/* Ramadan Sehri & Iftar Times - Styles */
/* Islamic color scheme: Greens, golds, and neutral tones */

:root {
    --primary-color: #2E8B57; /* Sea Green */
    --secondary-color: #FFD700; /* Gold */
    --accent-color: #8B4513; /* Saddle Brown */
    --text-primary: #2C3E50; /* Dark Slate Gray */
    --text-secondary: #7F8C8D; /* Asbestos */
    --background-primary: #ECF0F1; /* Clouds */
    --background-secondary: #FFFFFF; /* White */
    --background-card: #F8F9FA; /* Very Light Gray */
    --border-color: #E9ECEF; /* Light Gray */
    --success-color: #27AE60; /* Nephritis */
    --warning-color: #F39C12; /* Orange */
    --error-color: #E74C3C; /* Alizarin */
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--background-primary) 0%, #D5DBDB 100%);
    min-height: 100vh;
    overflow-x: hidden; /* Prevent horizontal scrolling */
    width: 100%;
    max-width: 100vw; /* Ensure body never exceeds viewport */
    box-sizing: border-box;
}

/* Global text wrapping and overflow prevention */
* {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    box-sizing: border-box;
}

h1, h2, h3, h4, h5, h6 {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

p, span, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Prevent horizontal overflow on all elements */
* {
    max-width: 100%;
}

/* Ensure images and media don't cause overflow */
img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.header-content {
    background: var(--background-secondary);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 2px solid var(--primary-color);
}

.title {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.title i {
    color: var(--secondary-color);
}

.subtitle {
    font-size: 1.2rem;
    color: #000000;
    font-weight: 700;
}

/* Country Selector */
.country-selector {
    margin-bottom: 30px;
}

.selector-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--background-secondary);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    box-sizing: border-box;
    width: 100%;
}

.selector-label {
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.country-dropdown {
    flex: 1 1 0;
    min-width: 0;          /* allow it to shrink below 200px */
    width: 0;              /* force flex to control width */
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--background-secondary);
    cursor: pointer;
    transition: var(--transition);
    box-sizing: border-box;
    max-width: 100%;
}

.country-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(46, 139, 87, 0.1);
}

.refresh-btn {
    padding: 12px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
}

.refresh-btn:hover {
    background: #228B22;
    transform: scale(1.05);
}

.refresh-btn:active {
    transform: scale(0.95);
}

/* Date Info */
.date-info {
    margin-bottom: 30px;
}

.date-card {
    background: var(--background-secondary);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.date-display {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.current-date {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.hijri-date {
    font-size: 1rem;
    color: #000000;
    font-style: italic;
}

.ramadan-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 25px;
    font-weight: 600;
}

.ramadan-status i {
    font-size: 1.2rem;
}

.calendar-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: white;
    font-size: 1.2rem;
    padding: 4px 7px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    line-height: 1;
    transition: background 0.2s;
    flex-shrink: 0;
}
.calendar-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* Calculation method indicator */
.method-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    /* Force onto its own row in the date-card flex container */
    flex-basis: 100%;
    width: 100%;
}

.method-info i {
    font-size: 0.85rem;
    color: var(--secondary-color);
    flex-shrink: 0;
}

.method-label {
    font-size: 0.78rem;
    color: #000000;
    font-style: italic;
    line-height: 1.3;
    word-break: break-word;
}

/* Viewing-other-date banner */
.viewing-other-date {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: linear-gradient(45deg, #7B3F00, #C8860A);
    color: white;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.88rem;
    font-weight: 500;
    flex-wrap: wrap;
    box-shadow: 0 3px 12px rgba(0,0,0,0.15);
}
.viewing-other-date.hidden { display: none; }
.viewing-other-date > i { font-size: 1rem; flex-shrink: 0; }
.back-to-today-btn {
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 5px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
    margin-left: auto;
    white-space: nowrap;
}
.back-to-today-btn:hover { background: rgba(255, 255, 255, 0.32); }

/* ── Sehri & Iftar Hero Highlight ─────────────────────────────────────── */
.fasting-highlight {
    display: flex;
    gap: 18px;
    margin-bottom: 28px;
}

.highlight-card {
    flex: 1;
    border-radius: 18px;
    padding: 28px 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.16);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.highlight-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.22);
}

.sehri-highlight {
    background: linear-gradient(135deg, #E67E22 0%, #F5B041 100%);
    color: #111;
    border: 2px solid rgba(255, 255, 255, 0.18);
}

.iftar-highlight {
    background: linear-gradient(135deg, #1A6B3C 0%, #27AE60 100%);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.18);
}

.highlight-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
}

.highlight-content {
    text-align: left;
    flex: 1;
    min-width: 0;
}

.highlight-label {
    font-size: 0.82rem;
    font-weight: 700;
    opacity: 0.88;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 6px;
}

.highlight-time {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 5px;
    letter-spacing: -0.01em;
}

.highlight-countdown {
    font-size: 1.15rem;
    font-weight: 600;
    opacity: 0.85;
    font-family: 'Courier New', Courier, monospace;
    margin-bottom: 5px;
    letter-spacing: 0.03em;
}

.highlight-sub {
    font-size: 0.76rem;
    opacity: 0.72;
    font-style: italic;
}

/* Responsive: stack on mobile */
@media (max-width: 600px) {
    .fasting-highlight {
        flex-direction: column;
        gap: 12px;
    }
    .highlight-time {
        font-size: 2rem;
    }
    .highlight-card {
        padding: 22px 18px;
    }
}

@media (max-width: 320px) {
    .fasting-highlight {
        gap: 10px;
    }
    .highlight-card {
        flex-direction: column;
        text-align: center;
        padding: 18px 14px;
        gap: 12px;
    }
    .highlight-content {
        text-align: center;
    }
    .highlight-time {
        font-size: 1.7rem;
    }
    .highlight-countdown {
        font-size: 1rem;
    }
}

/* Prayer Times */
.prayer-times {
    margin-bottom: 30px;
}

.section-title {
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: center;
    justify-content: center;
}

.times-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 18px;
    margin: 0 auto;
    max-width: 1200px;
    width: 100%;
    box-sizing: border-box;
}

/* Ensure grid adapts to very small screens */
@media (max-width: 320px) {
    .times-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.time-card {
    background: var(--background-secondary);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.time-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.time-card.sehri-card {
    border-color: var(--warning-color);
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.1), var(--background-secondary));
}

.time-card.iftar-card {
    border-color: var(--success-color);
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.1), var(--background-secondary));
}

.time-card.fajr-card,
.time-card.dhuhr-card,
.time-card.asr-card,
.time-card.isha-card {
    border-color: var(--primary-color);
}

.time-card.sunrise-card,
.time-card.sunset-card {
    border-color: var(--secondary-color);
}

.time-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 15px;
    position: relative;
}

.sehri-card .time-icon {
    background: linear-gradient(45deg, var(--warning-color), #F4D03F);
    color: white;
}

.iftar-card .time-icon {
    background: linear-gradient(45deg, var(--success-color), #58D68D);
    color: white;
}

.fajr-card .time-icon,
.dhuhr-card .time-icon,
.asr-card .time-icon,
.isha-card .time-icon {
    background: linear-gradient(45deg, var(--primary-color), #3CB371);
    color: white;
}

.sunrise-card .time-icon,
.sunset-card .time-icon {
    background: linear-gradient(45deg, var(--secondary-color), #FFA500);
    color: #8B4513;
}

.time-content {
    text-align: center;
}

.time-name {
    font-size: 1.1rem;
    color: #000000;
    margin-bottom: 10px;
    font-weight: 700;
}

.time-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
}

.countdown {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Additional Info */
.additional-info {
    margin-bottom: 30px;
}

.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.info-card {
    background: var(--background-secondary);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
}

.info-card h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-card ul {
    list-style: none;
    padding: 0;
}

.info-card li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    color: #000000;
}

.info-card li:last-child {
    border-bottom: none;
}

.info-card li:before {
    content: "✓";
    color: var(--success-color);
    font-weight: bold;
    margin-right: 10px;
}

/* Zakat CTA Section */
.zakat-cta {
    text-align: center;
    margin: 30px 0 10px;
    padding: 30px 24px;
    background: var(--background-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border-top: 3px solid var(--primary-color);
}

.zakat-cta-heading {
    font-size: 1.4rem;
    font-weight: 700;
    color: #000000;
    margin: 0 0 8px;
}

.zakat-cta-sub {
    font-size: 1rem;
    color: #000000;
    margin: 0 0 20px;
}

.zakat-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-color);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 600;
    padding: 12px 28px;
    border-radius: 8px;
    text-decoration: none;
    transition: var(--transition);
    border: 2px solid transparent;
}

.zakat-cta-btn:hover {
    background: transparent;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Dark mode overrides for Zakat CTA */
@media (prefers-color-scheme: dark) {
    .zakat-cta-heading,
    .zakat-cta-sub {
        color: #ffffff;
    }
}

/* Responsive: small screens */
@media (max-width: 600px) {
    .zakat-cta {
        padding: 22px 16px;
    }
    .zakat-cta-heading {
        font-size: 1.15rem;
    }
    .zakat-cta-sub {
        font-size: 0.95rem;
    }
    .zakat-cta-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
    }
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.footer-content p {
    color: #000000;
    margin: 5px 0;
}

.footer-content a {
    color: var(--primary-color);
    text-decoration: none;
}

.footer-content a:hover {
    text-decoration: underline;
}

/* ── Date Picker Calendar Modal ───────────────────────────────────────────────── */
.calendar-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    box-sizing: border-box;
}
.calendar-modal.hidden { display: none; }

.calendar-popup {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
    padding: 22px 20px;
    width: 320px;
    max-width: 100%;
    animation: calPop 0.18s ease;
}
@keyframes calPop {
    from { transform: scale(0.88); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.cal-header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 14px;
}
.cal-month-year {
    flex: 1;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-color);
}
.cal-nav {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary-color);
    font-size: 0.95rem;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.cal-nav:hover { background: rgba(46, 139, 87, 0.12); }
.cal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1rem;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    margin-left: 4px;
}
.cal-close:hover { background: rgba(0, 0, 0, 0.08); }

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 6px;
}
.cal-weekdays span {
    text-align: center;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 3px 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.cal-day {
    background: none;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 0.87rem;
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: auto;
}
.cal-day:hover:not(.cal-empty) {
    background: rgba(46, 139, 87, 0.13);
    color: var(--primary-color);
}
.cal-day.cal-empty {
    cursor: default;
    pointer-events: none;
}
.cal-day.cal-today {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    font-weight: 700;
}
.cal-day.cal-selected {
    background: var(--primary-color) !important;
    color: white !important;
    font-weight: 700;
}
.cal-day.cal-today.cal-selected {
    background: var(--primary-color) !important;
    border-color: transparent;
}

/* Past dates — dimmed and non-interactive */
.cal-day.cal-past {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.cal-footer {
    display: flex;
    justify-content: center;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
.cal-today-btn {
    background: linear-gradient(45deg, var(--primary-color), #3CB371);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 7px 20px;
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: opacity 0.2s;
}
.cal-today-btn:hover { opacity: 0.88; }

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    text-align: center;
    color: var(--primary-color);
}

.loading-spinner i {
    font-size: 3rem;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Error Message — full-screen overlay with centered card */
.error-message {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    padding: 16px;
    box-sizing: border-box;
}

.error-message.hidden {
    display: none;
}

.error-content {
    background: var(--background-secondary);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.error-content i {
    font-size: 3rem;
    color: var(--error-color);
    margin-bottom: 15px;
}

.error-content h3 {
    color: var(--error-color);
    margin-bottom: 10px;
}

.error-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.retry-btn {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.retry-btn:hover {
    background: #228B22;
}

/* Responsive Design - Comprehensive Coverage */

/* Extra Large Screens (1441px and up) — container stays 900px for clean side spacing */
@media (min-width: 1441px) {
    .title {
        font-size: 3rem;
    }

    .times-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 25px;
    }

    .time-card {
        padding: 30px;
    }

    .time-value {
        font-size: 2.5rem;
    }

    .time-icon {
        width: 70px;
        height: 70px;
        font-size: 1.8rem;
    }
}

/* Large Screens (1025px - 1440px) — container stays 900px for clean side spacing */
@media (min-width: 1025px) and (max-width: 1440px) {
    .title {
        font-size: 2.8rem;
    }

    .times-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px;
    }

    .time-card {
        padding: 28px;
    }

    .time-value {
        font-size: 2.2rem;
    }

    .time-icon {
        width: 65px;
        height: 65px;
        font-size: 1.6rem;
    }
}

/* Medium Screens (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .title {
        font-size: 2.4rem;
    }

    .times-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 18px;
    }

    .time-card {
        padding: 25px;
    }

    .time-value {
        font-size: 2rem;
    }

    .time-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .date-card {
        padding: 20px;
    }
}

/* Small Screens (601px - 768px) */
@media (min-width: 601px) and (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .title {
        font-size: 2rem;
        flex-direction: column;
        gap: 10px;
    }

    .header-content {
        padding: 25px;
    }

    .selector-wrapper {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
        gap: 10px;
    }

    .selector-label {
        white-space: normal;
    }

    .country-dropdown {
        flex: none;
        width: 100%;
        min-width: 0;
        font-size: 1rem;
        box-sizing: border-box;
    }

    .refresh-btn {
        width: 100%;
        justify-content: center;
    }

    .date-card {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }

    .times-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px;
    }

    .time-card {
        padding: 20px;
    }

    .time-value {
        font-size: 1.8rem;
    }

    .time-icon {
        width: 55px;
        height: 55px;
        font-size: 1.4rem;
    }

    .info-cards {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .info-card {
        padding: 20px;
    }
}

/* Extra Small Screens (320px - 600px) */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    .title {
        font-size: 1.5rem;
        text-align: center;
    }

    .header-content {
        padding: 20px 15px;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    .selector-wrapper {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        gap: 10px;
    }

    .selector-label {
        font-size: 0.95rem;
        white-space: normal;
    }

    .country-dropdown {
        flex: none;
        width: 100%;
        min-width: 0;
        padding: 10px 12px;
        font-size: 0.95rem;
        box-sizing: border-box;
    }

    .refresh-btn {
        width: 100%;
        padding: 10px 12px;
        font-size: 0.95rem;
        justify-content: center;
    }

    .date-card {
        padding: 18px;
        margin-bottom: 25px;
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .current-date {
        font-size: 1.3rem;
    }

    .hijri-date {
        font-size: 0.9rem;
    }

    .date-display {
        align-items: center;
        width: 100%;
        order: -1;
    }
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .section-title {
        font-size: 1.6rem;
    }

    .times-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .time-card {
        padding: 18px;
        border-radius: 10px;
    }

    .time-name {
        font-size: 1rem;
    }

    .time-value {
        font-size: 1.6rem;
    }

    .countdown {
        font-size: 0.85rem;
    }

    .time-icon {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }

    .additional-info {
        margin-bottom: 25px;
    }

    .info-cards {
        gap: 12px;
    }

    .info-card {
        padding: 18px;
    }

    .info-card h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    .footer {
        padding-top: 15px;
    }

    .footer-content p {
        font-size: 0.9rem;
    }

    /* Calendar Modal Mobile Styles */
    .calendar-modal {
        padding: 8px;
    }

    .calendar-popup {
        width: 100%;
        max-width: 100%;
        padding: 16px 12px;
    }

    .cal-header {
        gap: 2px;
        margin-bottom: 10px;
    }

    .cal-month-year {
        font-size: 0.95rem;
    }

    .cal-nav {
        width: 30px;
        height: 30px;
    }

    .cal-close {
        width: 30px;
        height: 30px;
        margin-left: 2px;
    }

    .cal-weekdays span {
        font-size: 0.6rem;
        padding: 2px 0;
    }

    .cal-days {
        gap: 1px;
    }

    .cal-day {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    .cal-footer {
        margin-top: 10px;
    }

    .cal-today-btn {
        font-size: 0.85rem;
        padding: 8px 12px;
    }
}

/* Ultra Small Screens (320px and below) */
@media (max-width: 320px) {
    .container {
        padding: 5px;
        max-width: 100%;
    }

    .title {
        font-size: 1.4rem;
        margin-bottom: 8px;
    }

    .header-content {
        padding: 15px 10px;
        margin-bottom: 15px;
    }

    .subtitle {
        font-size: 1rem;
        margin-bottom: 0;
    }

    .selector-wrapper {
        padding: 10px;
        gap: 8px;
        margin-bottom: 15px;
        flex-direction: column;
        align-items: stretch;
    }

    .selector-label {
        font-size: 0.85rem;
        margin-bottom: 2px;
        white-space: normal;
    }

    .country-dropdown {
        padding: 8px 10px;
        font-size: 0.85rem;
        min-height: 36px;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .refresh-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
        width: 100%;
        min-height: 36px;
        justify-content: center;
    }

    .date-card {
        padding: 12px;
        margin-bottom: 15px;
        flex-direction: column;
        gap: 8px;
    }

    .current-date {
        font-size: 1.1rem;
        line-height: 1.2;
    }

    .hijri-date {
        font-size: 0.8rem;
        line-height: 1.2;
    }

    .ramadan-status {
        padding: 6px 12px;
        font-size: 0.8rem;
        border-radius: 15px;
    }

    .section-title {
        font-size: 1.4rem;
        margin-bottom: 15px;
    }

    .times-grid {
        grid-template-columns: 1fr;
        gap: 8px;
        margin: 0;
    }

    .time-card {
        padding: 12px;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    .time-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
        margin-bottom: 8px;
    }

    .time-name {
        font-size: 0.9rem;
        margin-bottom: 4px;
        line-height: 1.2;
    }

    .time-value {
        font-size: 1.4rem;
        margin-bottom: 2px;
        line-height: 1.2;
    }

    .countdown {
        font-size: 0.75rem;
        line-height: 1.2;
    }

    .additional-info {
        margin-bottom: 20px;
    }

    .info-cards {
        gap: 8px;
    }

    .info-card {
        padding: 12px;
        border-radius: 8px;
    }

    .info-card h3 {
        font-size: 1rem;
        margin-bottom: 8px;
    }

    .info-card ul {
        margin: 0;
        padding-left: 15px;
    }

    .info-card li {
        font-size: 0.85rem;
        margin-bottom: 4px;
        line-height: 1.3;
    }

    .footer {
        padding-top: 10px;
        margin-top: 15px;
    }

    .footer-content p {
        font-size: 0.8rem;
        line-height: 1.3;
    }

    /* Calendar Modal Ultra-Small Mobile Styles */
    .calendar-modal {
        padding: 4px;
    }

    .calendar-popup {
        padding: 12px 8px;
    }

    .cal-header {
        gap: 1px;
        margin-bottom: 8px;
    }

    .cal-month-year {
        font-size: 0.9rem;
    }

    .cal-nav {
        width: 28px;
        height: 28px;
    }

    .cal-close {
        width: 28px;
        height: 28px;
        margin-left: 1px;
    }

    .cal-weekdays span {
        font-size: 0.55rem;
        padding: 1px 0;
    }

    .cal-days {
        gap: 1px;
    }

    .cal-day {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .cal-footer {
        margin-top: 8px;
    }

    .cal-today-btn {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
}

/* Micro Screens (280px and below) - For very old/small devices */
@media (max-width: 280px) {
    .container {
        padding: 3px;
        max-width: 100vw; /* Ensure container never exceeds viewport */
        overflow-x: hidden;
    }

    .title {
        font-size: 1.2rem;
    }

    .header-content {
        padding: 10px 8px;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .selector-wrapper {
        padding: 8px;
        gap: 6px;
        flex-direction: column;
        align-items: stretch;
    }

    .selector-label {
        font-size: 0.8rem;
        white-space: normal;
    }

    .country-dropdown {
        padding: 6px 8px;
        font-size: 0.8rem;
        min-height: 32px;
        width: 100%; /* Ensure full width */
        max-width: 100%; /* Prevent overflow */
        box-sizing: border-box;
        min-width: auto !important; /* Override default min-width */
    }

    .refresh-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
        min-width: 32px;
        min-height: 32px;
        width: 100%;
        justify-content: center;
    }

    .date-card {
        padding: 10px;
    }

    .current-date {
        font-size: 1rem;
    }

    .hijri-date {
        font-size: 0.75rem;
    }

    .ramadan-status {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    .section-title {
        font-size: 1.2rem;
    }

    /* Force single column grid to prevent horizontal overflow */
    .times-grid {
        grid-template-columns: 1fr !important; /* Force single column */
        gap: 6px;
        width: 100%;
        max-width: 100%;
    }

    .time-card {
        padding: 10px;
        width: 100%; /* Ensure full width */
        max-width: 100%; /* Prevent overflow */
        box-sizing: border-box;
    }

    .time-icon {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    .time-name {
        font-size: 0.85rem;
    }

    .time-value {
        font-size: 1.2rem;
    }

    .countdown {
        font-size: 0.7rem;
    }

    .info-card {
        padding: 10px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .info-card h3 {
        font-size: 0.9rem;
    }

    .info-card li {
        font-size: 0.8rem;
    }

    .footer-content p {
        font-size: 0.75rem;
    }

    /* Prevent horizontal overflow and ensure text wrapping */
    .container, .header-content, .selector-wrapper, .date-card,
    .time-card, .info-card, .footer-content {
        overflow-x: hidden;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        max-width: 100%;
        box-sizing: border-box;
    }

    .title, .subtitle, .selector-label, .current-date, .hijri-date,
    .ramadan-status, .section-title, .time-name, .time-value, .countdown {
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
    }

    /* Ensure all form elements are responsive */
    input, select, button, textarea {
        max-width: 100% !important;
        box-sizing: border-box !important;
        min-width: auto !important;
    }

    /* Force single column layout for all grids on micro screens */
    .times-grid, .info-cards, .selector-wrapper {
        display: block !important;
        width: 100% !important;
    }

    .selector-wrapper > * {
        width: 100% !important;
        margin-bottom: 6px !important;
    }

    .info-cards > * {
        width: 100% !important;
        margin-bottom: 6px !important;
    }
}

/* Touch Devices Optimization */
@media (hover: none) and (pointer: coarse) {
    .time-card {
        transition: none;
    }

    .time-card:hover {
        transform: none;
    }

    .highlight-card:hover {
        transform: none;
    }

    .refresh-btn {
        min-height: 44px;
        min-width: 44px;
    }

    .country-dropdown {
        min-height: 44px;
    }

    .cal-day {
        min-width: 36px;
        min-height: 36px;
    }
}

/* Refresh button spinning state */
.refresh-btn .fa-spin {
    animation: spin 0.8s linear infinite;
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .time-icon {
        font-weight: 900;
    }
}

/* Landscape Orientation for Small Screens */
@media (max-height: 500px) and (orientation: landscape) {
    .header-content {
        padding: 15px;
    }

    .title {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }

    .subtitle {
        font-size: 1rem;
    }

    .times-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 10px;
    }

    .time-card {
        padding: 15px;
    }
}

/* Dark Mode Support (future enhancement) */
@media (prefers-color-scheme: dark) {

    /* ── Token overrides ──────────────────────────────────────────────── */
    :root {
        --background-primary:   #1A1F2E;
        --background-secondary: #242B3D;
        --background-card:      #1E2537;
        --text-primary:         #E8EDF5;
        --text-secondary:       #9BA8BE;
        --border-color:         #3A4460;
        --shadow:               0 2px 12px rgba(0,0,0,0.45);
        --shadow-hover:         0 4px 24px rgba(0,0,0,0.6);
    }

    /* ── Body ─────────────────────────────────────────────────────────── */
    body {
        /* override the hardcoded #D5DBDB second stop */
        background: linear-gradient(135deg, #1A1F2E 0%, #12172A 100%);
    }

    /* ── Header ───────────────────────────────────────────────────────── */
    .header-content {
        border-color: var(--primary-color);
    }

    /* ── Country dropdown ─────────────────────────────────────────────── */
    .country-dropdown {
        color: var(--text-primary);
    }
    .country-dropdown option {
        background: var(--background-secondary);
        color: var(--text-primary);
    }

    /* ── Time cards ───────────────────────────────────────────────────── */
    .time-card.sehri-card {
        background: linear-gradient(135deg, rgba(243,156,18,0.18), var(--background-secondary));
    }
    .time-card.iftar-card {
        background: linear-gradient(135deg, rgba(39,174,96,0.18), var(--background-secondary));
    }
    .time-card.fajr-card,
    .time-card.dhuhr-card,
    .time-card.asr-card,
    .time-card.isha-card {
        background: linear-gradient(135deg, rgba(46,139,87,0.15), var(--background-secondary));
    }

    /* ── Calendar popup (hardcoded #fff) ─────────────────────────────── */
    .calendar-popup {
        background: var(--background-secondary);
        color: var(--text-primary);
    }
    .cal-day {
        color: var(--text-primary);
    }
    .cal-close:hover {
        background: rgba(255,255,255,0.10);
    }
    .cal-nav:hover {
        background: rgba(46,139,87,0.18);
    }

    /* ── Loading overlay (hardcoded white) ───────────────────────────── */
    .loading-overlay {
        background: rgba(18, 23, 40, 0.93);
    }
    .loading-spinner span {
        color: var(--text-primary);
    }

    /* ── Footer link ─────────────────────────────────────────────────── */
    .footer-content a {
        color: #5EC98A;
    }

    /* ── Info card list item separator ───────────────────────────────── */
    .info-card li {
        border-bottom-color: var(--border-color);
    }
    .info-card li:before {
        color: var(--primary-color);
    }

    /* ── Dark mode white text for specified elements ────────────────── */
    .title {
        color: white;
    }
    .subtitle {
        color: white;
    }
    .current-date,
    .hijri-date {
        color: white;
    }
    .method-label {
        color: white;
    }
    .time-name {
        color: white;
    }
    .info-card h3 {
        color: white;
    }
    .info-card li {
        color: white;
    }
    .footer-content p {
        color: white;
    }

/* Print Styles */
@media print {
    .refresh-btn,
    .countdown,
    .footer {
        display: none;
    }

    .time-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}