:root {
    --primary: #5c6ac4;
    --primary-light: #7a88e5;
    --secondary: #2b3356;
    --accent: #fbc02d;
    --text-main: #ffffff;
    --text-muted: #e2e8f0;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);

    --bg-gradient-1: #1a1e36;
    --bg-gradient-2: #2b3356;
    --bg-gradient-3: #4a2754;

    --skeleton-base: rgba(255, 255, 255, 0.05);
    --skeleton-highlight: rgba(255, 255, 255, 0.1);
}

body.theme-light {
    --primary: #4a5c96;
    --primary-light: #6a7cbb;
    --secondary: #e8eaf6;
    --accent: #f57f17;
    --text-main: #2c3e50;
    --text-muted: #546e7a;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);

    --bg-gradient-1: #e3f2fd;
    --bg-gradient-2: #bbdefb;
    --bg-gradient-3: #ffecb3;

    --skeleton-base: rgba(0, 0, 0, 0.05);
    --skeleton-highlight: rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazirmatn', sans-serif;
}

body {
    background: linear-gradient(-45deg, var(--bg-gradient-1), var(--bg-gradient-2), var(--bg-gradient-3), var(--primary));
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
    overflow-x: hidden;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.background-animation::before,
.background-animation::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 10s infinite ease-in-out alternate;
}

.background-animation::before {
    top: 10%;
    left: 20%;
    background: rgba(92, 106, 196, 0.6);
}

.background-animation::after {
    bottom: 10%;
    right: 20%;
    background: rgba(156, 39, 176, 0.5);
    animation-delay: -5s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, 50px) scale(1.2);
    }
}

.container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header Styles */
header {
    text-align: center;
    position: relative;
}

.header-controls {
    position: absolute;
    top: 0;
    left: 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

:root[dir="ltr"] .header-controls {
    left: auto;
    right: 1rem;
}

.lang-select {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.3rem 0.5rem;
    border-radius: 20px;
    outline: none;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.lang-select option {
    background: var(--bg-gradient-2);
    color: white;
}

.theme-light .lang-select option {
    background: white;
    color: var(--text-main);
}

.settings-toggle {
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s, transform 0.3s;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-toggle:hover {
    color: var(--accent);
    transform: rotate(30deg);
}

.header-logo {
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 0 10px rgba(251, 192, 45, 0.5));
    transition: transform 0.3s ease;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.2rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* Search Section */
.search-section {
    position: relative;
    z-index: 10;
    animation: slideUp 0.8s ease-out;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 0.5rem 1rem;
    position: relative;
    z-index: 50;
    /* Ensure dropdowns overlay subsequent elements */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}

.search-box:focus-within {
    box-shadow: 0 8px 32px rgba(92, 106, 196, 0.3);
    border-color: var(--primary-light);
}

.country-input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1.1rem;
    outline: none;
    padding: 0.8rem;
    width: 130px;
    z-index: 100;
}

.country-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.country-autocomplete-items {
    top: 100%;
    left: 0;
    width: 250px;
}

.search-divider {
    width: 1px;
    height: 30px;
    background-color: var(--glass-border);
    margin: 0 0.8rem;
}

.search-icon {
    font-size: 1.4rem;
    color: var(--text-muted);
}

.country-icon {
    margin-left: 0.2rem;
}

:root[dir="ltr"] .country-icon {
    margin-left: 0;
    margin-right: 0.2rem;
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.1rem;
    padding: 0.8rem;
    outline: none;
    font-family: 'Inter', 'Vazirmatn', sans-serif;
    min-width: 0;
    /* Prevents input from overflowing flex container */
}

.search-box input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.icon-button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    margin: 0 1rem;
    cursor: pointer;
    transition: color 0.3s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button:hover {
    color: var(--accent);
    transform: scale(1.1);
}

/* Favorites Section */
.favorites-container {
    position: relative;
    z-index: 1;
    margin-top: 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: fadeIn 0.5s ease-out;
}

.favorites-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.favorites-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.favorite-chip {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.3s, transform 0.2s;
}

.theme-light .favorite-chip {
    background: rgba(0, 0, 0, 0.05);
}

.favorite-chip:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.favorite-chip ion-icon {
    color: var(--accent);
}

/* Autocomplete list */
.autocomplete-items {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: rgba(30, 36, 60, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-top: 8px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: none;
}

.autocomplete-item {
    padding: 1rem 1.5rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.autocomplete-item ion-icon {
    color: var(--accent);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.hidden {
    display: none !important;
}

/* Result Section */
.result-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    animation: fadeIn 0.8s ease-out forwards;
}

/* Daily Banner */
.daily-banner {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem 1.5rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--glass-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.95rem;
}

.daily-banner-dates {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.banner-label,
.banner-divider,
.banner-comma {
    color: var(--text-muted);
    font-size: 0.9rem;
    opacity: 0.8;
}

.banner-shamsi,
.banner-qamari,
.banner-gregorian {
    color: var(--accent);
    font-weight: 600;
}

.dua-btn {
    display: flex;
    align-items: center;
    flex-direction: row;
    gap: 0.4rem;
    color: var(--primary-light);
    font-weight: 500;
    transition: all 0.3s;
    background: rgba(92, 106, 196, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    border: 1px solid rgba(92, 106, 196, 0.2);
    font-size: 0.95rem;
    margin: 0;
}

.dua-btn:hover {
    color: var(--accent);
    background: rgba(92, 106, 196, 0.2);
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* Dua Modal */
.dua-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    animation: fadeIn 0.3s ease-out;
}

.dua-modal.hidden {
    display: none !important;
}

.dua-modal-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.dua-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.dua-modal-header h2 {
    color: var(--accent);
    font-size: 1.4rem;
    margin: 0;
}

.dua-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    line-height: 2.2;
    text-align: justify;
}

.dua-arabic-text {
    font-size: 1.4rem;
    color: var(--text-main);
    font-family: inherit;
    font-weight: 500;
}

.location-info {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#cityNameDisplay {
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.fav-btn {
    font-size: 1.5rem;
    margin: 0;
}

.fav-btn.active {
    color: #e91e63;
}

.countdown-card {
    background: linear-gradient(135deg, rgba(92, 106, 196, 0.6), rgba(43, 51, 86, 0.8));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.theme-light .countdown-card {
    background: linear-gradient(135deg, rgba(92, 106, 196, 0.8), rgba(122, 136, 229, 0.9));
    color: white;
    /* Ensure text visible on dark card in light mode */
}

.countdown-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.highlight-text {
    color: var(--accent);
    font-weight: 800;
}

.timer {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: 'Inter', 'Vazirmatn', sans-serif;
    letter-spacing: 2px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.date-info {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.date-info p {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.date-info ion-icon {
    color: var(--primary-light);
}

/* Grid Layout */
.prayer-times-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.prayer-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    text-align: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s;
    opacity: 1;
    transform: translateY(0);
    animation: staggerFadeIn 0.6s ease-out backwards;
    animation-delay: calc(var(--animation-order) * 0.1s);
    position: relative;
    overflow: hidden;
}

@keyframes staggerFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
}

.prayer-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transition: left 0.5s ease;
}

.prayer-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    background: rgba(255, 255, 255, 0.15);
}

.prayer-card:hover::before {
    left: 100%;
}

.prayer-card.highlight {
    background: rgba(92, 106, 196, 0.4);
    border-color: rgba(92, 106, 196, 0.6);
}

.prayer-card.highlight:hover {
    background: rgba(92, 106, 196, 0.5);
}

.card-icon {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
    transition: transform 0.3s ease;
}

.prayer-card:hover .card-icon {
    transform: scale(1.1);
}

.prayer-card h3 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.prayer-card .time {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: 'Inter', 'Vazirmatn', sans-serif;
    letter-spacing: 1px;
}

/* Map Card Specific Styles */
.map-card {
    padding: 0;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden !important;
}

.map-card:hover {
    transform: none;
    /* Disable scale/float effect on map */
    box-shadow: var(--glass-shadow);
}

.map-card::before {
    display: none;
    /* Disable the shine sweep on the map */
}

.map-container {
    width: 100%;
    height: 100%;
    min-height: 200px;
    border-radius: 20px;
    z-index: 1;
    /* Keep map below the modal but above the card background */
}

/* Skeleton Loading Animation */
.skeleton {
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            var(--skeleton-base) 0%,
            var(--skeleton-highlight) 50%,
            var(--skeleton-base) 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite linear;
}

.skeleton h3,
.skeleton .time,
.skeleton .card-icon {
    visibility: hidden;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.active-prayer-pulse {
    animation: activePulse 2s infinite;
    border-color: var(--accent) !important;
}

@keyframes activePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(251, 192, 45, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(251, 192, 45, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(251, 192, 45, 0);
    }
}

/* Footer */
footer {
    text-align: center;
    margin-top: 2rem;
    padding-bottom: 1rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
}

footer a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color 0.3s;
}

footer a:hover {
    color: var(--accent);
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Responsive */
@media (max-width: 600px) {
    .prayer-times-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    h1 {
        font-size: 2rem;
    }

    .prayer-card .time {
        font-size: 1.5rem;
    }
}

@media (max-width: 400px) {
    .prayer-times-grid {
        grid-template-columns: 1fr;
    }
}