
/* ============================================================================
   CSS Variables & Reset
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --secondary-color: #6366f1;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-color: #1f2937;
    --light-color: #f3f4f6;
    --border-color: #e5e7eb;
    --text-color: #374151;
    --text-light: #6b7280;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --max-width: 1200px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================================
   App Container
   ============================================================================ */

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================================
   Header
   ============================================================================ */

.app-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.menu-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.menu-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================================================
   Menu Overlay
   ============================================================================ */

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: flex-end;
}

.menu-overlay.active {
    display: flex;
}

.menu-content {
    background: white;
    width: 100%;
    max-height: 80vh;
    border-radius: 20px 20px 0 0;
    padding: 1.5rem;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.menu-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-content h2 {
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.menu-item {
    width: 100%;
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: var(--light-color);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

.menu-item:active {
    background: var(--border-color);
}

/* ============================================================================
   Main Content
   ============================================================================ */

.main-content {
    flex: 1;
    padding: 1rem;
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
}

/* ============================================================================
   Sections
   ============================================================================ */

.quick-add-section {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.quick-add-section .btn-primary {
    background-color: var(--success-color);
}

.quick-add-section .btn-primary:active {
    background-color: #059669;
}

.metric-selector-section,
.date-filter-section {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.metric-selector-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.date-filter-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.date-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.date-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.date-input-group .form-control {
    min-width: 0;
    width: 100%;
}

.date-input-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
}

.filter-buttons {
    display: flex;
    gap: 0.5rem;
}

.filter-buttons button {
    flex: 1;
}

/* ============================================================================
   Chart Section
   ============================================================================ */

.chart-section {
    background: white;
    padding: 1.5rem 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    min-height: 300px;
    position: relative;
}

.no-data-message {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--text-light);
    font-size: 1.125rem;
    text-align: center;
}

#metricChart {
    display: none;
    max-height: 300px;
}

#metricChart.active {
    display: block;
}

/* ============================================================================
   Stats Section
   ============================================================================ */

.stats-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card h3 {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* ============================================================================
   Recent Section
   ============================================================================ */

.recent-section {
    background: white;
    padding: 1.5rem 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.recent-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--dark-color);
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.recent-item {
    background: var(--light-color);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.recent-item-info {
    flex: 1;
}

.recent-item-date {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.25rem;
}

.recent-item-metrics {
    font-size: 0.875rem;
    color: var(--text-light);
}

.recent-item-actions {
    display: flex;
    gap: 0.5rem;
}

/* ============================================================================
   Forms
   ============================================================================ */

.form-control {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.875rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-secondary {
    background-color: var(--text-light);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 36px;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    min-height: 52px;
}

.btn-block {
    width: 100%;
}

/* ============================================================================
   Modal
   ============================================================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal.active {
    display: block;
}

.modal-content {
    background: white;
    margin: 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    margin: 1rem auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--dark-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 1.5rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* ============================================================================
   Toast
   ============================================================================ */

.toast {
    position: fixed;
    bottom: 2rem;
    left: 1rem;
    right: 1rem;
    padding: 1rem;
    background: var(--dark-color);
    color: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(100px);
    transition: all 0.3s;
    z-index: 3000;
    text-align: center;
}

.toast.active {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

/* ============================================================================
   Tooltip
   ============================================================================ */

.tooltip-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
    margin-left: 4px;
    vertical-align: middle;
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

.no-data {
    text-align: center;
    color: var(--text-light);
    font-style: italic;
    padding: 2rem;
}

.hidden {
    display: none !important;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (min-width: 768px) {
    .app-header h1 {
        font-size: 2rem;
    }

    .main-content {
        padding: 2rem;
    }

    .stats-section {
        grid-template-columns: repeat(4, 1fr);
    }

    .date-filter-section {
        flex-direction: row;
        align-items: flex-end;
    }

    .filter-buttons {
        flex-shrink: 0;
    }

    .form-actions {
        flex-direction: row;
    }

    .modal-content {
        margin: 2rem auto;
    }

    .chart-section {
        padding: 2rem;
        min-height: 400px;
    }

    #metricChart {
        max-height: 400px;
    }
}

@media (min-width: 1024px) {
    .recent-item {
        padding: 1.5rem;
    }
}