/* Display Layout — shared by display.html and display-simulator.html */
:root {
    --footer-height: 64px;
    --tenant-primary: #c9a84c;  /* Default brand color, overridden by tenant branding */
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: 'Inter', sans-serif; background: #1a472a; color: #fff; }
body { display: flex; flex-direction: row; position: relative; background: linear-gradient(135deg, #1a472a 0%, #0f2e1a 100%); }

/* ========== Display Shell — unified L-shape container ========== */
.display-shell {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, rgba(26, 71, 42, 0.4) 0%, rgba(15, 46, 26, 0.4) 100%);
    backdrop-filter: blur(15px);
    z-index: 100;
    display: grid;
    grid-template-columns: minmax(300px, 20%) 1fr;
    grid-template-rows: 1fr var(--footer-height);
    grid-template-areas:
        "sidebar design"
        "sidebar footer";
    overflow: hidden;
}

/* ========== Sidebar — transparent grid child ========== */
.sidebar {
    --sidebar-font-scale: 1;
    grid-area: sidebar;
    display: flex; flex-direction: column; overflow-y: auto;
    padding: 32px 24px 0;
}
.logo-wrapper {
    margin-top: auto;
    flex-shrink: 0;
    height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: center;
}
.logo { height: 95%; width: auto; object-fit: contain; display: block; }
.clock-section { text-align: center; margin-bottom: 25.6px; padding: 20px; background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px); border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.12); }
.clock-time { font-size: calc(2.5rem * var(--sidebar-font-scale)); font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.clock-date, .hijri-date { font-size: calc(1.235rem * var(--sidebar-font-scale)); color: rgba(255, 255, 255, 0.8); margin-bottom: 4px; }

.clock-section { transition: opacity 0.3s ease; }
.clock-section.fade-out { opacity: 0; }

.clock-section.lang-ar .clock-date,
.clock-section.lang-ar .hijri-date {
    direction: rtl;
    font-family: 'Noto Naskh Arabic', 'Amiri', serif;
}
.clock-section.lang-de .clock-date,
.clock-section.lang-de .hijri-date {
    direction: ltr;
    font-family: 'Inter', 'DM Sans', sans-serif;
}

.next-prayer-section {
    margin-bottom: 25.6px; padding: 16px 20px; background: linear-gradient(135deg, rgba(201, 168, 76, 0.2) 0%, rgba(201, 168, 76, 0.1) 100%);
    backdrop-filter: blur(10px); border-radius: 16px; border: 2px solid rgba(201, 168, 76, 0.3);
    box-shadow: 0 8px 32px rgba(201, 168, 76, 0.15);
    display: flex; align-items: center; justify-content: center; gap: 12px;
    flex-wrap: wrap; overflow: hidden;
    transition: opacity 0.3s ease;
}
.next-prayer-section.fade-out { opacity: 0; }
.next-prayer-name { font-size: calc(1.8rem * var(--sidebar-font-scale)); font-weight: 700; color: var(--tenant-primary); line-height: 1.2; text-align: center; }
.countdown-label { font-size: calc(1.8rem * var(--sidebar-font-scale)); color: rgba(255, 255, 255, 0.7); font-weight: 600; }
.countdown-timer { font-size: calc(1.8rem * var(--sidebar-font-scale)); font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; transition: color 0.3s ease; }
.countdown-timer.urgent { color: var(--tenant-primary); }

.next-prayer-section.lang-ar {
    direction: rtl;
    font-family: 'Noto Naskh Arabic', 'Amiri', serif;
}
.next-prayer-section.lang-de {
    direction: ltr;
    font-family: 'Inter', 'DM Sans', sans-serif;
}

/* ========== Design Area — rounded inset with background ========== */
.main-design {
    grid-area: design;
    position: relative;
    border-radius: 0 0 0 20px;   /* only bottom-left corner rounded */
    overflow: hidden;
    isolation: isolate;           /* force stacking context so border-radius clips transformed children */
}

/* Background container — inside .main-design, inherits rounded corner */
.background-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: inherit;
}

/* Design canvas for background */
#backgroundCanvas {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Design Countdown Progress Bar */
.design-countdown-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: rgba(0, 0, 0, 0.3);
    z-index: 200;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.design-countdown-bar.visible {
    opacity: 1;
}
.design-countdown-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--tenant-primary) 0%, #d4b563 100%);
    width: 100%;
    transition: width 0.5s linear;
    box-shadow: 0 0 10px rgba(201, 168, 76, 0.5);
}
.design-countdown-label {
    position: absolute;
    top: 8px;
    right: 20px;
    background: rgba(26, 71, 42, 0.95);
    backdrop-filter: blur(10px);
    color: white;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    z-index: 201;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}
.design-countdown-label.visible {
    opacity: 1;
}
.countdown-time {
    font-variant-numeric: tabular-nums;
    color: var(--tenant-primary);
}

/* ========== Prayer Footer Bar — transparent grid child ========== */
.prayer-footer {
    --footer-font-scale: 1;
    grid-area: footer;
    display: flex;
    align-items: center;
    overflow: visible;
}

.prayer-footer-content {
    width: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 24px;
    transition: opacity 0.3s ease;
}
.prayer-footer-content.fade-out {
    opacity: 0;
}

.footer-prayer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.footer-prayer-name {
    font-size: calc(0.85rem * var(--footer-font-scale, 1));
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1;
}
.footer-prayer-time {
    font-size: calc(1.1rem * var(--footer-font-scale, 1));
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.footer-prayer.next .footer-prayer-name {
    color: var(--tenant-primary);
}
.footer-prayer.next .footer-prayer-time {
    color: var(--tenant-primary);
}

.footer-prayer.past {
    opacity: 0.5;
}

.prayer-footer-content.lang-ar {
    direction: rtl;
    font-family: 'Noto Naskh Arabic', 'Amiri', serif;
}
.prayer-footer-content.lang-de {
    direction: ltr;
    font-family: 'Inter', 'DM Sans', sans-serif;
}

/* Main content area — inside .main-design */
.main-container {
    position: absolute;
    inset: 0;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    z-index: 50;
}

/* Design container for content card only */
#previewCanvas {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Azan Hero Text */
.azan-hero {
    text-align: center;
    padding: 20px 0 30px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    animation: azanPulse 2s ease-in-out infinite;
}
.azan-hero-arabic {
    font-family: 'Noto Naskh Arabic', 'Amiri', serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--tenant-primary);
    direction: rtl;
    text-align: center;
    line-height: 1.4;
    text-shadow: 0 4px 12px rgba(201, 168, 76, 0.4), 0 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 12px;
}
.azan-hero-german {
    font-family: 'Inter', 'DM Sans', sans-serif;
    font-size: 1.4rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    direction: ltr;
    text-align: center;
    line-height: 1.4;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
@keyframes azanPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.02); }
}

/* Iqama Countdown Hero */
.iqama-countdown-hero {
    text-align: center;
    padding: 20px 0 30px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
.iqama-countdown-arabic {
    font-family: 'Noto Naskh Arabic', 'Amiri', serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--tenant-primary);
    direction: rtl;
    text-align: center;
    line-height: 1.4;
    text-shadow: 0 4px 12px rgba(201, 168, 76, 0.4), 0 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 12px;
}
.iqama-countdown-german {
    font-family: 'Inter', 'DM Sans', sans-serif;
    font-size: 1.4rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    direction: ltr;
    text-align: center;
    line-height: 1.4;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    margin-bottom: 16px;
}
.iqama-countdown-timer {
    font-family: 'Inter', monospace;
    font-size: 3.5rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 4px 16px rgba(255, 255, 255, 0.2), 0 2px 4px rgba(0, 0, 0, 0.5);
    animation: iqamaPulse 2s ease-in-out infinite;
}
@keyframes iqamaPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.03); }
}

/* ==========================================
   Mobile Responsive — vertical stacked layout
   ========================================== */

/* Tablets (768px - 1024px) — narrower sidebar, smaller fonts */
@media (max-width: 1024px) {
    .display-shell {
        grid-template-columns: minmax(260px, 25%) 1fr;
    }
    .sidebar {
        padding: 24px 16px 0;
    }
    .clock-time { font-size: calc(2rem * var(--sidebar-font-scale)); }
    .clock-date, .hijri-date { font-size: calc(1rem * var(--sidebar-font-scale)); }
    .next-prayer-name, .countdown-label, .countdown-timer { font-size: calc(1.4rem * var(--sidebar-font-scale)); }
    .azan-hero-arabic { font-size: 1.75rem; }
    .azan-hero-german { font-size: 1rem; }
    .iqama-countdown-arabic { font-size: 1.75rem; }
    .iqama-countdown-german { font-size: 1rem; }
    .iqama-countdown-timer { font-size: 2.5rem; }
}

/* ==========================================================
   Mobile (< 768px) — prayer-focused layout
   Portrait: top bar + prayer strip + design below
   Landscape: sidebar left + design right (compact)
   ========================================================== */
@media (max-width: 767px) {
    html, body { overflow: hidden; }

    /* ── Portrait ── */
    .display-shell {
        position: fixed;
        inset: 0;
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
        grid-template-areas:
            "sidebar"
            "footer"
            "design";
        height: 100vh;
        height: 100dvh;
    }

    /* Sidebar — thin horizontal bar: logo | clock | next prayer */
    .sidebar {
        padding: 8px 12px;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        overflow: hidden;
    }

    /* Logo — small icon in the bar */
    .logo-wrapper {
        height: auto;
        margin-top: 0;
        order: -1;
        flex-shrink: 0;
    }
    .logo { max-height: 28px; }

    /* Clock — compact */
    .clock-section {
        margin-bottom: 0;
        padding: 6px 10px;
        border-radius: 10px;
        flex: 0 1 auto;
        min-width: 0;
        text-align: center;
    }
    .clock-time {
        font-size: calc(1.1rem * var(--sidebar-font-scale));
        margin-bottom: 1px;
    }
    .clock-date, .hijri-date {
        font-size: calc(0.6rem * var(--sidebar-font-scale));
        margin-bottom: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Next prayer — prominent, takes remaining space */
    .next-prayer-section {
        margin-bottom: 0;
        padding: 6px 12px;
        border-radius: 10px;
        gap: 6px;
        flex: 1 1 auto;
        min-width: 0;
    }
    .next-prayer-name { font-size: calc(1.05rem * var(--sidebar-font-scale)); }
    .countdown-label { font-size: calc(1.05rem * var(--sidebar-font-scale)); }
    .countdown-timer { font-size: calc(1.05rem * var(--sidebar-font-scale)); }

    /* Footer — prayer times strip, always visible */
    .prayer-footer {
        display: flex;
        height: auto;
        min-height: 0;
        padding: 5px 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    .prayer-footer-content { padding: 0 8px; }
    .footer-prayer-name { font-size: calc(0.6rem * var(--footer-font-scale, 1)); }
    .footer-prayer-time { font-size: calc(0.8rem * var(--footer-font-scale, 1)); }

    /* Design area — fills remaining viewport space */
    .main-design {
        border-radius: 0;
        min-height: 0;
    }

    /* Azan / Iqama text scaled */
    .azan-hero { padding: 10px 0 14px; margin-bottom: 10px; }
    .azan-hero-arabic { font-size: 1rem; }
    .azan-hero-german { font-size: 0.6rem; }
    .iqama-countdown-hero { padding: 10px 0 14px; margin-bottom: 10px; }
    .iqama-countdown-arabic { font-size: 1rem; }
    .iqama-countdown-german { font-size: 0.6rem; }
    .iqama-countdown-timer { font-size: 1.5rem; }
}

/* ── Mobile Landscape — sidebar left, design right ── */
@media (max-width: 767px) and (orientation: landscape) {
    .display-shell {
        grid-template-columns: 220px 1fr;
        grid-template-rows: 1fr auto;
        grid-template-areas:
            "sidebar design"
            "footer  footer";
    }

    /* Sidebar — vertical column again in landscape */
    .sidebar {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        padding: 10px 10px 0;
        gap: 6px;
        overflow-y: auto;
    }

    .logo-wrapper { order: 0; margin-top: auto; height: auto; }
    .logo { max-height: 24px; }

    .clock-section {
        padding: 8px;
        flex: 0 0 auto;
    }
    .clock-time { font-size: calc(1.2rem * var(--sidebar-font-scale)); }
    .clock-date, .hijri-date { font-size: calc(0.65rem * var(--sidebar-font-scale)); }

    .next-prayer-section {
        padding: 8px;
        flex: 0 0 auto;
    }
    .next-prayer-name { font-size: calc(1rem * var(--sidebar-font-scale)); }
    .countdown-label { font-size: calc(1rem * var(--sidebar-font-scale)); }
    .countdown-timer { font-size: calc(1rem * var(--sidebar-font-scale)); }

    /* Footer — compact bar at bottom spanning full width */
    .prayer-footer {
        padding: 4px 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        border-bottom: none;
    }
    .footer-prayer-name { font-size: calc(0.55rem * var(--footer-font-scale, 1)); }
    .footer-prayer-time { font-size: calc(0.7rem * var(--footer-font-scale, 1)); }

    .main-design { border-radius: 0; }
}

/* ── Very small phones (< 400px) — tighter spacing ── */
@media (max-width: 399px) and (orientation: portrait) {
    .sidebar { padding: 6px 8px; gap: 4px; }
    .clock-section { padding: 5px 8px; }
    .clock-time { font-size: calc(1rem * var(--sidebar-font-scale)); }
    .clock-date, .hijri-date { font-size: calc(0.55rem * var(--sidebar-font-scale)); }
    .next-prayer-section { padding: 5px 8px; }
    .next-prayer-name, .countdown-label, .countdown-timer { font-size: calc(0.9rem * var(--sidebar-font-scale)); }
    .logo { max-height: 22px; }
    .azan-hero-arabic { font-size: 0.8rem; }
    .azan-hero-german { font-size: 0.5rem; }
    .iqama-countdown-arabic { font-size: 0.8rem; }
    .iqama-countdown-german { font-size: 0.5rem; }
    .iqama-countdown-timer { font-size: 1.2rem; }
}
