/* =========================================
   SMARTDEEN v2.2.4 - MAIN STYLESHEET
   ========================================= */

/* --- 1. FONTS IMPORT --- */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&display=swap');

/* =========================================
   2. CSS VARIABLES & BASE SETUP
   ========================================= */
:root {
    /* Colors - Light Mode */
    --sd-bg-body: #f9fafb; /* gray-50 */
    --sd-bg-surface: #ffffff;
    --sd-text-main: #1f2937; /* gray-800 */
    --sd-text-muted: #9ca3af; /* gray-400 */
    --sd-border-color: #f3f4f6; /* gray-100 */
    
    /* Brand Colors (Emerald/Teal) */
    --sd-brand-primary: #10b981;
    --sd-brand-secondary: #14b8a6;
    --sd-brand-light: #ecfdf5;
    --sd-brand-dark: #047857;

    /* Glassmorphism */
    --sd-glass-bg: rgba(255, 255, 255, 0.9);
    --sd-glass-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Dark Mode Override */
html.dark {
    --sd-bg-body: #111827;
    --sd-bg-surface: #1f2937;
    --sd-text-main: #f3f4f6;
    --sd-text-muted: #6b7280;
    --sd-border-color: #374151;
    
    --sd-brand-light: rgba(16, 185, 129, 0.2);
    --sd-glass-bg: rgba(17, 24, 39, 0.9);
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    -webkit-tap-highlight-color: transparent; /* Hilangkan highlight biru saat tap di mobile */
    background-color: var(--sd-bg-body);
    color: var(--sd-text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
    margin: 0;
}

.font-arabic {
    font-family: 'Amiri', serif;
    line-height: 2.4; /* Line height diperbesar agar nyaman dibaca */
}

/* Layout Utility */
.sd-container {
    max-width: 56rem; /* max-w-4xl */
    margin: 0 auto;
    padding: 0 1rem;
}

/* =========================================
   3. HEADER COMPONENT (Vanilla CSS)
   ========================================= */
.sd-header {
    background-color: var(--sd-glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--sd-glass-shadow);
    border-bottom: 1px solid var(--sd-border-color);
    position: sticky;
    top: 0;
    z-index: 50;
    transition: all 0.3s ease;
}

.sd-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 4rem; /* h-16 */
}

/* Logo Group */
.sd-logo-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.sd-logo-group:hover .sd-logo-icon {
    transform: scale(1.05);
}

.sd-logo-icon {
    background: linear-gradient(to top right, var(--sd-brand-primary), var(--sd-brand-secondary));
    color: #ffffff;
    padding: 0.625rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.3);
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

html.dark .sd-logo-icon {
    box-shadow: none;
}

.sd-logo-icon i {
    font-size: 1.125rem;
}

.sd-logo-text h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.025em;
    color: var(--sd-text-main);
}

.sd-logo-text h1 span {
    color: var(--sd-brand-primary);
}

.sd-logo-text p {
    margin: 0.125rem 0 0 0;
    font-size: 0.625rem; /* 10px */
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--sd-text-muted);
}

/* Header Actions */
.sd-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sd-action-btn {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    background-color: var(--sd-bg-body);
    color: var(--sd-text-muted);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.sd-action-btn:hover {
    background-color: var(--sd-border-color);
}

html.dark .sd-action-btn[title="Ganti Tema"] {
    color: #facc15; /* yellow-400 */
}

/* Menu Button (Desktop & Mobile Adaptive) */
.sd-menu-btn {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    background-color: var(--sd-brand-primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
}

.sd-menu-btn:hover {
    background-color: var(--sd-brand-dark);
    transform: scale(1.05);
}

.sd-menu-btn:active {
    transform: scale(0.95);
}

.sd-menu-btn-text {
    display: none;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.025em;
}

@media (min-width: 768px) {
    .sd-header-actions { gap: 0.75rem; }
    .sd-divider {
        width: 1px;
        height: 1.5rem;
        background-color: var(--sd-border-color);
        margin: 0 0.25rem;
    }
    .sd-menu-btn {
        width: auto;
        padding: 0 1rem;
        border-radius: 0.75rem;
    }
    .sd-menu-btn-text {
        display: inline;
    }
}

/* =========================================
   4. CUSTOM SCROLLBAR
   ========================================= */
.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #e5e7eb;
    border-radius: 20px;
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #374151;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* =========================================
   5. ANIMATIONS
   ========================================= */
.anim-element {
    animation: fadeIn 0.4s ease-out;
}

.anim-hidden {
    animation: fadeOut 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

/* Ripple Effect (Tasbih Tap) */
@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.3);
    width: 100px;
    height: 100px;
    pointer-events: none;
    animation: ripple 0.6s ease-out;
    transform: scale(0);
}

/* =========================================
   6. COMPONENTS
   ========================================= */

/* Collapsible Wrapper (Shalat Highlight) */
.collapsible-wrapper {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.collapsible-wrapper.collapsed {
    grid-template-rows: 0fr;
}

.collapsible-content {
    overflow: hidden;
}

/* Marquee (Hadits Banner) */
.marquee-wrapper {
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}

.marquee-content {
    display: inline-block;
    padding-left: 100%;
    animation: marquee 20s linear infinite;
}

@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* Audio Range Slider */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;         
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 12px;
    width: 12px;
    border-radius: 50%;
    background: #10b981;
    margin-top: -4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

input[type=range]:active::-webkit-slider-thumb {
    transform: scale(1.2);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

/* Mobile Safe Area */
.pb-safe {
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* =========================================
   7. TOUR GUIDE
   ========================================= */
.tour-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.75); z-index: 90; backdrop-filter: blur(2px); transition: opacity 0.3s;
}

.tour-highlight {
    position: relative; z-index: 91 !important;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.3), 0 0 30px rgba(0, 0, 0, 0.5);
    border-radius: 1rem; transition: all 0.3s ease; background-color: white;
}

.dark .tour-highlight { background-color: #1f2937; }

.tour-tooltip {
    position: absolute; z-index: 92; width: 280px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: floatUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes floatUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================================
   8. CALENDAR STYLES
   ========================================= */
.cal-day.active { background-color: #10b981; color: white; border: none; }
.cal-day.fasting-sunnah { border: 2px solid #10b981; color: #059669; }
.cal-day.fasting-bidh { border: 2px solid #3b82f6; color: #2563eb; }
.cal-day.haram { background-color: #fee2e2; color: #ef4444; opacity: 0.7; }

.dark .cal-day.active { background-color: #059669; color: white; }
.dark .cal-day.fasting-sunnah { border-color: #059669; color: #34d399; }
.dark .cal-day.fasting-bidh { border-color: #2563eb; color: #60a5fa; }
.dark .cal-day.haram { background-color: #7f1d1d; color: #fca5a5; }

/* =========================================
   9. TASBIH REVAMP (CIRCULAR)
   ========================================= */
.tasbih-ring-bg {
    fill: none;
    stroke: #f3f4f6;
    stroke-width: 12;
}
.dark .tasbih-ring-bg {
    stroke: #374151;
}

.tasbih-ring-progress {
    fill: none;
    stroke: #10b981; /* Emerald */
    stroke-width: 12;
    stroke-linecap: round;
    transform: rotate(-90deg); /* Start from top */
    transform-origin: 50% 50%;
    transition: stroke-dashoffset 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus Mode (Layar Hitam Tasbih) */
#sd-tasbih-overlay {
    transition: opacity 0.5s ease;
    pointer-events: none;
    backdrop-filter: blur(5px);
}

/* Saat Focus Aktif */
.tasbih-focus-active #sd-tasbih-overlay {
    opacity: 1 !important;
    pointer-events: auto;
}

.tasbih-focus-active .tasbih-control-btn {
    opacity: 0.3; /* Tombol lain meredup */
    transition: opacity 0.5s;
}

.tasbih-focus-active #sd-tasbih-area {
    z-index: 60;
    filter: drop-shadow(0 0 20px rgba(16, 185, 129, 0.5));
}

/* =========================================
   10. ZOOM FEATURE (TEXT SIZING)
   ========================================= */
/* Level 1 (Default) */
.text-zoom-1 .font-arabic { font-size: 1.5rem; } /* 24px */
.text-zoom-1 .latin-text { font-size: 0.75rem; } /* 12px */

/* Level 2 */
.text-zoom-2 .font-arabic { font-size: 1.8rem; }
.text-zoom-2 .latin-text { font-size: 0.85rem; }

/* Level 3 */
.text-zoom-3 .font-arabic { font-size: 2.2rem; }
.text-zoom-3 .latin-text { font-size: 1rem; }

/* Level 4 */
.text-zoom-4 .font-arabic { font-size: 2.8rem; }
.text-zoom-4 .latin-text { font-size: 1.15rem; }

/* Level 5 (Max) */
.text-zoom-5 .font-arabic { font-size: 3.5rem; }
.text-zoom-5 .latin-text { font-size: 1.3rem; }

/* =========================================
   11. MENU MODAL (Vanilla CSS)
   ========================================= */
#sd-menu-modal {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 9999 !important; /* Paksa selalu berada di lapisan paling atas */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 1.5rem;
    animation: fadeIn 0.3s ease-out;
}

/* Menyembunyikan modal saat tidak aktif */
#sd-menu-modal.hidden {
    display: none !important;
}

.sd-modal-card {
    background-color: var(--sd-bg-surface);
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-width: 24rem; /* setara max-w-sm */
    width: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    border: 1px solid var(--sd-border-color);
}