/* Lucera Health - Light Theme Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-primary: #F5F7F4;
    --bg-secondary: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --accent-primary: #3D9970;
    --accent-light: rgba(61, 153, 112, 0.12);
    --accent-hover: #2E7D5A;
    --accent-gradient: linear-gradient(135deg, #3D9970 0%, #2E7D5A 100%);
    --text-primary: #1A1D17;
    --text-secondary: #5A6354;
    --text-muted: #8A9183;
    --border-color: #E2E8DF;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.08);
    --card-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
    --danger-color: #DC4C4C;
    --danger-bg: #FEF2F2;
    --success-color: #3D9970;
    --success-bg: rgba(61, 153, 112, 0.12);
    --warning-color: #E8A020;
    --warning-bg: #FEF8E8;
    --info-color: #4A90D9;
    --info-bg: rgba(74, 144, 217, 0.1);
    --sidebar-width: 240px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 2px 8px rgba(61, 153, 112, 0.3);
}

.brand-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: var(--accent-light);
    color: var(--accent-primary);
}

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent-primary);
    font-weight: 600;
    border-left: 3px solid var(--accent-primary);
    margin-left: -3px;
}

.nav-item svg {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(61, 153, 112, 0.25);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.user-plan {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: var(--danger-bg);
    color: var(--danger-color);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: #FCE8E8;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px 48px;
    min-height: 100vh;
}

/* Page Headers */
.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.page-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.2s ease;
    margin-bottom: 0;
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title svg {
    color: var(--accent-primary);
}

.card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* Stat Cards */
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(61, 153, 112, 0.25);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.stat-sublabel {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Accent Card (Pro Tip style) */
.accent-card {
    background: var(--accent-gradient);
    color: white;
    border: none;
    box-shadow: 0 4px 16px rgba(61, 153, 112, 0.25);
}

.accent-card .card-title,
.accent-card h3 {
    color: white;
    font-weight: 600;
}

.accent-card p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(61, 153, 112, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(61, 153, 112, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--accent-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--accent-light);
    color: var(--accent-primary);
}

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

.btn-danger:hover {
    background: #FCE8E8;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-green {
    background: var(--accent-gradient);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(61, 153, 112, 0.3);
}

.btn-green:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(61, 153, 112, 0.4);
    transform: translateY(-1px);
}

.btn-disconnect {
    background: var(--danger-bg);
    color: var(--danger-color);
    padding: 12px 24px;
    border: 1px solid var(--danger-color);
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.btn-disconnect:hover {
    background: #FCE8E8;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-sublabel {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.form-group input,
.form-group textarea,
.form-group select,
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group input::placeholder,
.form-group textarea::placeholder,
.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    font-size: 0.95rem;
    color: var(--text-primary);
}

tr:hover {
    background: var(--bg-primary);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-color);
    font-weight: 600;
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-color);
    font-weight: 600;
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger-color);
    font-weight: 600;
}

.badge-info {
    background: var(--info-bg);
    color: var(--info-color);
    font-weight: 600;
}

.device-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.device-badge.withings {
    background: rgba(0, 150, 136, 0.15);
    color: #00796B;
    font-weight: 600;
}

.device-badge.whoop {
    background: rgba(255, 87, 34, 0.12);
    color: #E64A19;
    font-weight: 600;
}

.device-badge.oura {
    background: rgba(156, 39, 176, 0.12);
    color: #8E24AA;
    font-weight: 600;
}

/* Charts Container */
.chart-container {
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 16px rgba(61, 153, 112, 0.2);
}

.chart-container canvas {
    max-height: 250px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 40px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.95rem;
    max-width: 400px;
    margin: 0 auto;
}

/* Auth Layout */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: var(--bg-primary);
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 40px;
}

.auth-brand .brand-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    font-size: 1.5rem;
    box-shadow: 0 4px 16px rgba(61, 153, 112, 0.35);
}

.auth-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--card-shadow);
}

.auth-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Messages */
.error-message {
    background: var(--danger-bg);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.success-message {
    background: var(--accent-light);
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* Diary Styles */
.longevity-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 24px;
}

.longevity-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.checkbox-item:hover {
    border-color: var(--accent-primary);
    background: var(--accent-light);
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.checkbox-item span {
    font-size: 0.9rem;
    color: var(--text-secondary);
    user-select: none;
}

.checkbox-item input[type="checkbox"]:checked + span {
    color: var(--text-primary);
    font-weight: 500;
}

/* Custom Tracking Section */
.custom-tracking-section .section-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.custom-item-add {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.custom-item-add input[type="text"] {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.custom-item-add input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.custom-item-add input[type="text"]::placeholder {
    color: var(--text-secondary);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.custom-checkbox-item {
    position: relative;
}

.custom-checkbox-item span {
    flex: 1;
}

.delete-custom-item {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s;
}

.custom-checkbox-item:hover .delete-custom-item {
    opacity: 1;
}

.delete-custom-item:hover {
    background: #fee2e2;
    color: #dc2626;
}

.empty-custom-items {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
    padding: 12px;
}

/* Diary Entry Display */
.diary-entry {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
}

.diary-entry h4 {
    color: var(--accent-primary);
    margin-bottom: 8px;
    font-weight: 600;
}

/* File Upload */
.file-upload-area {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-primary);
}

.file-upload-area:hover {
    border-color: var(--accent-primary);
    background: var(--accent-light);
}

.file-upload-area.drag-over {
    border-color: var(--accent-primary);
    background: var(--accent-light);
}

.file-upload-area input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.file-upload-label svg {
    color: var(--accent-primary);
    margin-bottom: 8px;
}

.file-upload-label p {
    margin: 0;
}

.file-upload-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.file-selected {
    color: var(--accent-primary);
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Report Item */
.report-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.report-item h4 {
    margin: 0 0 4px 0;
    color: var(--text-primary);
    font-weight: 600;
}

.report-item p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Section Divider */
.section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 32px 0 24px;
}

.section-divider svg {
    color: var(--text-secondary);
}

.section-divider h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Container for old pages */
.container {
    max-width: 900px;
    padding: 0;
}

/* Weight source info */
.weight-source-info {
    margin-top: 8px;
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        padding: 24px 32px;
    }
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 100;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 70px 20px 20px 20px;
    }
    
    .card-grid,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .checkbox-grid {
        grid-template-columns: 1fr;
    }
    
    .mobile-menu-btn {
        display: flex;
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 101;
        width: 44px;
        height: 44px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: var(--text-primary);
        box-shadow: var(--card-shadow);
    }

    .mobile-menu-btn:hover {
        background: var(--accent-light);
        color: var(--accent-primary);
    }
}

@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none;
    }
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-primary); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid { display: grid; }
.hidden { display: none; }
