@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
    /* MD3 Color Palette (Indigo/Violet base) */
    --md-sys-color-primary: #3f51b5;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #e8eaf6;
    --md-sys-color-on-primary-container: #1a237e;

    --md-sys-color-secondary: #009688;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #e0f2f1;
    --md-sys-color-on-secondary-container: #004d40;

    --md-sys-color-tertiary: #ef5350;

    --md-sys-color-background: #fdfbff;
    --md-sys-color-on-background: #1b1b1f;

    --md-sys-color-surface: #fdfbff;
    --md-sys-color-on-surface: #1b1b1f;
    --md-sys-color-surface-variant: #e1e2ec;
    --md-sys-color-on-surface-variant: #44474f;
    --md-sys-color-outline: #74777f;
    --md-sys-color-outline-variant: #c4c6d0;

    --md-sys-color-success: #4caf50;
    --md-sys-color-error: #ba1a1a;
    --md-sys-color-on-error: #ffffff;

    /* MD3 Elevations */
    --md-sys-elevation-0: none;
    --md-sys-elevation-1: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-2: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-3: 0px 1px 3px rgba(0, 0, 0, 0.3), 0px 4px 8px 3px rgba(0, 0, 0, 0.15);

    /* Layout & Shape */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 28px;
    /* For FABs and Stadium buttons */

    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;

    --font-heading: 'Roboto', sans-serif;
    --font-body: 'Roboto', sans-serif;
}

/* Dark Mode Variables */
body.dark-mode {
    --md-sys-color-primary: #9fa8da;
    --md-sys-color-on-primary: #1a237e;
    --md-sys-color-primary-container: #283593;
    --md-sys-color-on-primary-container: #e8eaf6;

    --md-sys-color-secondary: #80cbc4;
    --md-sys-color-on-secondary: #004d40;
    --md-sys-color-secondary-container: #00695c;
    --md-sys-color-on-secondary-container: #e0f2f1;

    --md-sys-color-background: #1b1b1f;
    --md-sys-color-on-background: #e3e2e6;

    --md-sys-color-surface: #1b1b1f;
    --md-sys-color-on-surface: #e3e2e6;
    --md-sys-color-surface-variant: #44474f;
    --md-sys-color-on-surface-variant: #c4c6d0;
    --md-sys-color-outline: #8e9099;
    --md-sys-color-outline-variant: #44474f;

    --md-sys-color-error: #ffb4ab;
    --md-sys-color-on-error: #690005;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-body);
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* === Material Symbols === */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    /* Preferred icon size */
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* === Layout === */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    background-color: var(--md-sys-color-background);
}

.app-bar {
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    padding: var(--spacing-sm) var(--spacing-md);
    padding-top: max(var(--spacing-sm), env(safe-area-inset-top));
    /* MD3 uses less shadows, more tint. Using small shadow for separation */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    z-index: 10;
    transition: background-color 0.3s;
}

.app-bar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.app-title-wrapper {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.app-logo {
    color: var(--md-sys-color-primary);
    font-size: 28px;
}

.app-title {
    font-size: 1.375rem;
    /* 22px */
    font-weight: 400;
    color: var(--md-sys-color-on-surface);
}

.app-actions {
    display: flex;
    gap: var(--spacing-xs);
}

.icon-button {
    background: transparent;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.icon-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.icon-button:active {
    background-color: rgba(0, 0, 0, 0.1);
}

.dark-mode .icon-button:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* === Main Content === */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    padding-bottom: 88px;
    /* Space for FAB */
    scrollbar-width: thin;
}

/* === Tabs (Navigation Rail style) === */
.tabs-container {
    background-color: var(--md-sys-color-surface);
    border-top: 1px solid var(--md-sys-color-outline-variant);
    /* For Bottom Navigation Bar style in Mobile */
    order: 3;
    /* Move to bottom? No, keeping on top as per previous layout, but styled nicely */
}

/* User had tabs on top below title. Let's keep them there but style properly */
.tabs-scroll {
    display: flex;
    overflow-x: auto;
    padding: 0 var(--spacing-sm);
}

.tab {
    flex: 1;
    padding: 12px 0;
    background: none;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 64px;
    position: relative;
    /* transition: color 0.2s; */
}

.tab .material-symbols-outlined {
    padding: 4px 20px;
    border-radius: 16px;
    transition: background-color 0.2s;
}

.tab.active {
    color: var(--md-sys-color-on-surface);
}

.tab.active .material-symbols-outlined {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.tab-label {
    font-size: 0.75rem;
    font-weight: 500;
}

/* === Cards === */
.card {
    background-color: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    transition: background-color 0.3s, border-color 0.3s;
    /* Optional slight elevation */
    /* box-shadow: var(--md-sys-elevation-1); */
}

/* Elevated Card Variant if needed */
.card-elevated {
    background-color: var(--md-sys-color-surface);
    box-shadow: var(--md-sys-elevation-1);
    border: none;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--md-sys-color-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* === Day/Plan Card === */
.day-card {
    background-color: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    overflow: hidden;
}

.day-header {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    padding: var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

.day-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.exercise-item {
    display: flex;
    align-items: center;
    padding: 12px var(--spacing-md);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    cursor: pointer;
    transition: background 0.2s;
}

.exercise-item:last-child {
    border-bottom: none;
}

.exercise-item:active {
    background-color: var(--md-sys-color-surface-variant);
}

.exercise-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--md-sys-color-primary);
    border-radius: 2px;
    /* Checkboxes are usually square-ish */
    margin-right: var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-color-on-primary);
    flex-shrink: 0;
    transition: background 0.2s;
}

.exercise-checkbox.checked {
    background-color: var(--md-sys-color-primary);
}

.exercise-content {
    flex: 1;
}

.exercise-title {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--md-sys-color-on-surface);
}

.exercise-info-btn {
    background: none;
    border: none;
    color: var(--md-sys-color-outline);
    cursor: pointer;
    display: flex;
    align-items: center;
}

.exercise-details {
    font-size: 0.85rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 2px;
}

.time-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-right: 6px;
}

.time-morning {
    background-color: #fff9c4;
    color: #5d4037;
}

.time-afternoon {
    background-color: #ffe0b2;
    color: #5d4037;
}

.time-evening {
    background-color: #e1bee7;
    color: #4a148c;
}

.dark-mode .time-morning {
    background-color: #fbc02d;
    color: #000;
}

.dark-mode .time-afternoon {
    background-color: #ffa000;
    color: #000;
}

.dark-mode .time-evening {
    background-color: #7b1fa2;
    color: #fff;
}

/* === Progress === */
.progress-container {
    margin-bottom: var(--spacing-md);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-xs);
    font-size: 0.9rem;
    color: var(--md-sys-color-on-surface-variant);
}

.progress-bar {
    height: 8px;
    /* Thinner for MD3 */
    background-color: var(--md-sys-color-surface-variant);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--md-sys-color-secondary);
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.stat-card {
    background-color: var(--md-sys-color-secondary-container);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--md-sys-color-on-secondary-container);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* === Settings/Forms === */
.settings-group {
    margin-bottom: var(--spacing-lg);
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    cursor: pointer;
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
}

.text-field {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 4px;
    /* Text fields usually have smaller radius */
    font-family: inherit;
    font-size: 1rem;
    background-color: transparent;
    color: var(--md-sys-color-on-surface);
    transition: border-color 0.2s;
}

.text-field:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
    padding: 11px 15px;
    /* Adjust for border width change */
}

/* Buttons */
.button {
    padding: 10px 24px;
    border: none;
    border-radius: 20px;
    /* Stadium shape */
    font-weight: 500;
    font-size: 0.875rem;
    letter-spacing: 0.1px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.filled-button,
.button.primary {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    box-shadow: var(--md-sys-elevation-1);
}

.filled-button:active {
    box-shadow: none;
}

.text-button {
    background: transparent;
    color: var(--md-sys-color-primary);
    padding: 10px 12px;
}

.text-button:hover {
    background-color: rgba(63, 81, 181, 0.08);
    /* Primary opacity */
}

.button.full {
    width: 100%;
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 32px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--md-sys-color-surface-variant);
    border: 2px solid var(--md-sys-color-outline);
    transition: .4s;
    border-radius: 16px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 6px;
    bottom: 6px;
    background-color: var(--md-sys-color-outline);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
    background-color: var(--md-sys-color-on-primary);
    height: 24px;
    width: 24px;
    left: 2px;
    bottom: 2px;
}

/* === Floating Action Button === */
.fab-container {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--spacing-sm);
}

.fab-main {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    /* MD3 FAB shape */
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border: none;
    box-shadow: var(--md-sys-elevation-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.2s;
}

.fab-main:active {
    transform: scale(0.95);
    box-shadow: var(--md-sys-elevation-1);
}

.fab-options {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--spacing-sm);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.2s;
}

.fab-options.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.fab-option {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border: none;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: var(--md-sys-elevation-2);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

/* === Modal === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    /* Scrim */
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
    backdrop-filter: blur(2px);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    width: 100%;
    max-width: 400px;
    border-radius: 28px;
    /* High radius for Dialogs */
    padding: 24px;
    box-shadow: var(--md-sys-elevation-3);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.2, 0.0, 0, 1.0);
    max-height: 85vh;
    overflow-y: auto;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: 24px;
}

.modal-icon {
    font-size: 24px;
    color: var(--md-sys-color-secondary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    margin-top: 24px;
}

/* === Notification === */
/* Styled in index.html inline originally, moving here partially */
.notification {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--md-sys-color-on-surface);
    color: var(--md-sys-color-surface);
    padding: 14px 16px;
    border-radius: 4px;
    z-index: 3000;
    box-shadow: var(--md-sys-elevation-2);
    font-size: 0.875rem;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 90vw;
}

.notification.show {
    display: flex;
}

.notification-icon {
    color: var(--md-sys-color-surface);
}

/* === Timer === */
.timer-container {
    background-color: var(--md-sys-color-surface-variant);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-top: var(--spacing-md);
    text-align: center;
    border: none;
}

.timer-display {
    font-size: 3rem;
    font-weight: 500;
    font-family: 'Roboto Mono', monospace;
    color: var(--md-sys-color-on-surface);
    margin: var(--spacing-sm) 0;
}

/* === Confetti === */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}