/* ===== CSS Variables ===== */
:root {
    --primary: #667eea;
    --primary-dark: #764ba2;
    --primary-light: #f0f4ff;
    --bg-light: #ffffff;
    --bg-dark: #09090b;
    --bg-dark-secondary: #1f2937;
    --text-light: #333333;
    --text-dark: #ffffff;
    --border-light: #e2e8f0;
    --border-dark: #374151;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-light);
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.6;
}

body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-dark);
}

/* ===== Typography ===== */
h1, h2, h3 {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Navigation ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: background 0.3s ease, border-color 0.3s ease;
}

body.dark-mode .navbar {
    background: rgba(15, 23, 42, 0.9);
    border-bottom-color: var(--border-dark);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 20px;
    padding-right: 20px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.nav-icon {
    font-size: 1.5rem;
}

.nav-title {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-desktop {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

.nav-mobile {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border-light);
}

body.dark-mode .nav-mobile {
    border-top-color: var(--border-dark);
}

/* ===== Buttons ===== */
.btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.nav-btn {
    background: none;
    border: none;
    color: #9ca3af;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    transition: color 0.3s ease;
}

body.dark-mode .nav-btn {
    color: #9ca3af;
}

.nav-btn:hover, .nav-btn.active {
    color: var(--primary);
}

body.light-mode .nav-btn {
    color: #6b7280;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

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

body.dark-mode .btn-secondary {
    color: var(--text-dark);
    border-color: var(--border-dark);
}

.btn-secondary:hover {
    background: var(--primary-light);
}

body.dark-mode .btn-secondary:hover {
    background: rgba(102, 126, 234, 0.1);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ===== Progress Section ===== */
.progress-section {
    margin-top: 80px;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.progress-year {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.progress-detail {
    font-size: 1rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: white;
    transition: width 0.3s ease;
}

/* ===== Week Progress Section (NEW in v0.3) ===== */
.week-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid rgba(255, 255, 255, 0.3);
}

.week-progress-container {
    margin-top: 0.75rem;
    transition: all 0.3s ease;
}

.week-progress-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.week-settings-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 0.375rem;
    padding: 0.375rem 0.625rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.week-settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.week-toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 1;
}

.week-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.week-progress-detail {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    opacity: 0.9;
}

/* ===== Main Container ===== */
.main-container {
    padding: 2rem 0;
    min-height: calc(100vh - 80px);
}

/* ===== Views ===== */
.view-section {
    display: none;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== Controls Section ===== */
.controls-section {
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: flex-end;
}

body.dark-mode .controls-section {
    background: var(--bg-dark-secondary);
    border-color: var(--border-dark);
}

.color-picker-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.color-picker-group label {
    font-weight: 600;
    font-size: 0.875rem;
}

.color-picker-group input[type="color"],
.color-input {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease;
}

.color-picker-group input[type="color"]:hover,
.color-input:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.button-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ===== Calendar Grid ===== */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
    gap: 8px;
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

body.dark-mode .calendar-grid {
    background: var(--bg-dark-secondary);
    border-color: var(--border-dark);
}

@media (min-width: 768px) {
    .calendar-grid {
        grid-template-columns: repeat(14, 1fr);
    }
}

@media (min-width: 1024px) {
    .calendar-grid {
        grid-template-columns: repeat(26, 1fr);
    }
}

.day-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--border-light);
    background: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0);
}

body.dark-mode .day-dot {
    border-color: var(--border-dark);
    background: #4b5563;
}

.day-dot:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.day-dot.has-note::after {
    content: '★';
    position: absolute;
    top: -6px;
    right: -6px;
    color: var(--warning);
    font-size: 0.9rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.day-dot:hover {
    color: rgba(255, 255, 255, 1);
}

/* ===== Life Overview ===== */
.life-overview-grid {
    display: grid;
    gap: 2rem;
}

.year-section {
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

body.dark-mode .year-section {
    background: var(--bg-dark-secondary);
    border-color: var(--border-dark);
}

.year-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.year-section-title.current {
    color: var(--primary);
}

.year-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
    gap: 6px;
}

@media (min-width: 768px) {
    .year-section-grid {
        grid-template-columns: repeat(14, 1fr);
    }
}

@media (min-width: 1024px) {
    .year-section-grid {
        grid-template-columns: repeat(26, 1fr);
    }
}

/* ===== Year Range Selector ===== */
.year-range-selector {
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

body.dark-mode .year-range-selector {
    background: var(--bg-dark-secondary);
    border-color: var(--border-dark);
}

.year-range-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.year-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .year-inputs {
        grid-template-columns: 1fr;
    }
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-weight: 600;
    font-size: 0.875rem;
}

.input-group input[type="number"] {
    padding: 0.75rem;
    border: 2px solid var(--border-light);
    border-radius: 0.5rem;
    font-size: 1rem;
    background: var(--bg-light);
    color: var(--text-light);
    transition: border-color 0.3s ease;
}

body.dark-mode .input-group input[type="number"] {
    background: #1f2937;
    color: white;
    border-color: var(--border-dark);
}

.input-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.year-sliders {
    margin-bottom: 1.5rem;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: #999;
    margin-bottom: 0.75rem;
}

.year-slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    outline: none;
    padding: 0;
    margin: 8px 0;
    -webkit-appearance: none;
    appearance: none;
}

.year-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--primary);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.year-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.year-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--primary);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.year-display {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem;
    border-radius: 0.5rem;
    text-align: center;
    font-weight: 600;
}

/* ===== Key Moments ===== */
.key-moments-container {
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

body.dark-mode .key-moments-container {
    background: var(--bg-dark-secondary);
    border-color: var(--border-dark);
}

.key-moments-empty {
    text-align: center;
    padding: 3rem 2rem;
}

.key-moments-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.key-moments-empty-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.key-moments-empty-text {
    color: #9ca3af;
}

body.dark-mode .key-moments-empty-text {
    color: #6b7280;
}

.key-moments-list {
    display: grid;
    gap: 1rem;
}

.key-moments-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.key-moment-card {
    border-left: 4px solid;
    padding: 1.5rem;
    border-radius: 0.5rem;
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

body.dark-mode .key-moment-card {
    background: #1f2937;
    border-color: var(--border-dark);
}

.key-moment-card:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.key-moment-content {
    flex: 1;
}

.key-moment-date {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #9ca3af;
    margin-bottom: 0.5rem;
}

.key-moment-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.key-moment-note {
    font-size: 1rem;
    line-height: 1.6;
}

.key-moment-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* ===== Modals ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 1rem;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.modal-wide {
    max-width: 500px;
}

body.dark-mode .modal-content {
    background: var(--bg-dark-secondary);
    border-color: var(--border-dark);
}

.modal-confirm {
    text-align: center;
}

.confirm-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.modal-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal-day-info {
    font-size: 0.875rem;
    color: #9ca3af;
    margin-bottom: 1.5rem;
}

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.textarea-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-light);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    min-height: 100px;
    background: var(--bg-light);
    color: var(--text-light);
}

body.dark-mode .textarea-input {
    background: #1f2937;
    color: white;
    border-color: var(--border-dark);
}

.textarea-input:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    flex-direction: column;
}

.modal-buttons .btn {
    flex: 1;
}

/* ===== Week Settings Modal (NEW in v0.3) ===== */
.time-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.time-select {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-light);
    border-radius: 0.5rem;
    font-size: 1rem;
    background: var(--bg-light);
    color: var(--text-light);
    cursor: pointer;
}

body.dark-mode .time-select {
    background: #1f2937;
    color: white;
    border-color: var(--border-dark);
}

.time-input {
    width: 60px;
    padding: 0.75rem;
    border: 2px solid var(--border-light);
    border-radius: 0.5rem;
    font-size: 1rem;
    text-align: center;
    background: var(--bg-light);
    color: var(--text-light);
}

body.dark-mode .time-input {
    background: #1f2937;
    color: white;
    border-color: var(--border-dark);
}

.time-input:focus,
.time-select:focus {
    outline: none;
    border-color: var(--primary);
}

.settings-info {
    background: rgba(102, 126, 234, 0.05);
    padding: 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid var(--primary);
    margin-top: 1rem;
}

body.dark-mode .settings-info {
    background: rgba(102, 126, 234, 0.1);
}

.settings-info p {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
}

body.dark-mode .settings-info p {
    color: #9ca3af;
}

/* ===== Key Moment Toggle ===== */
.key-moment-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(102, 126, 234, 0.05);
    border-left: 4px solid var(--primary);
    border-radius: 0.5rem;
}

body.dark-mode .key-moment-toggle {
    background: rgba(102, 126, 234, 0.1);
}

.key-moment-toggle label {
    font-weight: 600;
    margin-bottom: 0;
}

.toggle-btn {
    width: 48px;
    height: 24px;
    border-radius: 12px;
    border: none;
    background: #d1d5db;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.toggle-btn.active {
    background: var(--primary);
}

.toggle-btn::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
}

.toggle-btn.active::after {
    left: 26px;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .nav-mobile-toggle {
        display: block;
    }

    .nav-desktop {
        display: none;
    }

    .nav-mobile.active {
        display: flex;
    }

    .button-group {
        width: 100%;
    }

    .button-group .btn {
        flex: 1;
        min-width: 0;
    }

    .controls-section {
        flex-direction: column;
        align-items: stretch;
    }

    .color-picker-group {
        align-items: center;
    }

    .button-group {
        width: 100%;
    }

    .calendar-grid {
        grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
        gap: 6px;
    }

    .day-dot {
        width: 28px;
        height: 28px;
    }

    .modal-content {
        margin: 0 auto;
    }

    .time-input-group {
        flex-wrap: wrap;
    }

    .time-select {
        width: 100%;
    }
}

/* ===== Animations ===== */
@media (prefers-reduced-motion: no-preference) {
    * {
        scroll-behavior: smooth;
    }

    button, input {
        transition: all 0.2s ease;
    }
}

/* ===== Accessibility ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
