:root {
    --bg-color: #f4f3ef;
    /* Off-white paper */
    --surface: #ffffff;
    --ink: #1a1a1a;
    --accent: #bd93f9;
    /* Acid Purple */
    --accent-hover: #ff79c6;
    /* Hot Pink */
    
    --border-color: var(--ink);
    --text-muted: #555;
    --warning: #d32f2f;
    
    /* Toned down borders and shadows as requested */
    --border-thick: 1.5px solid var(--border-color);
    --border-thin: 1px solid var(--border-color);
    --shadow-hard: 3px 3px 0px 0px var(--ink);
    --shadow-hover: 1px 1px 0px 0px var(--ink);
}

/* Explicit dark mode */
[data-theme="dark"] {
    --bg-color: #121212;
    --surface: #1e1e1e;
    --ink: #f4f3ef;
    --accent: #9b6fd9;
    --shadow-hard: 3px 3px 0px 0px rgba(255, 255, 255, 0.2);
    --shadow-hover: 1px 1px 0px 0px rgba(255, 255, 255, 0.1);
    --border-color: #3a3a3a;
    --text-muted: #aaa;
    --warning: #ff5555;
}

/* Auto mode: follow system preference */
@media (prefers-color-scheme: dark) {
    [data-theme="auto"] {
        --bg-color: #121212;
        --surface: #1e1e1e;
        --ink: #f4f3ef;
        --accent: #9b6fd9;
        --shadow-hard: 3px 3px 0px 0px rgba(255, 255, 255, 0.2);
        --shadow-hover: 1px 1px 0px 0px rgba(255, 255, 255, 0.1);
        --border-color: #2a2a2a;
        --text-muted: #aaa;
        --warning: #ff5555;
    }
}

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

body {
    background-color: var(--bg-color);
    color: var(--ink);
    font-family: 'Space Grotesk', sans-serif;
    padding: 2rem;
    min-height: 100vh;
}

/* --- Header Section --- */
.marquee-container {
    border-top: var(--border-thick);
    border-bottom: var(--border-thick);
    background: var(--ink);
    color: var(--bg-color);
    overflow: hidden;
    white-space: nowrap;
    margin-bottom: 2rem;
    display: flex;
    /* Enable flex for seamless scrolling */
}

.marquee-content {
    display: flex;
    width: max-content;
    /* Critical for dynamic width */
    animation: scroll 30s linear infinite;
}

.marquee-text {
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
    text-transform: uppercase;
    padding: 0.5rem 0;
    /* Vertical padding only */
    white-space: nowrap;
    flex-shrink: 0;
}

@keyframes scroll {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
        /* Scroll exactly half to loop seamlessly */
    }
}

.header-layout {
    display: grid;
    /* Match calendar grid columns for perfect alignment */
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
    align-items: stretch;
}

.header-left {
    grid-column: span 2;
    /* Reverted to 2 spans */
}



.header-title {
    font-size: clamp(3rem, 6vw, 5rem);
    line-height: 0.9;
    text-transform: uppercase;
    letter-spacing: -0.05em;
}

.subtitle {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 1rem;
    margin-top: 1rem;
}

.subtitle-date {
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
    margin-top: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: var(--border-thick);
}

.district-select {
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--ink);
    padding: 0.6rem 2.2rem 0.6rem 0.75rem;
    width: fit-content;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    box-shadow: var(--shadow-hard);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23333' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    transition: all 0.15s ease;
}

.district-select:hover {
    transform: translate(1px, 1px);
    box-shadow: var(--shadow-hover);
}

.district-select:active {
    transform: translate(3px, 3px);
    box-shadow: none;
}

[data-theme="dark"] .district-select,
[data-theme="auto"] .district-select {
    border-color: rgba(255, 255, 255, 0.1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23f4f3ef' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}

.district-select option {
    background: var(--surface);
    color: var(--ink);
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
}

/* Quran/Hadith Section */
.reminders-box {
    grid-column: span 2;
    /* Default span */
    grid-column-end: -1;
    /* Push to the right edge */
    border: var(--border-thick);
    padding: 1.5rem;
    background: var(--surface);
    box-shadow: var(--shadow-hard);
    display: flex;
    flex-direction: column;
    justify-content: start;
    /* height: fit-content; */
    min-height: 250px;
    height: auto;
    transition: height 0.6s cubic-bezier(0.19, 1, 0.22, 1);
    overflow: hidden;
    /* Clip slide animations */
}

/* Medium Screens (e.g. Tablets) */
@media (max-width: 1300px) and (min-width: 900px) {
    .header-left {
        grid-column: span 2;
        /* 2 spans on medium screens as requested */
    }

    .reminders-box {
        grid-column: span 2;
        grid-column-end: -1;
    }
}

/* Small Screens / Stack - adjusted breakpoint to 900px */
@media (max-width: 900px) {

    .header-left,
    .reminders-box {
        grid-column: 1 / -1;
    }
}

.reminder-content-wrapper {
    opacity: 1;
    transform: translateY(0);
}

.reminder-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    background: var(--ink);
    color: var(--bg-color);
    display: inline-block;
    padding: 0.2rem 0.5rem;
    align-self: flex-start;
}

.reminder-title.warning {
    background: var(--warning);
    color: white;
}

.reminder-text {
    font-family: 'Space Grotesk', serif;
    font-size: 1.1rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    min-height: 3.5em;
    /* Prevent jumpiness */
}

.reminder-source {
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
    display: block;
    font-style: italic;
}

.reminder-divider {
    height: 1px;
    background: var(--ink);
    margin: 1.5rem 0;
    opacity: 0.2;
}

/* --- The Grid --- */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 4rem;
}

/* --- Day Card --- */
.day-card {
    background: var(--surface);
    border: var(--border-thick);
    box-shadow: var(--shadow-hard);
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    display: flex;
    flex-direction: column;
}

.day-card:hover {
    transform: translate(1px, 1px);
    box-shadow: var(--shadow-hover);
}

/* Special styling for "Active/Today" */
.day-card.active {
    background: var(--accent);
}

.day-card.active .label,
.day-card.active .time-value {
    border-color: var(--ink);
}

/* Completed State */
.day-card.completed {
    opacity: 0.6;
    background: #e6e6e6;
    border-color: #999;
}

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: var(--border-thin);
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 0.9rem;
}

.ramadan-day {
    background: var(--ink);
    color: var(--bg-color);
    padding: 0.1rem 0.4rem;
}

.date-separator {
    opacity: 0.8;
    margin: 0 0.15rem;
    font-weight: 400;
}

.day-name {
    opacity: 0.8;
    /* font-weight: 500; */
}

/* Card Body */
.card-body {
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.time-group {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.label {
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.time-value {
    font-family: 'Space Mono', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    position: relative;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.ampm {
    font-size: 0.6em;
    font-weight: 400;
    text-transform: uppercase;
}

/* Responsive Utilities */
@media (max-width: 800px) {
    .header-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .header-title {
        font-size: 3.5rem;
    }

    body {
        padding: 1rem;
    }
}

/* --- Debug Panel (Collapsible) --- */
.debug-panel {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    z-index: 1000;
    font-family: 'Space Mono', monospace;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 0.5rem;
}

.debug-toggle {
    width: 40px;
    height: 40px;
    border-radius: 0;
    border: 1.5px solid var(--border-color);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-hard);
    transition: all 0.2s ease;
    opacity: 0.5;
}

.debug-toggle:hover {
    opacity: 1;
    transform: translate(1px, 1px);
    box-shadow: var(--shadow-hover);
}

.debug-panel.open .debug-toggle {
    opacity: 1;
    background: var(--ink);
    color: var(--bg-color);
}

.debug-controls {
    display: none;
    background: var(--surface);
    color: var(--ink);
    padding: 0.75rem;
    border: 1.5px solid var(--border-color);
    border-radius: 0;
    box-shadow: var(--shadow-hard);
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.7rem;
}

.debug-panel.open .debug-controls {
    display: flex;
}

.debug-controls label {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 700;
}

.debug-controls input {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.3rem 0.4rem;
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--ink);
}

.debug-controls button {
    background: var(--ink);
    color: var(--bg-color);
    border: none;
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    margin-top: 0.25rem;
}

/* --- Countdown Section --- */
.countdown-container {
    margin-top: 2rem;
    padding: 2rem;
    border: var(--border-thick);
    background: var(--ink);
    color: var(--bg-color);
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    box-shadow: 8px 8px 0px 0px var(--accent);
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    position: relative;
    overflow: hidden;
    z-index: 100;
}

/* Reminder Animations */
@keyframes slideUpIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUpOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.slide-in {
    animation: slideUpIn 0.5s forwards;
}

.slide-out {
    animation: slideUpOut 0.5s forwards;
}

/* Fullscreen Mode State */
.countdown-container.fullscreen-active {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    border: none;
    border-radius: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    background: var(--bg-color); /* Match theme */
}

.countdown-container:hover {
    transform: translate(-4px, -4px);
    box-shadow: 12px 12px 0px 0px var(--accent-hover);
}

/* Disable hover effect in fullscreen */
.countdown-container.fullscreen-active:hover {
    transform: none;
    box-shadow: none;
}

.fullscreen-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    z-index: 10;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-btn:hover {
    opacity: 1;
    color: var(--bg-color);
    background: rgba(128, 128, 128, 0.25);
}

.timer-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
    z-index: 1;
    transition: all 0.5s ease;
}

/* Scale label in fullscreen */
.countdown-container.fullscreen-active .timer-label {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    letter-spacing: 4px;
}

.timer-value {
    font-family: 'Space Mono', monospace;
    font-size: clamp(3.5rem, 10vw, 6rem);
    font-weight: 700;
    line-height: 0.9;
    letter-spacing: -5px;
    color: var(--bg-color);
    z-index: 1;
    transition: all 0.5s ease;
}

.timer-subtext {
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    color: var(--bg-color);
    opacity: 0.6;
    margin-top: 1rem;
    transition: all 0.5s ease;
    text-transform: uppercase;
}

/* Fullscreen adjustments for subtext */
.countdown-container.fullscreen-active .timer-subtext {
    font-size: 1.5rem;
    margin-top: 2rem;
    opacity: 0.6;
    color: var(--ink); /* Match theme text */
}

/* Scale timer in fullscreen */
.countdown-container.fullscreen-active .timer-value {
    font-size: clamp(6rem, 20vw, 15rem);
    letter-spacing: -10px;
    text-shadow: none; /* Removed harsh shadow */
    color: var(--ink); /* Match theme text */
}

/* Response for smaller screens */
@media (max-width: 800px) {
    .countdown-container {
        padding: 1.5rem;
        margin-top: 1.5rem;
        width: 100%;
    }

    /* Adjust fullscreen font sizes for mobile */
    .countdown-container.fullscreen-active .timer-label {
        font-size: clamp(0.8rem, 4vw, 1.2rem);
        letter-spacing: 2px;
        margin-bottom: 1rem;
        text-align: center;
        padding: 0 1rem;
    }

    .countdown-container.fullscreen-active .timer-value {
        font-size: clamp(3rem, 15vw, 8rem);
        letter-spacing: -2px;
    }

    .countdown-container.fullscreen-active .timer-subtext {
        font-size: clamp(0.75rem, 3.5vw, 1.1rem);
        margin-top: 1.25rem;
    }

    .timer-value {
        font-size: 3.5rem;
        letter-spacing: -2px;
    }

    .timer-subtext {
        font-size: 0.75rem;
    }
}

/* --- Floating Action Bar --- */
.fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 999;
    font-family: 'Space Mono', monospace;
}

.fab-btn {
    width: 40px;
    height: 40px;
    border-radius: 0;
    border: 1.5px solid var(--border-color);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-hard);
    transition: all 0.2s ease;
}

.fab-btn:hover {
    transform: translate(1px, 1px);
    box-shadow: var(--shadow-hover);
}

.theme-switcher {
    display: flex;
    border: 1.5px solid var(--border-color);
    border-radius: 0;
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow-hard);
}

.theme-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.theme-btn:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

.theme-btn.active {
    background: var(--ink);
    color: var(--bg-color);
}

.theme-btn:hover:not(.active) {
    background: var(--border-color);
    color: var(--ink);
}

/* Hide FAB in fullscreen */
.countdown-container.fullscreen-active ~ .fab {
    display: none;
}

/* --- Notification Settings Modal --- */
.notif-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.notif-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.notif-modal {
    background: var(--surface);
    border: var(--border-thick);
    box-shadow: none;
    width: 90%;
    max-width: 440px;
    font-family: 'Space Grotesk', sans-serif;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s cubic-bezier(0.19, 1, 0.22, 1);
}

.notif-modal-overlay.active .notif-modal {
    transform: translateY(0) scale(1);
}

.notif-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: var(--border-thin);
}

.notif-modal-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.notif-modal-close {
    background: transparent;
    border: none;
    color: var(--ink);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.notif-modal-close:hover {
    opacity: 1;
    background: rgba(128, 128, 128, 0.25);
}

.notif-modal-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notif-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.notif-option-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.notif-option-label {
    font-weight: 700;
    font-size: 0.9rem;
}

.notif-option-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Toggle Switch */
.notif-toggle {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

.notif-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.notif-toggle-track {
    display: block;
    width: 42px;
    height: 24px;
    background: rgba(128, 128, 128, 0.3);
    border: none;
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease;
    border-radius: 12px;
}

.notif-toggle-track::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--surface);
    top: 4px;
    left: 4px;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.notif-toggle input:checked + .notif-toggle-track {
    background: var(--accent);
}

.notif-toggle input:checked + .notif-toggle-track::after {
    transform: translateX(18px);
}

/* Slider Value Display */
.notif-slider-value {
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
    color: #9b6fd9;
}

/* Range Slider */
.notif-slider {
    width: 100%;
    height: 2px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(128, 128, 128, 0.25);
    outline: none;
    cursor: pointer;
    margin-top: 0.25rem;
}

.notif-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border: none;
    cursor: pointer;
}

.notif-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent);
    border: none;
    border-radius: 0;
    cursor: pointer;
}

/* Save Button */
.notif-save-btn {
    margin: 0 1.25rem 1.25rem;
    width: calc(100% - 2.5rem);
    padding: 0.7rem;
    background: var(--accent);
    color: var(--ink);
    border: none;
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 4px 4px 0px 0px var(--ink);
    transition: all 0.15s ease;
}

.notif-save-btn:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px 0px var(--ink);
}

.notif-save-btn:active {
    transform: translate(4px, 4px);
    box-shadow: none;
}
