/* ============================================================
   WellnessDashboard - CSS Stylesheet
   ============================================================ */

/* ---------- CSS Variables / Theme ---------- */
:root {
    --primary: #4A90D9;
    --primary-dark: #357ABD;
    --primary-light: #7BB3E8;
    --secondary: #27AE60;
    --secondary-dark: #1E8449;
    --accent: #F39C12;
    --accent-dark: #D68910;
    --danger: #E74C3C;
    --danger-dark: #C0392B;
    --warning: #F1C40F;
    --info: #3498DB;
    --bg-primary: #F5F7FA;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;
    --text-muted: #BDC3C7;
    --border-color: #E1E8ED;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: all 0.25s ease;
    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --max-width: 1280px;
    --sidebar-width: 240px;
    --header-height: 64px;
}

/* ---------- Reset ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; height: auto; }

/* ---------- Loading ---------- */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #2C3E50 0%, #1a252f 100%);
    color: #ECF0F1;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ECF0F1;
    margin-top: 8px;
}

.sidebar-header .logo {
    font-size: 2rem;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #BDC3C7;
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid transparent;
    font-size: 0.95rem;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #ECF0F1;
}

.nav-item.active {
    background: rgba(74,144,217,0.15);
    color: var(--primary-light);
    border-left-color: var(--primary);
}

.nav-item .nav-icon {
    margin-right: 12px;
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px 32px;
    max-width: calc(var(--max-width) + 64px);
}

/* ---------- Page Header ---------- */
.page-header {
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-info h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-info .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-info .stat-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- Wellness Score Gauge ---------- */
.score-gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
}

.score-gauge {
    position: relative;
    width: 200px;
    height: 200px;
}

.score-gauge svg {
    width: 200px;
    height: 200px;
    transform: rotate(-90deg);
}

.score-gauge .track {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 12;
}

.score-gauge .progress {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.score-gauge .score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.score-gauge .score-number {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
}

.score-gauge .score-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ---------- Progress Bars ---------- */
.progress-bar-container {
    margin-bottom: 16px;
}

.progress-bar-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.progress-bar-header .label { color: var(--text-primary); font-weight: 500; }
.progress-bar-header .value { color: var(--text-secondary); }

.progress-bar {
    height: 10px;
    background: var(--border-color);
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.6s ease;
    background: var(--primary);
}

.progress-bar .fill.success { background: var(--secondary); }
.progress-bar .fill.warning { background: var(--accent); }
.progress-bar .fill.danger { background: var(--danger); }

/* ---------- Goal Cards ---------- */
.goal-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.goal-card:hover {
    box-shadow: var(--shadow-md);
}

.goal-card .goal-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.goal-card .goal-type {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.goal-card .goal-target {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.goal-card.met {
    border-color: var(--secondary);
    background: linear-gradient(135deg, rgba(39,174,96,0.04) 0%, var(--bg-card) 100%);
}

/* ---------- Streak Badge ---------- */
.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    background: linear-gradient(135deg, #F39C12 0%, #E67E22 100%);
    color: white;
}

.streak-badge.inactive {
    background: var(--border-color);
    color: var(--text-muted);
}

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74,144,217,0.15);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: var(--transition);
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
    background: var(--secondary);
    color: white;
}

.btn-success:hover { background: var(--secondary-dark); }

.btn-warning {
    background: var(--accent);
    color: white;
}

.btn-warning:hover { background: var(--accent-dark); }

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

/* ---------- Mood Selector ---------- */
.mood-selector {
    display: flex;
    gap: 12px;
    padding: 8px 0;
}

.mood-option {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.mood-option:hover {
    transform: scale(1.15);
    border-color: var(--primary);
}

.mood-option.selected {
    border-color: var(--primary);
    background: rgba(74,144,217,0.1);
    transform: scale(1.15);
}

/* ---------- Chart Container ---------- */
.chart-container {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
}

.chart-canvas {
    width: 100%;
    height: 250px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ---------- Table ---------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    text-align: left;
    padding: 12px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.data-table tr:hover td {
    background: rgba(74,144,217,0.03);
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}

.tab:hover { color: var(--primary); }

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ---------- Toast / Notifications ---------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

.toast.success { background: var(--secondary); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* ---------- Score Breakdown ---------- */
.score-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.breakdown-item {
    text-align: center;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

.breakdown-item .breakdown-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
}

.breakdown-item .breakdown-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* ---------- Completion Ring ---------- */
.completion-ring {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.completion-ring svg {
    width: 64px;
    height: 64px;
    transform: rotate(-90deg);
}

.completion-ring .ring-track {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 6;
}

.completion-ring .ring-fill {
    fill: none;
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s ease;
}

.completion-ring .ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 700;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .score-breakdown {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .score-breakdown {
        grid-template-columns: repeat(2, 1fr);
    }
}
