:root {
    /* Base Colors */
    --primary-green: #2E7D32;
    --dark-green: #1B5E20;
    --light-green: #E8F5E9;
    --accent-gold: #FDD835;

    /* Default Theme (Day/Fajr) - Light Mode */
    --text-main: #1f2937;
    /* Dark grey for readability on light bg */
    --text-secondary: #374151;
    /* Slightly darker grey */
    --card-bg: rgba(255, 255, 255, 0.65);
    /* Less transparent for readability */
    --card-border: rgba(255, 255, 255, 0.6);
    --card-blur: 20px;
    --active-card-bg: rgba(46, 125, 50, 0.9);
    /* Solid green for active */
    --active-text: #ffffff;
    --select-bg: rgba(255, 255, 255, 0.95);
    --select-text: #1f2937;
    --shadow-soft: 0 8px 16px -2px rgba(0, 0, 0, 0.15), 0 4px 8px -2px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(46, 125, 50, 0.4);
}

/* Night & Sunset Theme - Dark Mode */
body.bg-night,
body.bg-sunset {
    --text-main: #f9fafb;
    /* White-ish for readability on dark bg */
    --text-secondary: #e5e7eb;
    /* Lighter grey */
    --card-bg: rgba(20, 20, 20, 0.7);
    /* Darker and less transparent */
    --card-border: rgba(255, 255, 255, 0.15);
    --active-card-bg: rgba(46, 125, 50, 0.95);
    --select-bg: rgba(255, 255, 255, 0.95);
    /* Keep select white for standard feel */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: #2E7D32;
    /* Consistently solid background behind everything */
    min-height: 100vh;
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    position: relative;
    /* Needed for pseudo-element positioning */
}

/* Background Image Layer */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    /* Behind overlay and content */
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-image: url('bg-day.png');
    /* Default */
    transition: background-image 1s ease-in-out;
    filter: blur(3px);
    /* The requested blur */
    transform: scale(1.02);
    /* Scale up slightly to hide blurred edges */
}

/* Background classes applied via JS - Targeting Pseudo-element */
body.bg-fajr::before {
    background-image: url('bg-fajr.png');
}

body.bg-day::before {
    background-image: url('bg-day.png');
}

body.bg-sunset::before {
    background-image: url('bg-sunset.png');
}

body.bg-night::before {
    background-image: url('bg-night.png');
}

/* Background Overlay for readability */
.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    /* Base overlay for all themes to ensure text pop */
    z-index: -1;
    pointer-events: none;
    transition: background 0.5s ease;
}

body.bg-night .background-overlay {
    background: rgba(0, 0, 0, 0.5);
    /* Darker for night */
}

body.bg-sunset .background-overlay {
    background: rgba(0, 0, 0, 0.3);
    /* Moderate for sunset */
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Glassmorphism Utility */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(var(--card-blur));
    -webkit-backdrop-filter: blur(var(--card-blur));
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    transition: background 0.5s ease, border-color 0.5s ease, transform 0.3s ease;
}

/* Header */
header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    padding: 10px 0;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-green);
    /* For logo, maybe allow it to be white in night mode? */
}

body.bg-night .logo-area,
body.bg-sunset .logo-area {
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.logo-area i {
    font-size: 1.8rem;
}

.logo-area h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Custom Select */
.custom-select-wrapper {
    position: relative;
    width: 250px;
}

select {
    width: 100%;
    padding: 12px 15px 12px 40px;
    border: 2px solid var(--primary-green);
    border-radius: 12px;
    background-color: var(--select-bg);
    color: var(--select-text);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    outline: none;
    transition: all 0.2s;
    box-shadow: var(--shadow-soft);
}

select:focus {
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.2);
}

.select-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-green);
    pointer-events: none;
}

/* Hero Section */
.hero-section {
    padding: 30px;
    text-align: center;
    border-top: 5px solid var(--primary-green);
    position: relative;
    overflow: hidden;
}

.hero-title {
    font-size: 1.1rem;
    color: var(--text-secondary);
    /* Dynamic */
    font-weight: 500;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.countdown-timer {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--text-main);
    /* Dynamic for visibility */
    font-variant-numeric: tabular-nums;
    margin: 5px 0;
}

/* Ensure Fajr/Day (light bg) uses dark text or green */
body.bg-day .countdown-timer,
body.bg-fajr .countdown-timer {
    color: var(--primary-green);
}

/* Ensure Night (dark bg) uses white or gold */
body.bg-night .countdown-timer,
body.bg-sunset .countdown-timer {
    color: #fff;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.next-prayer-info {
    font-size: 1.1rem;
    color: var(--text-main);
    font-weight: 500;
}

.next-prayer-info span {
    color: var(--primary-green);
    font-weight: 700;
}

body.bg-night .next-prayer-info span {
    color: var(--accent-gold);
}

/* Times Grid */
.times-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (min-width: 600px) {
    .times-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.time-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: default;
}

.time-card:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.4);
    /* Slightly closer to opaque on hover for day */
}

body.bg-night .time-card:hover {
    background: rgba(0, 0, 0, 0.6);
    /* Darker on hover for night */
}

.time-card.active {
    background: var(--active-card-bg);
    color: var(--active-text);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-glow);
}

/* Icon in card */
.card-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--light-green);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-green);
    font-size: 1.2rem;
    flex-shrink: 0;
}

.time-card.active .card-icon {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--active-text);
}

.card-info {
    display: flex;
    flex-direction: column;
}

.card-info h3 {
    font-size: 0.9rem;
    font-weight: 400;
    opacity: 0.9;
    margin-bottom: 2px;
    color: var(--text-main);
}

.time-card.active .card-info h3 {
    opacity: 1;
    color: var(--active-text);
}

.card-info .time {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
}

.time-card.active .card-info .time {
    color: var(--active-text);
}

/* Date Display */
.date-display {
    padding: 15px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    justify-content: center;
}

@media(min-width: 500px) {
    .date-display {
        flex-direction: row;
        gap: 15px;
    }
}

.date-display i {
    margin-right: 5px;
}

.hijri {
    font-style: italic;
    opacity: 0.8;
}

/* Loading */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    gap: 15px;
    color: var(--primary-green);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--light-green);
    border-top: 4px solid var(--primary-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.hidden {
    display: none !important;
}

/* Footer */
footer {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.8;
    margin-top: auto;
    padding-bottom: 10px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Spiritual Quote Bar */
.quote-container {
    margin-top: auto;
    padding: 15px 25px;
    /* Reduced vertical padding */
    text-align: center;
    position: relative;
    max-width: 600px;
    /* Reduced max-width for compact look */
    width: 90%;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    /* Reduced gap */
    animation: fadeIn 1s ease-out;
    border-radius: 16px;
    /* Slightly rounder */
}

.quote-icon {
    color: var(--primary-green);
    font-size: 0.9rem;
    /* Smaller icon */
    opacity: 0.6;
}

body.bg-night .quote-icon {
    color: var(--accent-gold);
}

.quote-text {
    font-family: 'Amiri', serif;
    /* Elegant font for quotes */
    font-size: 1.2rem;
    /* Increased from 0.95rem */
    font-weight: 700;
    /* Bold for clearer visibility */
    font-style: italic;
    /* Keep italic styling */
    color: var(--text-main);
    line-height: 1.5;
    max-width: 100%;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    /* Subtle shadow for pop */
    letter-spacing: 0.5px;
    /* Slightly wider for readability */
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Qibla Finder Styles */
.qibla-section {
    padding: 25px;
    margin-top: 20px;
    text-align: center;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.qibla-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    color: var(--primary-green);
}

body.bg-night .qibla-header {
    color: var(--accent-gold);
}

.qibla-start-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.primary-btn {
    background-color: var(--primary-green);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.primary-btn:hover {
    transform: translateY(-2px);
    background-color: var(--dark-green);
}

.perm-note {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Compass UI */
.qibla-compass-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.compass-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 10px 0;
}

.compass-ring {
    width: 100%;
    height: 100%;
    border: 4px solid var(--text-secondary);
    border-radius: 50%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.5s ease-out;
}

.direction {
    position: absolute;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.direction.n {
    top: 10px;
    color: #E53935;
    /* Red for North */
}

.direction.e {
    right: 15px;
}

.direction.s {
    bottom: 10px;
}

.direction.w {
    left: 15px;
}

.qibla-pointer {
    position: absolute;
    width: 4px;
    height: 50%;
    background: transparent;
    top: 0;
    left: 50%;
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(0deg);
    /* Will be rotated by JS */
    transition: transform 1s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding-top: 10px;
}

.qibla-pointer .fa-arrow-up {
    color: var(--primary-green);
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

body.bg-night .qibla-pointer .fa-arrow-up {
    color: var(--accent-gold);
}

.kaaba-icon {
    margin-top: 5px;
    font-size: 1rem;
    color: var(--text-main);
}

.qibla-info {
    text-align: center;
}

.qibla-info p {
    font-size: 1.1rem;
    font-weight: 500;
}

.compass-status {
    font-size: 0.85rem !important;
    opacity: 0.8;
    margin-top: 5px;
}