/* ========================================================
   WIRA FITRAH &mdash; SOVEREIGN ISLAMIC DIGITAL ECOSYSTEM
   Spiritual Minimal, Calm & Trustworthy Design System
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Scheherazade+New:wght@400;600;700&display=swap');

:root {
    --fitrah-emerald-950: #022c22;
    --fitrah-emerald-900: #064e3b;
    --fitrah-emerald-800: #065f46;
    --fitrah-emerald-700: #047857;
    --fitrah-emerald-600: #059669;
    --fitrah-emerald-500: #10b981;
    --fitrah-emerald-100: #d1fae5;
    --fitrah-emerald-50:  #ecfdf5;

    --fitrah-gold-900: #78350f;
    --fitrah-gold-700: #b45309;
    --fitrah-gold-600: #d97706;
    --fitrah-gold-500: #f59e0b;
    --fitrah-gold-100: #fef3c7;
    --fitrah-gold-50:  #fffbeb;

    --fitrah-font-arabic: 'Amiri', 'Scheherazade New', serif;
    --fitrah-font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    
    --fitrah-bg: #f8fafc;
    --fitrah-card: #ffffff;
    --fitrah-card-border: #e2e8f0;
    --fitrah-text: #0f172a;
    --fitrah-text-muted: #64748b;
    --fitrah-header-bg: linear-gradient(135deg, #064e3b 0%, #065f46 60%, #047857 100%);
}

/* Theme 1: Fitrah Emerald & Gold (Default) */
[data-wira-theme="fitrah"] {
    --fitrah-bg: #f8fafc;
    --fitrah-card: #ffffff;
    --fitrah-card-border: #e2e8f0;
    --fitrah-text: #0f172a;
    --fitrah-text-muted: #64748b;
    --fitrah-header-bg: linear-gradient(135deg, #064e3b 0%, #065f46 60%, #047857 100%);
}

/* Theme 2: Midnight Serenity (Dark Mode) */
[data-wira-theme="midnight"] {
    --fitrah-bg: #090d16;
    --fitrah-card: #111827;
    --fitrah-card-border: #1f2937;
    --fitrah-text: #f3f4f6;
    --fitrah-text-muted: #9ca3af;
    --fitrah-header-bg: linear-gradient(135deg, #0b1329 0%, #0f172a 60%, #1e293b 100%);
}

/* Theme 3: Pristine Ivory */
[data-wira-theme="ivory"] {
    --fitrah-bg: #faf7f2;
    --fitrah-card: #ffffff;
    --fitrah-card-border: #ede6dd;
    --fitrah-text: #1c1917;
    --fitrah-text-muted: #78716c;
    --fitrah-header-bg: linear-gradient(135deg, #292524 0%, #44403c 60%, #57534e 100%);
}

body {
    font-family: var(--fitrah-font-sans);
    background-color: var(--fitrah-bg);
    color: var(--fitrah-text);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Responsive shell */
.fitrah-container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 1.5rem 1rem 6rem 1rem;
}

@media (min-width: 1024px) {
    .fitrah-container {
        padding: 2rem 1.5rem 4rem 1.5rem;
    }
}

/* Header & Hero Gradient */
.fitrah-hero-card {
    background: var(--fitrah-header-bg);
    color: #ffffff;
    border-radius: 24px;
    padding: 2rem 1.75rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 30px -10px rgba(4, 120, 87, 0.4);
}

.fitrah-hero-card::after {
    content: '';
    position: absolute;
    right: -40px;
    bottom: -40px;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(217, 119, 6, 0.25) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    pointer-events: none;
}

.fitrah-card {
    background: var(--fitrah-card);
    border: 1px solid var(--fitrah-card-border);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px -3px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fitrah-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px -4px rgba(0, 0, 0, 0.07);
}

/* Arabic Text Typography */
.arabic-text {
    font-family: var(--fitrah-font-arabic);
    direction: rtl;
    text-align: right;
    line-height: 2.2;
    letter-spacing: 0;
    font-size: 26px;
    font-weight: 500;
}

.arabic-title {
    font-family: var(--fitrah-font-arabic);
    direction: rtl;
    font-size: 32px;
    line-height: 1.4;
}

/* Verse marker symbol */
.ayah-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1.5px solid var(--fitrah-gold-600);
    border-radius: 50%;
    color: var(--fitrah-gold-600);
    font-size: 13px;
    font-family: var(--fitrah-font-sans);
    font-weight: 700;
    margin: 0 6px;
    vertical-align: middle;
}

/* Prayer Times Strip */
.prayer-time-item {
    padding: 1rem 0.75rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: all 0.25s ease;
}

.prayer-time-item.active-prayer {
    background: #ffffff;
    color: var(--fitrah-emerald-950);
    border-color: var(--fitrah-gold-500);
    transform: scale(1.05);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.2);
}

.prayer-time-item.active-prayer .prayer-name {
    color: var(--fitrah-emerald-700);
    font-weight: 700;
}

/* ========================================================
   LUXURY QIBLA COMPASS SYSTEM
   ======================================================== */
.qibla-dial-wrapper {
    position: relative;
    width: 310px;
    height: 310px;
    margin: 0 auto;
    border-radius: 50%;
    border: 7px solid var(--fitrah-emerald-800);
    outline: 3px solid rgba(217, 119, 6, 0.4);
    background: radial-gradient(circle at 50% 50%, #ffffff 0%, #f8fafc 65%, #e2e8f0 100%);
    box-shadow: 0 20px 45px -10px rgba(4, 120, 87, 0.25), inset 0 2px 14px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: box-shadow 0.4s ease, border-color 0.4s ease, outline-color 0.4s ease;
}

.qibla-dial-wrapper.aligned {
    border-color: #059669 !important;
    outline-color: #10b981 !important;
    box-shadow: 0 0 50px rgba(16, 185, 129, 0.65), inset 0 0 25px rgba(16, 185, 129, 0.3) !important;
    animation: qiblaGlowPulse 1.8s infinite;
}

@keyframes qiblaGlowPulse {
    0% { box-shadow: 0 0 30px rgba(16, 185, 129, 0.45), inset 0 0 15px rgba(16, 185, 129, 0.2); }
    50% { box-shadow: 0 0 60px rgba(16, 185, 129, 0.8), inset 0 0 30px rgba(16, 185, 129, 0.4); }
    100% { box-shadow: 0 0 30px rgba(16, 185, 129, 0.45), inset 0 0 15px rgba(16, 185, 129, 0.2); }
}

.qibla-compass-face {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.qibla-rotating-needle {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    transform-origin: 50% 50%;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.qibla-pointer-beam {
    position: absolute;
    top: 36px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 110px;
    background: linear-gradient(to top, rgba(16, 185, 129, 0.2), #d97706 70%, #f59e0b 100%);
    border-radius: 9999px;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.qibla-needle-tail {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 48px;
    background: linear-gradient(to bottom, rgba(100, 116, 139, 0.2), #94a3b8);
    border-radius: 9999px;
}

.qibla-kaaba-badge {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 42px;
    height: 42px;
    background: #0f172a;
    border: 2px solid #f59e0b;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), 0 0 12px rgba(245, 158, 11, 0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.qibla-dial-wrapper.aligned .qibla-kaaba-badge {
    border-color: #10b981 !important;
    box-shadow: 0 6px 22px rgba(16, 185, 129, 0.7), 0 0 16px rgba(16, 185, 129, 0.8) !important;
    transform: translateX(-50%) scale(1.08);
}

.qibla-center-hub {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fef08a 0%, #d97706 55%, #78350f 100%);
    border: 3px solid #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    z-index: 10;
}

.qibla-aligned-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem 1.25rem;
    background: rgba(16, 185, 129, 0.15);
    border: 1.5px solid #10b981;
    color: #047857;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.3s ease;
    animation: fadeInPill 0.3s ease;
}

@keyframes fadeInPill {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

[data-wira-theme="midnight"] .qibla-dial-wrapper {
    background: radial-gradient(circle at 50% 50%, #1e293b 0%, #0f172a 75%, #020617 100%) !important;
    border-color: #047857 !important;
    outline-color: rgba(245, 158, 11, 0.35) !important;
    box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.7), inset 0 2px 14px rgba(255, 255, 255, 0.05) !important;
}

[data-wira-theme="midnight"] .qibla-center-hub {
    border-color: #1e293b !important;
}

[data-wira-theme="midnight"] .qibla-aligned-pill {
    background: rgba(16, 185, 129, 0.2) !important;
    color: #34d399 !important;
    border-color: #34d399 !important;
}

[data-wira-theme="emerald"] .qibla-dial-wrapper {
    background: radial-gradient(circle at 50% 50%, #064e3b 0%, #022c22 80%, #011c16 100%) !important;
    border-color: #10b981 !important;
    outline-color: rgba(245, 158, 11, 0.5) !important;
}

[data-wira-theme="emerald"] .qibla-center-hub {
    border-color: #064e3b !important;
}

[data-wira-theme="emerald"] .qibla-aligned-pill {
    background: rgba(16, 185, 129, 0.25) !important;
    color: #6ee7b7 !important;
    border-color: #34d399 !important;
}

@media (max-width: 480px) {
    .qibla-dial-wrapper {
        width: 275px;
        height: 275px;
    }
    .qibla-pointer-beam {
        top: 32px;
        height: 95px;
    }
    .qibla-kaaba-badge {
        width: 38px;
        height: 38px;
        top: 8px;
    }
}

/* Tactile Tasbih Counter */
.tasbih-ring-button {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, var(--fitrah-emerald-600) 0%, var(--fitrah-emerald-900) 100%);
    border: 8px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 40px -10px rgba(4, 120, 87, 0.5), inset 0 -4px 12px rgba(0,0,0,0.3);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
    margin: 1.5rem auto;
}

.tasbih-ring-button:active {
    transform: scale(0.94);
    box-shadow: 0 10px 20px -5px rgba(4, 120, 87, 0.4), inset 0 2px 8px rgba(0,0,0,0.4);
}

.tasbih-count-display {
    font-size: 56px;
    font-weight: 800;
    line-height: 1;
    font-family: var(--fitrah-font-sans);
    letter-spacing: -1px;
}

/* ========================================================
   FLOATING ACTION POPOVER MENU (ROUND / CIRCLING EXPERIENCE)
   ======================================================== */
.fitrah-mobile-menu-scope {
    display: block;
}

@media (min-width: 821px) {
    .fitrah-mobile-menu-scope {
        display: none !important;
    }
}

/* Floating Action Button (FAB Trigger) */
.fitrah-fab-trigger {
    position: fixed;
    bottom: max(1.25rem, env(safe-area-inset-bottom, 1.25rem));
    right: 1.25rem;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #047857 0%, #064e3b 100%);
    border: 2px solid rgba(251, 191, 36, 0.5);
    box-shadow: 0 8px 24px rgba(4, 120, 87, 0.42), 0 3px 8px rgba(0, 0, 0, 0.16);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease, box-shadow 0.2s ease;
}

.fitrah-fab-trigger:active {
    transform: scale(0.92);
}

.fitrah-fab-trigger .fitrah-fab-icon-menu {
    display: block;
    transition: transform 0.25s ease;
}

.fitrah-fab-trigger .fitrah-fab-icon-close {
    display: none;
    transition: transform 0.25s ease;
}

.fitrah-fab-trigger.open {
    background: #0f172a;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
    transform: rotate(90deg);
}

.fitrah-fab-trigger.open .fitrah-fab-icon-menu {
    display: none;
}

.fitrah-fab-trigger.open .fitrah-fab-icon-close {
    display: block;
}

/* Scrim Backdrop */
.fitrah-popover-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9997;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.fitrah-popover-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

/* Floating Popover Container */
.fitrah-mobile-popover {
    position: fixed;
    bottom: calc(max(1.25rem, env(safe-area-inset-bottom, 1.25rem)) + 68px);
    right: 1.25rem;
    width: min(320px, calc(100vw - 2.5rem));
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.6);
    padding: 1.25rem;
    z-index: 9998;
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8) translateY(16px);
    transition: opacity 0.25s ease, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    -webkit-user-select: none;
}

.fitrah-mobile-popover.open {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
}

.fitrah-popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--fitrah-card-border);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.fitrah-popover-close-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--fitrah-card-border);
    background: var(--fitrah-bg);
    color: var(--fitrah-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* 6 Round / Circling Menu Grid */
.fitrah-popover-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.9rem;
    justify-items: center;
}

.fitrah-popover-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--fitrah-text);
    padding: 2px;
    border-radius: 16px;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease;
}

.fitrah-popover-node:active {
    transform: scale(0.92);
}

.fitrah-node-circle {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--fitrah-bg);
    border: 1.5px solid var(--fitrah-card-border);
    color: var(--fitrah-text-muted);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fitrah-node-circle svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
}

.fitrah-popover-node.active .fitrah-node-circle {
    background: linear-gradient(135deg, #047857 0%, #065f46 100%);
    color: #ffffff;
    border-color: #10b981;
    box-shadow: 0 6px 16px rgba(4, 120, 87, 0.35);
    transform: scale(1.05);
}

.fitrah-node-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--fitrah-text-muted);
    text-align: center;
    letter-spacing: -0.2px;
}

.fitrah-popover-node.active .fitrah-node-label {
    color: var(--fitrah-emerald-700);
    font-weight: 800;
}

/* Midnight Theme Overrides for Mobile Popover */
[data-wira-theme="midnight"] .fitrah-fab-trigger {
    background: linear-gradient(135deg, #065f46 0%, #022c22 100%);
    border-color: rgba(251, 191, 36, 0.4);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

[data-wira-theme="midnight"] .fitrah-mobile-popover {
    background: rgba(17, 24, 39, 0.94);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

[data-wira-theme="midnight"] .fitrah-node-circle {
    background: rgba(31, 41, 55, 0.85);
    border-color: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
}

[data-wira-theme="midnight"] .fitrah-popover-node.active .fitrah-node-circle {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #ffffff;
    border-color: #34d399;
    box-shadow: 0 6px 18px rgba(5, 150, 105, 0.4);
}

[data-wira-theme="midnight"] .fitrah-popover-node.active .fitrah-node-label {
    color: #34d399;
}

/* Ivory Theme Overrides */
[data-wira-theme="ivory"] .fitrah-fab-trigger {
    background: linear-gradient(135deg, #b45309 0%, #92400e 100%);
    border-color: rgba(217, 119, 6, 0.5);
}

[data-wira-theme="ivory"] .fitrah-popover-node.active .fitrah-node-circle {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    border-color: #f59e0b;
}

[data-wira-theme="ivory"] .fitrah-popover-node.active .fitrah-node-label {
    color: #b45309;
}


/* Desktop Navigation Header */
.fitrah-top-nav {
    background: var(--fitrah-card);
    border-bottom: 1px solid var(--fitrah-card-border);
    position: sticky;
    top: 0;
    z-index: 990;
    backdrop-filter: blur(12px);
}

.fitrah-nav-link {
    text-decoration: none;
    color: var(--fitrah-text-muted);
    font-weight: 600;
    font-size: 14px;
    padding: 0.5rem 0.85rem;
    border-radius: 10px;
    transition: all 0.15s ease;
}

.fitrah-nav-link:hover, .fitrah-nav-link.active {
    color: var(--fitrah-emerald-700);
    background: var(--fitrah-emerald-50);
}

[data-wira-theme="midnight"] .fitrah-nav-link:hover,
[data-wira-theme="midnight"] .fitrah-nav-link.active {
    color: var(--fitrah-emerald-500);
    background: rgba(16, 185, 129, 0.1);
}

/* Audio Player Bar */
.ayah-audio-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--fitrah-emerald-50);
    color: var(--fitrah-emerald-700);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ayah-audio-btn:hover {
    background: var(--fitrah-emerald-700);
    color: #ffffff;
    transform: scale(1.08);
}

.ayah-audio-btn.playing {
    background: var(--fitrah-gold-500) !important;
    color: #ffffff !important;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
    animation: pulse 1.5s infinite;
}

/* Bookmarked State */
.ayah-bookmark-btn.bookmarked {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 10px rgba(217, 119, 6, 0.4);
    animation: bookmarkBounce 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ayah-bookmark-btn.bookmarked:hover {
    background: linear-gradient(135deg, #d97706, #b45309) !important;
    transform: scale(1.08);
}

@keyframes bookmarkBounce {
    0% { transform: scale(0.85); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

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

/* Badge styles */
.badge-gold {
    background: var(--fitrah-gold-100);
    color: var(--fitrah-gold-900);
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-emerald {
    background: var(--fitrah-emerald-100);
    color: var(--fitrah-emerald-950);
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Print layout */
@media print {
    .fitrah-bottom-nav, .fitrah-top-nav, .no-print {
        display: none !important;
    }
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
}

/* ========================================================
   THEME OVERRIDES FOR MIDNIGHT (DARK MODE)
   ======================================================== */
[data-wira-theme="midnight"] body {
    background-color: #090d16 !important;
    color: #f8fafc !important;
}

[data-wira-theme="midnight"] .fitrah-top-nav {
    background: #111827 !important;
    border-color: #1f2937 !important;
}

[data-wira-theme="midnight"] .fitrah-bottom-nav {
    background: rgba(17, 24, 39, 0.96) !important;
    border-color: #1f2937 !important;
}

[data-wira-theme="midnight"] .fitrah-card {
    background: #111827 !important;
    border-color: #1f2937 !important;
    color: #f8fafc !important;
    box-shadow: 0 4px 20px -3px rgba(0, 0, 0, 0.4) !important;
}

[data-wira-theme="midnight"] .fitrah-hero-card {
    background: linear-gradient(135deg, #022c22 0%, #064e3b 50%, #0f172a 100%) !important;
    box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.6) !important;
}

[data-wira-theme="midnight"] h1,
[data-wira-theme="midnight"] h2,
[data-wira-theme="midnight"] h3,
[data-wira-theme="midnight"] h4,
[data-wira-theme="midnight"] strong {
    color: #f8fafc !important;
}

[data-wira-theme="midnight"] .arabic-text {
    color: #6ee7b7 !important;
}

[data-wira-theme="midnight"] .arabic-title {
    color: #a7f3d0 !important;
}

[data-wira-theme="midnight"] .quran-verse-arabic {
    color: #f0fdf4 !important;
}

[data-wira-theme="midnight"] .quran-verse-trans {
    color: #94a3b8 !important;
    border-color: #10b981 !important;
}

[data-wira-theme="midnight"] input,
[data-wira-theme="midnight"] select,
[data-wira-theme="midnight"] textarea {
    background: #1f2937 !important;
    color: #f8fafc !important;
    border-color: #374151 !important;
}

[data-wira-theme="midnight"] option {
    background: #111827 !important;
    color: #f8fafc !important;
}

[data-wira-theme="midnight"] footer {
    background: #0b0f19 !important;
    border-color: #1f2937 !important;
}

[data-wira-theme="midnight"] .badge-emerald {
    background: rgba(16, 185, 129, 0.2) !important;
    color: #6ee7b7 !important;
}

[data-wira-theme="midnight"] .badge-gold {
    background: rgba(245, 158, 11, 0.2) !important;
    color: #fde047 !important;
}

[data-wira-theme="midnight"] .ayah-audio-btn {
    background: #1f2937 !important;
    color: #10b981 !important;
}

[data-wira-theme="midnight"] .qibla-dial-wrapper {
    background: radial-gradient(circle, #1e293b 0%, #0f172a 100%) !important;
    border-color: #059669 !important;
}

/* ========================================================
   THEME OVERRIDES FOR FITRAH (DEFAULT EMERALD)
   ======================================================== */
[data-wira-theme="fitrah"] body {
    background-color: #f8fafc !important;
    color: #0f172a !important;
}

[data-wira-theme="fitrah"] .fitrah-top-nav {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
}

[data-wira-theme="fitrah"] .fitrah-bottom-nav {
    background: rgba(255, 255, 255, 0.96) !important;
    border-color: #e2e8f0 !important;
}

[data-wira-theme="fitrah"] .fitrah-card {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    color: #0f172a !important;
    box-shadow: 0 4px 15px -3px rgba(0, 0, 0, 0.04) !important;
}

[data-wira-theme="fitrah"] .fitrah-hero-card {
    background: linear-gradient(135deg, #064e3b 0%, #065f46 60%, #047857 100%) !important;
    box-shadow: 0 12px 30px -10px rgba(4, 120, 87, 0.4) !important;
}

[data-wira-theme="fitrah"] h1,
[data-wira-theme="fitrah"] h2,
[data-wira-theme="fitrah"] h3,
[data-wira-theme="fitrah"] h4,
[data-wira-theme="fitrah"] strong {
    color: #0f172a !important;
}

[data-wira-theme="fitrah"] .arabic-text {
    color: #065f46 !important;
}

[data-wira-theme="fitrah"] input,
[data-wira-theme="fitrah"] select,
[data-wira-theme="fitrah"] textarea {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: #e2e8f0 !important;
}

/* ========================================================
   THEME OVERRIDES FOR IVORY (WARM SAND)
   ======================================================== */
[data-wira-theme="ivory"] body {
    background-color: #faf7f2 !important;
    color: #1c1917 !important;
}

[data-wira-theme="ivory"] .fitrah-top-nav {
    background: #ffffff !important;
    border-color: #ede6dd !important;
}

[data-wira-theme="ivory"] .fitrah-bottom-nav {
    background: rgba(255, 255, 255, 0.96) !important;
    border-color: #ede6dd !important;
}

[data-wira-theme="ivory"] .fitrah-card {
    background: #ffffff !important;
    border-color: #ede6dd !important;
    color: #1c1917 !important;
    box-shadow: 0 4px 15px -3px rgba(120, 53, 15, 0.05) !important;
}

[data-wira-theme="ivory"] .fitrah-hero-card {
    background: linear-gradient(135deg, #292524 0%, #44403c 60%, #57534e 100%) !important;
    box-shadow: 0 12px 30px -10px rgba(41, 37, 36, 0.4) !important;
}

[data-wira-theme="ivory"] h1,
[data-wira-theme="ivory"] h2,
[data-wira-theme="ivory"] h3,
[data-wira-theme="ivory"] h4,
[data-wira-theme="ivory"] strong {
    color: #1c1917 !important;
}

[data-wira-theme="ivory"] .arabic-text {
    color: #78350f !important;
}

[data-wira-theme="ivory"] input,
[data-wira-theme="ivory"] select,
[data-wira-theme="ivory"] textarea {
    background: #fdfbf7 !important;
    color: #1c1917 !important;
    border-color: #ede6dd !important;
}

/* Theme Switcher Active Button Highlights */
[data-wira-theme="fitrah"] #theme-btn-fitrah {
    background: #ffffff !important;
    box-shadow: 0 2px 8px rgba(4, 120, 87, 0.25) !important;
}

[data-wira-theme="midnight"] #theme-btn-midnight {
    background: #1f2937 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
}

[data-wira-theme="ivory"] #theme-btn-ivory {
    background: #ffffff !important;
    box-shadow: 0 2px 8px rgba(180, 83, 9, 0.25) !important;
}

/* Tasbih Target Switcher Buttons */
.tasbih-target-btn {
    padding: 0.45rem 0.95rem;
    border-radius: 12px;
    border: 1.5px solid var(--fitrah-card-border);
    background: var(--fitrah-card);
    color: var(--fitrah-text) !important;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.tasbih-target-btn:hover {
    border-color: var(--fitrah-emerald-500);
    transform: translateY(-1px);
}

.tasbih-target-btn.active {
    background: var(--fitrah-emerald-700) !important;
    color: #ffffff !important;
    border-color: var(--fitrah-emerald-700) !important;
    box-shadow: 0 4px 12px rgba(4, 120, 87, 0.35);
}

.tasbih-reset-btn {
    padding: 0.45rem 0.95rem;
    border-radius: 12px;
    border: 1.5px solid rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444 !important;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tasbih-reset-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    transform: translateY(-1px);
}

/* Dark mode specific high-contrast refinements */
[data-wira-theme="midnight"] .tasbih-target-btn {
    background: #1e293b !important;
    color: #f8fafc !important;
    border-color: rgba(255, 255, 255, 0.16) !important;
}

[data-wira-theme="midnight"] .tasbih-target-btn:hover {
    border-color: #34d399 !important;
    background: #334155 !important;
}

[data-wira-theme="midnight"] .tasbih-target-btn.active {
    background: #059669 !important;
    color: #ffffff !important;
    border-color: #10b981 !important;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4) !important;
}

[data-wira-theme="midnight"] .tasbih-reset-btn {
    background: rgba(239, 68, 68, 0.18) !important;
    border-color: rgba(239, 68, 68, 0.45) !important;
    color: #fca5a5 !important;
}

[data-wira-theme="emerald"] .tasbih-target-btn {
    background: #064e3b !important;
    color: #ecfdf5 !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

[data-wira-theme="emerald"] .tasbih-target-btn:hover {
    border-color: #6ee7b7 !important;
    background: #047857 !important;
}

[data-wira-theme="emerald"] .tasbih-target-btn.active {
    background: #10b981 !important;
    color: #064e3b !important;
    font-weight: 800 !important;
    border-color: #34d399 !important;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45) !important;
}

[data-wira-theme="emerald"] .tasbih-reset-btn {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: rgba(239, 68, 68, 0.45) !important;
    color: #fca5a5 !important;
}

/* ========================================================
   NATIVE MOBILE APP EXPERIENCE & TOUCH ERGONOMICS
   ======================================================== */

* {
    -webkit-tap-highlight-color: transparent;
}

button, a, .fitrah-card, .quick-action-item, .nav-tab-item, .prayer-time-item {
    touch-action: manipulation;
}

/* Mobile Quick Actions Grid */
.mobile-quick-actions {
    display: none;
}

@media (max-width: 768px) {
    /* Safe Area & Shell adjustments */
    body {
        overscroll-behavior-y: contain;
    }

    .fitrah-container {
        padding: 0.85rem 0.85rem calc(6.5rem + env(safe-area-inset-bottom, 0px)) 0.85rem !important;
    }

    /* Native App Bar for Mobile */
    .mobile-appbar {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: max(10px, env(safe-area-inset-top, 10px)) 1rem 10px 1rem;
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-bottom: 1px solid var(--fitrah-card-border);
        position: sticky;
        top: 0;
        z-index: 990;
    }

    [data-wira-theme="midnight"] .mobile-appbar {
        background: rgba(17, 24, 39, 0.85) !important;
        border-bottom-color: rgba(255, 255, 255, 0.08) !important;
    }

    [data-wira-theme="ivory"] .mobile-appbar {
        background: rgba(250, 247, 242, 0.9) !important;
        border-bottom-color: rgba(237, 230, 221, 0.95) !important;
    }

    .desktop-top-header {
        display: none !important;
    }

    /* 4-Bubble Quick Action Grid */
    .mobile-quick-actions {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
        margin: -0.75rem 0 1.25rem 0;
    }

    .quick-action-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        background: var(--fitrah-card);
        border: 1px solid var(--fitrah-card-border);
        border-radius: 18px;
        padding: 12px 6px 10px 6px;
        box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.04);
        transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.15s ease;
    }

    .quick-action-btn:active {
        transform: scale(0.93) !important;
    }

    .quick-action-icon {
        width: 44px;
        height: 44px;
        border-radius: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 7px;
        box-shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.15);
    }

    .quick-action-label {
        font-size: 11px;
        font-weight: 700;
        color: var(--fitrah-text);
        text-align: center;
        line-height: 1.2;
    }

    /* Mobile Hero Prayer Horizontal Scroll */
    .mobile-prayer-row {
        display: flex !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 8px !important;
        padding: 4px 2px 8px 2px !important;
        margin-top: 1.25rem !important;
    }

    .mobile-prayer-row::-webkit-scrollbar {
        display: none;
    }

    .mobile-prayer-row .prayer-time-item {
        flex: 0 0 88px !important;
        scroll-snap-align: start !important;
        border-radius: 16px !important;
        padding: 10px 8px !important;
    }

    .active-prayer {
        border-color: #fef08a !important;
        box-shadow: 0 0 16px rgba(254, 240, 138, 0.45) !important;
        animation: prayerActivePulse 2.5s infinite ease-in-out;
    }

    @keyframes prayerActivePulse {
        0%, 100% { box-shadow: 0 0 10px rgba(254, 240, 138, 0.3); }
        50% { box-shadow: 0 0 20px rgba(254, 240, 138, 0.7); }
    }

    /* Bottom Sheet Transformation for Modals */
    .fitrah-modal-content {
        border-radius: 28px 28px 0 0 !important;
        margin-top: auto !important;
        max-height: 88vh !important;
        width: 100% !important;
        animation: slideUpBottomSheet 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }

    .bottom-sheet-handle {
        width: 40px;
        height: 5px;
        border-radius: 9999px;
        background: rgba(156, 163, 175, 0.4);
        margin: 0 auto 14px auto;
    }

    @keyframes slideUpBottomSheet {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}

@media (pointer: coarse) {
    .btn, button, .quick-action-btn, .nav-tab-item, .fitrah-card {
        user-select: none;
        -webkit-user-select: none;
    }
    .btn:active, button:active, .quick-action-btn:active {
        transform: scale(0.95);
    }
}

/* ========================================================
   Responsive Page Footer (Rich on Desktop, Simplified on Mobile)
   ======================================================== */
.fitrah-page-footer {
    border-top: 1px solid var(--fitrah-card-border);
    background: var(--fitrah-card);
    margin-top: 4rem;
    padding: 2.5rem 1rem;
    position: relative;
    z-index: 10;
}

.footer-desktop-content {
    display: block;
}

.footer-mobile-content {
    display: none;
}

@media (max-width: 768px) {
    .fitrah-page-footer {
        margin-top: 1.5rem !important;
        margin-bottom: 0 !important;
        padding: 1.25rem 1rem calc(2.25rem + env(safe-area-inset-bottom, 0px)) 1rem !important;
        border-top: 1px solid var(--fitrah-card-border) !important;
        background: transparent !important;
    }

    .footer-desktop-content {
        display: none !important;
    }

    .footer-mobile-content {
        display: block !important;
    }
}

/* ========================================================
   QURAN ACTIVE PLAYING AYAH HIGHLIGHT & AUTO-SCROLL GLOW
   ======================================================== */
.ayah-item-card.ayah-playing-highlight {
    border-color: var(--fitrah-emerald-500) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.28), 0 10px 25px rgba(4, 120, 87, 0.12) !important;
    background: rgba(16, 185, 129, 0.045) !important;
    transform: scale(1.006);
}

[data-wira-theme="midnight"] .ayah-item-card.ayah-playing-highlight {
    background: rgba(16, 185, 129, 0.1) !important;
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.35), 0 12px 32px rgba(0, 0, 0, 0.6) !important;
}

/* ========================================================
   GLOBAL TOAST NOTIFICATIONS (ANCHORED AT BOTTOM RIGHT)
   ======================================================== */
.w-toast-container {
    position: fixed !important;
    bottom: 1.5rem !important;
    right: 1.5rem !important;
    top: auto !important;
    left: auto !important;
    z-index: 999999 !important;
    display: flex !important;
    flex-direction: column-reverse !important;
    gap: 0.75rem !important;
    pointer-events: none !important;
    max-width: 380px !important;
    width: calc(100% - 3rem) !important;
}

@media (max-width: 768px) {
    .w-toast-container {
        bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)) !important;
        right: 1rem !important;
        left: auto !important;
        max-width: 340px !important;
        width: calc(100% - 2rem) !important;
    }
}

/* ========================================================
   IBADAH LOG & ANALYTICS STYLES
   ======================================================== */
.ibadah-kpi-card {
    background: var(--fitrah-card);
    border: 1px solid var(--fitrah-card-border);
    border-radius: 18px;
    padding: 1.35rem 1.25rem;
    position: relative;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.03);
}

.ibadah-kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
    border-color: var(--fitrah-emerald-400);
}

.ibadah-kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.ibadah-kpi-val {
    font-size: 28px;
    font-weight: 800;
    color: var(--fitrah-text);
    line-height: 1.15;
    margin: 0.6rem 0 0.2rem 0;
    letter-spacing: -0.5px;
}

/* Visual Bar Charts */
.ibadah-chart-box {
    background: var(--fitrah-card);
    border: 1px solid var(--fitrah-card-border);
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.chart-bars-wrap {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 180px;
    padding-top: 25px;
    padding-bottom: 5px;
    gap: 8px;
    border-bottom: 1.5px dashed var(--fitrah-card-border);
}

.chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    position: relative;
    cursor: pointer;
}

.chart-bar-bg {
    width: 100%;
    max-width: 38px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: rgba(16, 185, 129, 0.06);
    border-radius: 10px;
    position: relative;
    overflow: visible;
}

.chart-bar-fill {
    width: 100%;
    border-radius: 10px;
    transition: height 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    animation: barGrowUp 0.8s ease-out forwards;
    transform-origin: bottom;
}

.chart-bar-fill.emerald {
    background: linear-gradient(180deg, #10b981 0%, #047857 100%);
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.3);
}

.chart-bar-fill.gold {
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.3);
}

.chart-bar-fill.perfect {
    background: linear-gradient(180deg, #fbbf24 0%, #059669 100%);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
}

@keyframes barGrowUp {
    0% { transform: scaleY(0); opacity: 0.2; }
    100% { transform: scaleY(1); opacity: 1; }
}

/* Tooltip on Chart Bar */
.chart-col .chart-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--fitrah-text);
    color: var(--fitrah-card);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 20;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.chart-col .chart-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 4px;
    border-style: solid;
    border-color: var(--fitrah-text) transparent transparent transparent;
}

.chart-col:hover .chart-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.chart-col:hover .chart-bar-fill {
    filter: brightness(1.1);
    transform: scaleX(1.05);
}

.chart-day-label {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--fitrah-text-muted);
}

.chart-col.is-today .chart-day-label {
    color: var(--fitrah-emerald-700);
    font-weight: 800;
}

/* Habit Matrix */
.habit-matrix-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.habit-matrix-table th {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--fitrah-text-muted);
    padding: 0.75rem 0.5rem;
    text-align: center;
    border-bottom: 1.5px solid var(--fitrah-card-border);
}

.habit-matrix-table td {
    padding: 0.65rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid var(--fitrah-card-border);
}

.habit-matrix-table tr:last-child td {
    border-bottom: none;
}

.habit-pill-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--fitrah-card-border);
    background: var(--fitrah-bg);
    color: var(--fitrah-text-muted);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 0;
}

.habit-pill-btn:hover {
    transform: scale(1.12);
    border-color: var(--fitrah-emerald-500);
}

.habit-pill-btn.active {
    background: linear-gradient(135deg, #10b981, #047857);
    border-color: #047857;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}

.habit-pill-btn.active svg {
    display: block;
}

.habit-pill-btn svg {
    width: 16px;
    height: 16px;
}

/* Tabs */
.ibadah-tab-nav {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--fitrah-card-border);
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.ibadah-tab-btn {
    padding: 0.55rem 1rem;
    border-radius: 12px;
    background: var(--fitrah-bg);
    border: 1px solid var(--fitrah-card-border);
    color: var(--fitrah-text-muted);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ibadah-tab-btn:hover {
    color: var(--fitrah-text);
    border-color: var(--fitrah-emerald-400);
}

.ibadah-tab-btn.active {
    background: var(--fitrah-emerald-700);
    color: #ffffff;
    border-color: var(--fitrah-emerald-700);
    box-shadow: 0 2px 10px rgba(4, 120, 87, 0.25);
}

