:root {
    --bg-color: #1a3c46;
    /* Matching Primary Teal */
    --bg-gradient: linear-gradient(135deg, #0f4c5c 0%, #1a2c38 100%);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.15);
    /* ... Keep other vars ... */
    --text-primary: #ffffff;
    --text-secondary: #e0e6ed;
    --accent-gold: #fb8b24;
    --accent-teal: #1f7a8c;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);

    --font-main: 'Vazirmatn', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100dvh;
    /* Dynamic viewport height */
    width: 100%;
}

body {
    font-family: var(--font-main);
    background: var(--bg-color);
    /* Base color visible through status bar */
    /* Ensure gradient overlays if needed, but solid color is safer for status bar blend */
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    /* Keep gradient fixed */
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    /* Removed padding: 20px from body to allow full bleed */
    direction: rtl;
}

.app-container {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 20px;

    /* Safe Area Padding - This pushes content below the notch/status bar */
    padding-top: max(20px, env(safe-area-inset-top));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--card-shadow);
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

.location-badge {
    display: flex;
    align-items: center;
    gap: 0;
    /* Tight grouping */
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 2px 2px 10px;
    /* Right padding for text */
    border-radius: 12px;
}

.location-info {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 10px;
    transition: background 0.2s;
}

.location-info:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* Lock Icon in Location Badge */
.location-badge .lock-icon {
    display: flex;
    align-items: center;
    margin-right: 4px;
    color: rgba(255, 255, 255, 0.9);
}

/* Privacy Toggle */
.privacy-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 10px;
    border-radius: 12px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.privacy-toggle input {
    display: none;
}

.privacy-toggle .shield-icon {
    font-size: 1.2rem;
    opacity: 0.3;
    /* Inactive state */
    filter: grayscale(1);
    transition: all 0.3s ease;
}

/* Active State */
.privacy-toggle input:checked+.shield-icon {
    opacity: 1;
    filter: grayscale(0);
    text-shadow: 0 0 10px var(--accent-teal);
}

.privacy-toggle:has(input:checked) {
    border-color: var(--accent-teal);
    background: rgba(42, 157, 143, 0.1);
}

.date-display {
    text-align: center;
}

.date-display h2 {
    font-size: 1.4rem;
    /* Prominent Persian Date */
    font-weight: 700;
    margin-bottom: 4px;
}

.date-subtitles {
    display: flex;
    gap: 8px;
    justify-content: center;
    font-size: 0.8rem;
    opacity: 0.8;
}

.date-subtitles p {
    margin: 0;
}

.divider {
    opacity: 0.5;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    transition: transform 0.2s;
}

.icon-btn:active {
    transform: scale(0.9);
}

/* Main Display */
.main-display {
    text-align: center;
    padding: 30px 20px;
    position: relative;
    border: 1px solid rgba(251, 139, 36, 0.3);
}

.next-prayer-label {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 5px;
}

#next-prayer-name {
    font-size: 2.2rem;
    color: var(--accent-gold);
    margin-bottom: 10px;
    text-shadow: 0 2px 10px rgba(251, 139, 36, 0.3);
}

.countdown {
    font-size: 3rem;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
}

.info-badges {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.info-badge {
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.08);
    padding: 6px 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.info-badge strong {
    color: var(--accent-gold);
}

.compass-icon,
.sun-icon,
.fast-icon {
    font-size: 1rem;
}

/* Prayer Grid */
.prayer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.prayer-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.prayer-card:active {
    transform: scale(0.98);
}

.prayer-card.passed {
    opacity: 0.5;
    filter: grayscale(0.5);
}

.countdown.is-banner {
    font-size: 2.2rem;
    /* Smaller than digits */
    color: var(--accent-gold);
    line-height: 1.2;
    padding: 0 10px;
    animation: pulse-banner 2s infinite;
}

@keyframes pulse-banner {
    0% {
        opacity: 0.8;
    }

    50% {
        opacity: 1;
        text-shadow: 0 0 15px rgba(251, 139, 36, 0.5);
    }

    100% {
        opacity: 0.8;
    }
}

.prayer-card.active {
    background: rgba(251, 139, 36, 0.15);
    border: 1px solid rgba(251, 139, 36, 0.5);
    transform: translateY(-2px);
}

.prayer-card.next {
    border: 1px dashed var(--accent-gold);
}

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

.prayer-info {
    display: flex;
    flex-direction: column;
}

.prayer-info .label {
    font-size: 0.8rem;
    opacity: 0.7;
}

.prayer-info .time {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Events */
.events-section {
    margin-top: 10px;
}

.event-block {
    margin-bottom: 15px;
}

.event-block h3 {
    font-size: 0.95rem;
    margin-bottom: 8px;
    color: var(--accent-gold);
    opacity: 0.9;
}

.event-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 10px 0;
}

.events-list {
    list-style: none;
    font-size: 0.9rem;
    line-height: 1.5;
}

.events-list li {
    margin-bottom: 6px;
    position: relative;
    padding-right: 12px;
}

.events-list li::before {
    content: "•";
    color: var(--accent-teal);
    position: absolute;
    right: 0;
}

.no-event {
    opacity: 0.5;
    font-style: italic;
    font-size: 0.85rem;
}

/* Lock Icon specific */
.lock-icon {
    font-size: 0.9rem;
    margin-right: 5px;
    color: var(--accent-teal);
}

/* Footer */
footer {
    text-align: center;
    font-size: 0.75rem;
    opacity: 0.5;
    margin-top: 20px;
    margin-bottom: 20px;
    /* Increased margin */
}

.footer-tools {
    display: none;
}

.simple-lang-toggle {
    font-family: var(--font-main);
    /* Ensure Vazirmatn or system font */
    font-size: 0.9rem;
    opacity: 0.5;
    cursor: pointer;
    margin-bottom: 20px;
    transition: opacity 0.3s;
    direction: ltr;
    /* Always EN / FA */
    letter-spacing: 1px;
}

.simple-lang-toggle:hover {
    opacity: 1;
}

.simple-lang-toggle span {
    padding: 0 4px;
}

.simple-lang-toggle span.active {
    font-weight: bold;
    color: var(--accent-gold);
    border-bottom: 1px solid var(--accent-gold);
}

.tiny {
    font-size: 0.65rem;
    margin-top: 4px;
}

.hidden {
    display: none !important;
}

/* Event Badges */
.event-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    margin-left: 8px;
    /* Space between badge and text */
    vertical-align: middle;
    font-weight: bold;
}

.event-badge.celebration {
    background: rgba(16, 185, 129, 0.2);
    /* Emerald 500 */
    color: #34d399;
    /* Emerald 400 */
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.event-badge.mourning {
    background: rgba(239, 68, 68, 0.2);
    /* Red 500 */
    color: #fca5a5;
    /* Red 300 */
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.event-badge.spiritual {
    background: rgba(59, 130, 246, 0.2);
    /* Blue 500 */
    color: #93c5fd;
    /* Blue 300 */
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.event-badge.solemn {
    background: rgba(107, 114, 128, 0.3);
    /* Gray 500 */
    color: #d1d5db;
    /* Gray 300 */
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.event-badge.honor {
    background: rgba(139, 92, 246, 0.2);
    /* Violet 500 */
    color: #c4b5fd;
    /* Violet 300 */
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.event-badge.lesson {
    background: rgba(245, 158, 11, 0.2);
    /* Amber 500 */
    color: #fcd34d;
    /* Amber 300 */
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.event-badge.default {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

/* Mobile Tweaks */
@media (max-width: 380px) {
    .countdown {
        font-size: 2.5rem;
    }

    .prayer-grid {
        grid-template-columns: 1fr;
        /* Stack on very small screens */
    }
}

/* New Elements Styling (Refresh & Search Button) */
.refresh-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    margin-right: 8px;
    /* Space from location name */
    opacity: 0.7;
    transition: all 0.3s ease;
}

.refresh-btn:hover {
    opacity: 1;
    transform: rotate(180deg);
}

.icon-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.icon-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--accent-gold);
}

/* Search Modal Input Group Harmonization */
.input-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    margin-bottom: 10px;
}

.input-group input {
    flex: 1;
    padding: 12px 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-teal);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 10px rgba(31, 122, 140, 0.3);
}

.input-group button#search-btn {
    padding: 0 20px;
    border-radius: 12px;
    border: none;
    background: var(--accent-teal);
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.input-group button#search-btn:hover {
    background: #186372;
    transform: translateY(-2px);
}

.modal-content {
    background: rgba(20, 30, 40, 0.85);
    /* Darker specific bg for modal readability */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Modal Overlay */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal h3 {
    margin-bottom: 10px;
    color: var(--accent-gold);
}

.modal p {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 10px;
}

/* Search Results Dropdown */
.search-results {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    margin-top: 10px;
    overflow: hidden;
    max-height: 200px;
    overflow-y: auto;
}

.search-result-item {
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

.search-result-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item .city-name {
    font-size: 1rem;
    font-weight: 600;
}

.search-result-item .city-detail {
    font-size: 0.8rem;
    opacity: 0.6;
}

/* Error Message */
.error-msg {
    color: #fca5a5;
    font-size: 0.85rem;
    margin-top: 10px;
}

/* Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--accent-gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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