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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a2e;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========================================
   تعريف الخط NouariAbdelkabir
   ======================================== */
@font-face {
    font-family: 'NouariAbdelkabir';
    src: url('../fonts/NouariAbdelkabir.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

body, button, .mushaf-btn, .ctrl-btn, .page-label, .page-input,
.surah-item, .compare-mushaf-item, .panel-header, .close-panel {
    font-family: 'NouariAbdelkabir', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

h1, h2, h3, .sidebar-header h2, .panel-header h3 {
    font-family: 'NouariAbdelkabir', 'Segoe UI', sans-serif;
    font-weight: bold;
}

/* ========== الحاويات الرئيسية ========== */
.app-wrapper {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.viewer-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
}

/* ========== القائمة الجانبية ========== */
.sidebar {
    width: 260px;
    background-color: #16213e;
    color: white;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-left: 1px solid #e94560;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 18px 12px;
    background-color: #0f3460;
    text-align: center;
    border-bottom: 2px solid #e94560;
}

.sidebar-header h2 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.sidebar-header p {
    font-size: 0.7rem;
    color: #a0c4e2;
}

.mushaf-list {
    padding: 12px;
}

.mushaf-btn {
    display: block;
    width: 100%;
    text-align: right;
    background-color: #0f3460;
    border: none;
    color: white;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    border-right: 3px solid #e94560;
}

.mushaf-btn:hover {
    background-color: #e94560;
    transform: translateX(-3px);
}

.mushaf-btn.active {
    background-color: #e94560;
    border-right-color: #ffd966;
    font-weight: bold;
}

/* ========== منطقة عرض PDF ========== */
.viewer-area {
    flex: 1;
    background-color: #2f7ebb;
    padding: 2px 2px 0 2px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.viewer-container {
    flex: 1;
    background-color: #3a3d40;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    position: relative;
}

.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #aaa;
    font-size: 1.1rem;
    background-color: #2c2f33;
}

iframe {
    width: 100%;
    height: 1100px;
    max-height: 95vh;
    border: none;
    background-color: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
}

/* ========== وضع المقارنة ========== */
.compare-split {
    display: flex;
    gap: 8px;
    height: 100%;
}

.compare-split > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #2c2f33;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e94560;
}

.compare-split > div:first-child {
    border-left: 2px solid #e94560;
}

.compare-label {
    text-align: center;
    padding: 6px;
    background-color: #0f3460;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
}

.compare-split iframe {
    flex: 1;
}

/* ========== الشريط السفلي (تصميم عام) ========== */
.bottom-bar {
    background-color: #16213e;
    padding: 8px 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    border-top: 1px solid #e94560;
    border-radius: 0 0 12px 12px;
    margin: 0 12px 12px 12px;
    flex-shrink: 0;
}

.ctrl-btn {
    background-color: #e94560;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: 0.2s;
    font-weight: bold;
    white-space: nowrap;
}

.ctrl-btn:hover {
    background-color: #ff6b6b;
    transform: scale(1.02);
}

.surah-btn {
    background-color: #ff9800;
}

.compare-btn {
    background-color: #9b59b6;
}

.compare-btn.active {
    background-color: #e94560;
}

.page-box {
    background-color: #0f3460;
    padding: 4px 12px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-label {
    color: #a0c4e2;
    font-size: 0.75rem;
}

.page-input {
    width: 55px;
    padding: 4px;
    text-align: center;
    border-radius: 20px;
    border: none;
    font-weight: bold;
}

/* ========== مشغل الصوت المصغر ========== */
.mini-player {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: #0f3460;
    padding: 3px 10px;
    border-radius: 30px;
    height: 36px;
    margin: 0;
}

.mini-player.hidden {
    display: none;
}

.mini-btn {
    background: none;
    border: none;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 20px;
    transition: all 0.2s;
}

.mini-btn:hover {
    background-color: #1abc9c;
}

.mini-icon-btn {
    background: none;
    border: none;
    color: #1abc9c;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 15px;
    transition: all 0.2s;
}

.mini-icon-btn:hover {
    background-color: #1abc9c;
    color: white;
}

.mini-progress {
    width: 80px;
    height: 3px;
    background-color: #2d3e4f;
    border-radius: 2px;
    cursor: pointer;
    overflow: hidden;
}

.mini-progress-bar {
    width: 0%;
    height: 100%;
    background-color: #1abc9c;
    border-radius: 2px;
    transition: width 0.1s;
}

.mini-time {
    color: #a0c4e2;
    font-size: 0.65rem;
    min-width: 35px;
    direction: ltr;
    text-align: center;
}

#audioBtn {
    transition: all 0.3s ease;
    background-color: #1abc9c;
}

/* ========== أزرار التكبير والتصغير ========== */
.zoom-btn {
    background-color: #3498db;
}

.zoom-btn:hover {
    background-color: #2980b9;
}

.zoom-level {
    background-color: #0f3460;
    padding: 0px 0px;
    border-radius: 20px;
    color: #a0c4e2;
    font-size: 0.1rem;
    font-weight: bold;
}

/* ========== اللوحات المنبثقة ========== */
.float-panel {
    position: fixed;
    top: 0;
    right: -360px;
    width: 340px;
    height: 100%;
    background-color: #16213e;
    box-shadow: -2px 0 20px rgba(0,0,0,0.4);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.25s ease;
}

.float-panel.open {
    right: 0;
}

.panel-header {
    background-color: #0f3460;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ff9800;
}

.panel-header h3 {
    color: white;
    font-size: 1rem;
}

.close-panel {
    background: none;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
}

.close-panel:hover {
    color: #ff9800;
}

.panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.surah-item,
.compare-mushaf-item {
    background-color: #0f3460;
    padding: 8px 12px;
    margin-bottom: 6px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    transition: 0.2s;
}

.surah-item:hover,
.compare-mushaf-item:hover {
    background-color: #e94560;
    transform: translateX(-3px);
}

.surah-number {
    background-color: #e94560;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
}

.surah-name {
    flex: 1;
    margin-right: 12px;
}

.surah-page {
    color: #ffd966;
    font-size: 0.8rem;
}

/* ========== زر القائمة للهواتف ========== */
.menu-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 45px;
    height: 45px;
    background-color: #e94560;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.6rem;
    cursor: pointer;
    z-index: 1002;
    display: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    transition: all 0.2s;
}

.menu-toggle:hover {
    background-color: #ff6b6b;
    transform: scale(1.05);
}

::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: #16213e;
}

::-webkit-scrollbar-thumb {
    background: #e94560;
    border-radius: 5px;
}

/* ========================================
   قواعد الهواتف الموحدة (بدون تكرار)
   ======================================== */
@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        position: fixed;
        top: 0;
        right: -280px;
        width: 260px;
        height: 100%;
        z-index: 1001;
        transition: right 0.3s ease;
        box-shadow: 2px 0 15px rgba(0,0,0,0.3);
    }

    .sidebar.open {
        right: 0;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0,0,0,0.5);
        z-index: 1000;
        display: none;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .viewer-area {
        margin-right: 0;
        width: 100%;
    }

    .float-panel {
        width: 85%;
        right: -85%;
    }

    .compare-split {
        flex-direction: row;
        gap: 5px;
    }

    .compare-label {
        font-size: 0.6rem;
        padding: 4px;
    }

    /* الشريط السفلي ثابت في الأسفل */
    .bottom-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        background-color: #16213e;
        border-radius: 12px 12px 0 0;
        margin: 0;
        padding: 8px 12px;
        z-index: 1000;
        display: flex !important;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        border-top: 1px solid #e94560;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
    }

    .viewer-section {
        margin-bottom: 80px;
    }

    /* تصغير الأزرار */
    .ctrl-btn {
        padding: 5px 10px;
        font-size: 0.7rem;
        min-width: 50px;
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .page-box {
        padding: 3px 8px;
        border-radius: 8px;
    }

    .page-input {
        width: 45px;
        padding: 3px;
        font-size: 0.7rem;
    }

    .page-label {
        font-size: 0.6rem;
    }

    /* إخفاء أزرار إضافية */
    #zoomOutBtn, #zoomInBtn, #openSurahBtn, #compareBtn, #toggleSourceBtn {
        display: none !important;
    }

    /* إظهار زر المزيد */
    .more-btn {
        display: inline-flex !important;
        background-color: #555;
    }

    /* إخفاء مشغل الصوت تمامًا */
    .mini-player {
        display: none !important;
    }

    #audioBtn {
        display: inline-flex !important;
    }
}

/* ========================================
   شاشات صغيرة جداً
   ======================================== */
@media (max-width: 480px) {
    .ctrl-btn {
        padding: 4px 7px;
        font-size: 0.6rem;
        min-width: 42px;
    }

    .page-input {
        width: 38px;
        font-size: 0.65rem;
    }

    .page-label {
        font-size: 0.55rem;
    }

    .float-panel {
        width: 92%;
        right: -92%;
    }
}

/* ========================================
   حل خاص لهواتف ريالمي والأندرويد القديم
   ======================================== */
@media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 0) {
    .bottom-bar {
        display: block !important;
        text-align: center !important;
    }

    .bottom-bar .ctrl-btn,
    .bottom-bar .page-box {
        display: inline-block !important;
        margin: 3px !important;
        vertical-align: middle !important;
    }

    .ctrl-btn {
        display: inline-block !important;
        width: auto !important;
    }
}

/* ========================================
   القائمة المنبثقة (المزيد)
   ======================================== */
.more-menu {
    position: fixed;
    bottom: 70px;
    right: 10px;
    background-color: #16213e;
    border-radius: 12px;
    padding: 8px;
    z-index: 1000;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 130px;
}

.more-menu button {
    background-color: #0f3460;
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    text-align: right;
    font-size: 0.8rem;
}

.more-menu button:hover {
    background-color: #e94560;
}

.more-menu.hidden {
    display: none;
}
