/* ================================================================
   1. GLOBAL VARIABLES & OVERRIDES
   ================================================================ */
:root {
    --primary-color: #7cb89e;
    --secondary-color: #3a5a4a;
    --bg-color: #1a1e26;
    --text-color: #e8e4dc;
    --sidebar-bg: #222831;
    --card-bg: #222831;
    --card-border: #3a5a4a;
    --hover-color: #2d343f;
    --border-color: #3a3f4a;
    --header-border: #3a3f4a;
    --shadow-color: rgba(0,0,0,0.3);
    --shadow-hover: rgba(0,0,0,0.4);
    --loader-color: #8a8a8a;
    --scrollbar-track: #222831;
    --scrollbar-thumb: #3a4a4a;
    --bookmark-color: #e74c3c;
    --toast-bg: #2ecc71;
    --toast-color: #fff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    display: flex;
    height: 100vh;
    overflow: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    border-right: 2px solid var(--border-color);
    overflow-y: auto;
    padding: 20px 10px;
    box-shadow: 2px 0 10px var(--shadow-color);
    flex-shrink: 0;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.sidebar h2 {
    text-align: center;
    font-size: 22px;
    color: var(--primary-color);
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 12px;
    font-weight: 400;
    letter-spacing: 1px;
    transition: color 0.3s ease, border-color 0.3s ease;
}

.sidebar h2 span { font-weight: 700; }

.surah-item {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    width: 100%;
    margin-bottom: 4px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 15px;
    border: 1px solid transparent;
    color: var(--text-color);
}

.surah-item:hover {
    background: linear-gradient(135deg, rgba(139, 115, 85, 0.04), rgba(92, 69, 44, 0.03));
    border-color: rgba(139, 115, 85, 0.12);
}

.surah-item.active {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

.surah-item .surah-number { font-weight: 600; opacity: 0.6; font-size: 13px; }
.surah-item .surah-name-block {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
    flex: 1;
}
.surah-item .surah-name-ar {
    font-family: 'Amiri', 'Times New Roman', serif;
    font-size: 20px;
    font-weight: 600;
    margin-right: auto;
    padding-left: 8px;
}
.surah-item .surah-name-phonetic {
    font-size: 12px;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: auto;
}
.surah-item.active .surah-name-phonetic { opacity: 1; }

.main {
    flex: 1;
    overflow-y: auto;
    padding: 30px 40px 60px;
    background: var(--bg-color);
    transition: background 0.3s ease;
    position: relative;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--header-border);
    padding-bottom: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
    transition: border-color 0.3s ease;
}

.header-left { flex: 1; }
.header-right { display: flex; align-items: center; gap: 10px; }

.main-header h1 {
    font-size: 30px;
    font-weight: 300;
    color: var(--text-color);
    transition: color 0.3s ease;
}

.main-header h1 span {
    font-family: 'Amiri', 'Times New Roman', serif;
    font-size: 36px;
    font-weight: 700;
    color: var(--primary-color);
    margin-right: 10px;
    transition: color 0.3s ease;
}

.main-header .bismillah {
    font-family: 'Amiri', 'Times New Roman', serif;
    font-size: 28px;
    color: var(--primary-color);
    opacity: 0.8;
    transition: color 0.3s ease;
}

/* Boutons header */
.notes-btn, .settings-btn, .bookmarks-btn {
    background: var(--primary-color);
    border: none;
    color: #ffffff;
    font-size: 22px;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow-color);
    line-height: 1;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notes-btn { background: linear-gradient(135deg, #f5b041, #e67e22); }
.bookmarks-btn { background: linear-gradient(135deg, var(--bookmark-color), #c0392b); }

.notes-btn:hover, .settings-btn:hover, .bookmarks-btn:hover { transform: scale(1.05); filter: brightness(0.85); }
.notes-btn:active, .settings-btn:active, .bookmarks-btn:active { transform: scale(0.95); }

/* Focus toggle button */
.focus-toggle-btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    flex-shrink: 0;
}
.focus-toggle-btn:hover {
    background: var(--primary-color);
    color: var(--bg-color);
    transform: scale(1.05);
}
.focus-toggle-btn:active {
    transform: scale(0.95);
}
.focus-toggle-btn svg {
    width: 22px;
    height: 22px;
    display: block;
}

.auto-play-btn {
    background: #27ae60;
    color: #fff;
    border: none;
    font-size: 16px;
    padding: 8px 18px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.auto-play-btn:hover { background: #219a52; }
.auto-play-btn.playing { background: #e74c3c; }
.auto-play-btn.playing:hover { background: #c0392b; }

/* Boutons verset */
.verse-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: nowrap;
}

.verse-play-btn,
.verse-bookmark-btn,
.verse-copy-btn,
.verse-tafsir-btn {
    background: transparent;
    border: 1.5px solid var(--primary-color);
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px;
    padding: 7px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    line-height: 1;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.verse-note-btn {
    background: transparent;
    border: 1.5px solid #e67e22;
    color: #f5b041;
    font-size: 15px;
    padding: 7px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    line-height: 1;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.verse-note-btn:hover {
    background: rgba(230, 126, 34, 0.15);
    color: #ffffff;
    border-color: #f5b041;
}

.verse-bookmark-btn { border-color: var(--bookmark-color); color: var(--bookmark-color); }

.verse-play-btn:hover,
.verse-bookmark-btn:hover,
.verse-copy-btn:hover,
.verse-tafsir-btn:hover {
    background: linear-gradient(135deg, rgba(139, 115, 85, 0.22), rgba(92, 69, 44, 0.16));
    color: #ffffff;
    border-color: var(--primary-color);
}
.verse-note-btn:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
    filter: brightness(1.1);
}

.verse-bookmark-btn.bookmarked {
    background: transparent;
    color: #e74c3c;
    border-color: #e74c3c;
}

.verse-play-btn.playing { background: var(--primary-color); color: #fff; }

.verse-play-btn:focus,
.verse-note-btn:focus,
.verse-bookmark-btn:focus,
.verse-copy-btn:focus,
.verse-tafsir-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(124, 184, 158, 0.35);
}

.verse-item {
    margin-bottom: 18px;
    padding: 16px 18px;
    border: 0.3px solid rgba(255,255,255,0.18);
    border-radius: 14px;
    background: var(--card-bg);
    box-shadow: 0 1px 3px var(--shadow-color);
    animation: fadeUp 0.25s ease both;
    border-right: 6px solid var(--card-border);
    transition: all 0.3s ease;
}

.verse-item:hover {
    border-right-color: var(--primary-color);
    box-shadow: 0 4px 14px var(--shadow-hover);
    background: linear-gradient(135deg, rgba(139, 115, 85, 0.22), rgba(92, 69, 44, 0.16));
}

.verse-arabic {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    line-height: 2.2;
    padding: 2px 4px;
    margin-bottom: 10px;
    font-family: 'Amiri', 'Times New Roman', serif;
    font-size: 36px;
    font-weight: 400;
    text-align: right;
    direction: rtl;
    color: var(--text-color);
    letter-spacing: 0.5px;
    word-wrap: break-word;
    transition: all 0.3s ease;
}

.verse-arabic.bold { font-weight: 700; }
.verse-arabic.monospace { font-family: 'Courier New', 'Amiri', monospace; letter-spacing: 0; }

.verse-arabic .ayah-marker {
    display: inline-block;
    background: var(--primary-color);
    color: #ffffff;
    font-size: 20px;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    text-align: center;
    line-height: 36px;
    margin-left: 14px;
    font-weight: 700;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.verse-arabic .word { display: inline; transition: color 0.15s ease, font-weight 0.15s ease; white-space: pre; }
.verse-arabic .words-wrapper { display: inline; word-wrap: break-word; }
.verse-arabic .word.highlight { color: #3498db; font-weight: 700; }

.verse-translation {
    margin-top: 0;
    margin-bottom: 14px;
    margin-left: 36px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-color);
    opacity: 0.92;
    padding: 8px 0 0;
    position: relative;
    top: -2px;
}

.verse-translation::before {
    content: "";
    display: block;
    height: 1px;
    margin-bottom: 10px;
    background: linear-gradient(90deg, transparent 0%, rgba(139, 115, 85, 0.24) 28%, rgba(139, 115, 85, 0.08) 70%, transparent 100%);
    transition: background 0.2s ease;
}

.verse-item:hover .verse-translation::before {
    background: linear-gradient(90deg, transparent 0%, rgba(139, 115, 85, 0.72) 24%, rgba(139, 115, 85, 0.26) 70%, transparent 100%);
}

/* ========================
   PANNEAUX MODAUX COMMUNS
   ======================== */
.notes-panel,
.bookmarks-panel,
.settings-panel {
    position: fixed;
    background: var(--sidebar-bg);
    border-radius: 16px;
    box-shadow: 0 12px 60px rgba(0,0,0,0.45);
    z-index: 1100;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: panelFade 0.2s ease both;
    /* Dimensions par défaut */
    width: 560px;
    max-width: 90vw;
    max-height: 80vh;
}

.notes-panel.open,
.bookmarks-panel.open,
.settings-panel.open {
    display: flex;
    /* recentrage sera fait par JS */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* En-têtes */
.notes-header,
.bookmarks-header,
.settings-drag-handle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    color: #fff;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}

.notes-header { background: var(--primary-color); }
.bookmarks-header { background: var(--bookmark-color); }
.settings-drag-handle { background: var(--primary-color); }

.notes-header:active,
.bookmarks-header:active,
.settings-drag-handle:active { cursor: grabbing; }

.notes-header-actions,
.bookmarks-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.new-note-btn,
.notes-close-btn,
.new-bookmark-btn,
.bookmarks-close-btn,
.settings-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

.new-note-btn { background: rgba(255,255,255,0.2); padding: 6px 10px; border-radius: 999px; }
.new-bookmark-btn { background: rgba(255,255,255,0.25); padding: 6px 10px; border-radius: 999px; }

.settings-close-btn {
    font-size: 18px;
    margin-left: 10px;
}

/* Corps */
.notes-body,
.bookmarks-body,
.settings-body {
    padding: 18px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Formulaires */
.notes-form,
.bookmarks-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notes-form.hidden,
.bookmarks-form.hidden { display: none; }

.notes-form label,
.bookmarks-form label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
}

.notes-form select,
.notes-form textarea,
.bookmarks-form select,
.bookmarks-form input[type="text"] {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 14px;
}

.notes-form textarea { min-height: 90px; resize: vertical; }

.note-verse-selects,
.bookmark-verse-selects {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.note-verse-field,
.bookmark-verse-field {
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.notes-form-actions,
.bookmarks-form-actions {
    display: flex;
    gap: 8px;
}

.save-note-btn,
.save-bookmark-btn {
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
}

.save-note-btn { background: var(--primary-color); }
.save-bookmark-btn { background: var(--bookmark-color); }

.cancel-note-btn,
.cancel-bookmark-btn {
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(255,255,255,0.12);
    color: var(--text-color);
}

/* Listes */
.notes-list,
.bookmarks-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.note-item,
.bookmark-item {
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 12px;
    background: rgba(255,255,255,0.04);
    animation: fadeUp 0.22s ease both;
}

.note-meta,
.bookmark-meta {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
}

.note-meta { color: var(--primary-color); }
.bookmark-meta { color: var(--bookmark-color); }

.note-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-color);
    margin-bottom: 10px;
    white-space: pre-wrap;
}

.bookmark-label { font-size: 13px; color: var(--text-color); font-style: italic; }

.note-actions,
.bookmark-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.note-jump-btn,
.note-edit-btn,
.note-delete-btn,
.bookmark-jump-btn,
.bookmark-edit-btn,
.bookmark-delete-btn {
    border: none;
    border-radius: 8px;
    padding: 7px 10px;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
}

.note-jump-btn { background: #27ae60; }
.note-edit-btn { background: #4c6ef5; }
.note-delete-btn { background: #e74c3c; }
.bookmark-jump-btn { background: #27ae60; }
.bookmark-edit-btn { background: #4c6ef5; }
.bookmark-delete-btn { background: #c0392b; }

.note-target-highlight { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.bookmark-target-highlight { outline: 2px solid var(--bookmark-color); outline-offset: 2px; }

/* Poignées de redimensionnement */
.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 50px;
    height: 50px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 55%, var(--primary-color) 55%);
    border-radius: 0 0 16px 0;
    opacity: 0.6;
    z-index: 20;
    transition: opacity 0.2s;
}

.resize-handle:hover { opacity: 1; background: linear-gradient(135deg, transparent 45%, var(--primary-color) 45%); }

.resize-handle::after {
    content: "◢";
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-size: 20px;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    pointer-events: none;
}

/* Paramètres */
.setting-group { margin-bottom: 16px; }
.setting-group label { display: block; font-size: 14px; font-weight: 600; color: var(--text-color); margin-bottom: 4px; }

.setting-control { display: flex; align-items: center; gap: 12px; }

.setting-control input[type="range"] { flex: 1; -webkit-appearance: none; appearance: none; height: 5px; border-radius: 3px; background: var(--secondary-color); outline: none; }
.setting-control input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--primary-color); cursor: pointer; }
.setting-control input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--primary-color); cursor: pointer; border: none; }
.setting-control input[type="range"]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--secondary-color); }

.setting-control span { min-width: 45px; text-align: center; font-weight: 600; color: var(--text-color); font-size: 14px; }

.bold-toggle-btn, .toggle-btn {
    padding: 8px 20px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    background: transparent;
    color: var(--text-color);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    flex: 1;
}

.bold-toggle-btn.active, .toggle-btn.active { background: var(--primary-color); color: #ffffff; }
.bold-toggle-btn:hover, .toggle-btn:hover { transform: scale(1.02); }

.color-section { background: var(--hover-color); padding: 14px; border-radius: 12px; border: 1px solid var(--secondary-color); }
.color-row { display: grid; grid-template-columns: 70px 36px 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.color-row:last-child { margin-bottom: 0; }
.color-label { font-size: 12px; font-weight: 500; color: var(--text-color); white-space: nowrap; }
.color-row input[type="color"] { width: 32px; height: 32px; border: 2px solid var(--border-color); border-radius: 6px; cursor: pointer; padding: 2px; background: none; flex-shrink: 0; }
.color-hex-input { width: 100%; min-width: 0; padding: 4px 8px; border: 2px solid var(--border-color); border-radius: 6px; font-size: 12px; font-family: 'Courier New', monospace; background: var(--card-bg); color: var(--text-color); transition: border-color 0.3s ease; }
.color-hex-input:focus { outline: none; border-color: var(--primary-color); }
.reset-colors-btn { width: 100%; margin-top: 10px; padding: 8px; background: #f39c12; color: #ffffff; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.reset-colors-btn:hover { background: #e67e22; }

.theme-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.theme-btn { padding: 6px 12px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; font-size: 12px; font-weight: 500; transition: all 0.3s ease; }
.theme-btn:hover { transform: scale(1.05); }
.theme-btn.active { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(124, 184, 158, 0.3); }

/* Thèmes personnalisés */
.custom-theme-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

#customThemeName {
    flex: 1;
    padding: 6px 10px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 13px;
}

.custom-theme-action-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    background: #3498db;
    color: #fff;
    transition: background 0.3s ease;
}

.custom-theme-action-btn.recording { background: #27ae60; }

.custom-themes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.custom-theme-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 13px;
}

.custom-theme-item button {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.custom-theme-item .apply-custom-theme {
    font-weight: 600;
    margin-right: auto;
    cursor: pointer;
}

.custom-theme-item .apply-custom-theme:hover { color: var(--primary-color); }

.setting-control select { flex: 1; padding: 8px 12px; border: 2px solid var(--border-color); border-radius: 8px; font-size: 13px; background: var(--card-bg); color: var(--text-color); cursor: pointer; transition: border-color 0.3s ease; }
.setting-control select:focus { outline: none; border-color: var(--primary-color); }

.reset-btn { width: 100%; padding: 10px; background: #e74c3c; color: #ffffff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; }
.reset-btn:hover { background: #c0392b; }

/* Custom theme buttons integrated with presets */
.custom-theme-btn {
    position: relative;
    padding-right: 22px !important;
}
.custom-theme-delete {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.6;
    font-weight: 700;
}
.custom-theme-delete:hover {
    opacity: 1;
    color: #e74c3c;
}

/* Boutons flottants */
.floating-buttons {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 900;
    transition: opacity 0.3s ease;
}

.floating-buttons.hidden { display: none; }

.floating-buttons button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    cursor: pointer;
    font-size: 20px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.floating-buttons button:hover { transform: scale(1.1); filter: brightness(1.1); }

.floating-auto-play-btn { background: #27ae60; }
.floating-auto-play-btn.playing { background: #e74c3c; }

.floating-notes-btn { background: linear-gradient(135deg, #f5b041, #e67e22); }
.floating-bookmarks-btn { background: linear-gradient(135deg, var(--bookmark-color), #c0392b); }
.floating-settings-btn { background: var(--primary-color); }

.header-right .float-hidden { display: none !important; }

.floating-toggles {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.floating-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-color);
}

.floating-toggle-label input[type="checkbox"] { accent-color: var(--primary-color); }

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--toast-bg);
    color: var(--toast-color);
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    pointer-events: auto;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(20px); }
}

/* Divers */
.loading, .empty { text-align: center; padding: 60px 20px; font-size: 20px; color: var(--loader-color); }
.loading::after { content: "..."; animation: dots 1.2s steps(3, end) infinite; }
@keyframes dots { 0% { content: "."; } 33% { content: ".."; } 66% { content: "..."; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes panelFade { from { opacity: 0; transform: translate(-50%, -48%) scale(0.95); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 10px; }

@media (max-width: 768px) {
    body { flex-direction: column; height: 100vh; overflow: hidden; }
    .sidebar { width: 100%; height: 45vh; border-right: none; border-bottom: 2px solid var(--border-color); padding: 12px 8px; }
    .sidebar h2 { font-size: 18px; margin-bottom: 10px; padding-bottom: 8px; }
    .surah-item { padding: 6px 10px; font-size: 13px; }
    .surah-item .surah-name-ar { font-size: 17px; }
    .main { height: 55vh; padding: 16px 14px 30px; }
    .main-header h1 { font-size: 22px; }
    .main-header .bismillah { font-size: 20px; }
    .settings-panel { width: 95% !important; max-height: 90vh; }
    .settings-body { max-height: calc(90vh - 70px); padding: 16px; }
    .verse-arabic { font-size: 30px; line-height: 2; letter-spacing: 0.3px; }
    .verse-arabic .ayah-marker { width: 30px; height: 30px; font-size: 17px; line-height: 30px; margin-left: 10px; }
    .settings-btn { width: 40px; height: 40px; font-size: 18px; padding: 8px; }
    .color-row { grid-template-columns: 60px 30px 1fr; gap: 6px; }
    .color-label { font-size: 11px; }
    .color-row input[type="color"] { width: 28px; height: 28px; }
    .color-hex-input { font-size: 11px; padding: 3px 6px; }
    .resize-handle { width: 40px; height: 40px; opacity: 0.8; }
    .floating-buttons { bottom: 20px; right: 20px; gap: 8px; }
    .floating-buttons button { width: 40px; height: 40px; font-size: 18px; }
}
    
/* ================================================================
   NEW FEATURES CSS
   ================================================================ */

/* Reading progress bar */
.reading-progress {
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    height: 3px;
    background: transparent;
    z-index: 800;
    pointer-events: none;
}
.reading-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--primary-color);
    transition: width 0.1s linear;
    box-shadow: 0 0 8px var(--primary-color);
}

/* Header search */
.header-search {
    position: relative;
    display: flex;
    align-items: center;
}
.header-search input {
    padding: 8px 32px 8px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 14px;
    width: 220px;
    transition: all 0.3s ease;
    outline: none;
}
.header-search input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(124,184,158,0.15);
    width: 280px;
}
.header-search input::placeholder { color: var(--text-color); opacity: 0.5; }
.clear-search-btn {
    position: absolute;
    right: 6px;
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 12px;
    opacity: 0.6;
    padding: 4px;
    display: none;
}
.clear-search-btn.visible { display: block; }
.clear-search-btn:hover { opacity: 1; }

/* Resume banner */
.resume-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #fff;
    border-radius: 12px;
    margin: 0 0 16px 0;
    font-size: 14px;
    font-weight: 500;
    animation: fadeUp 0.3s ease both;
}
.resume-banner.hidden { display: none; }
.resume-banner button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.2s;
}
.resume-banner button:hover { background: rgba(255,255,255,0.35); }
.resume-banner #dismissResumeBtn {
    background: none;
    padding: 4px 8px;
    font-size: 16px;
}

/* Verse copy & tafsir buttons */
/* verse-copy-btn and verse-tafsir-btn share the same base style as play/note */
.verse-copy-btn, .verse-tafsir-btn {
    background: transparent;
    border: 1.5px solid var(--primary-color);
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px;
    padding: 7px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    line-height: 1;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.verse-copy-btn:hover, .verse-tafsir-btn:hover {
    background: linear-gradient(135deg, rgba(139, 115, 85, 0.22), rgba(92, 69, 44, 0.16));
    color: #ffffff;
    border-color: var(--primary-color);
}
.verse-copy-btn:focus, .verse-tafsir-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(124, 184, 158, 0.35);
}

/* Search highlight */
.verse-item.search-match {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    animation: pulse 1.5s ease infinite;
}
@keyframes pulse {
    0%, 100% { outline-color: var(--primary-color); }
    50% { outline-color: rgba(124,184,158,0.4); }
}
.verse-item.search-hidden { display: none; }

/* Focus mode */
body.focus-mode .sidebar { transform: translateX(-100%); width: 0; padding: 0; border: none; }
body.focus-mode .main { padding-left: 40px; padding-right: 40px; }
body.focus-mode .reading-progress { left: 0; }

/* Translation hidden mode */
body.hide-translations .verse-translation { display: none !important; }

/* Shortcuts list in settings */
.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--hover-color);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--secondary-color);
}
.shortcut-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-color);
}
.shortcut-row kbd {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 8px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    min-width: 24px;
    text-align: center;
    box-shadow: 0 2px 0 var(--border-color);
}

/* Tafsir panel */
.tafsir-panel {
    position: fixed;
    background: var(--sidebar-bg);
    border-radius: 16px;
    box-shadow: 0 12px 60px rgba(0,0,0,0.45);
    z-index: 1200;
    display: none;
    flex-direction: column;
    overflow: hidden;
    width: 500px;
    max-width: 90vw;
    max-height: 70vh;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}
.tafsir-panel.open { display: flex; }
.tafsir-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--primary-color);
    color: #fff;
    cursor: grab;
}
.tafsir-header:active { cursor: grabbing; }
.tafsir-body {
    padding: 18px;
    overflow-y: auto;
    flex: 1;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-color);
}
.tafsir-body p {
    margin-bottom: 12px;
    text-align: justify;
    word-wrap: break-word;
    white-space: normal;
}
.tafsir-body p:last-child {
    margin-bottom: 0;
}
.tafsir-close { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; }

/* Responsive */
@media (max-width: 768px) {
    .reading-progress { left: 0; }
    .header-search input { width: 140px; font-size: 13px; }
    .header-search input:focus { width: 180px; }
    body.focus-mode .main { padding-left: 14px; padding-right: 14px; }
}

/* ================================================================
   BUTTON DISPLAY & APPEARANCE SETTINGS
   ================================================================ */






/* SETTINGS BUTTON — NEVER HIDE */
#settingsToggle,
.settings-btn,
.header-right .settings-btn,
.header-right .settings-btn.float-hidden {
    display: flex !important;
}
.floating-settings-btn {
    display: flex !important;
}


/* ================================================================
   BUTTON DISPLAY ROW IN SETTINGS
   ================================================================ */
.btn-display-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
    font-size: 13px;
    color: var(--text-color);
}
.btn-display-row span {
    flex-shrink: 0;
    font-weight: 500;
}
.btn-display-row select {
    padding: 4px 8px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 12px;
    cursor: pointer;
}

/* ================================================================
   PER-BUTTON DISPLAY MODES
   ================================================================ */

/* NOTE button display modes */
body.note-hide .verse-note-btn { display: none !important; }
body.note-verse-only .verse-note-btn { display: inline-flex !important; }
body.note-verse-only #notesToggle { display: none !important; }
body.note-verse-only .floating-notes-btn { display: none !important; }
body.note-header-only .verse-note-btn { display: none !important; }
body.note-header-only #notesToggle { display: flex !important; }
body.note-header-only .floating-notes-btn { display: flex !important; }

/* BOOKMARK button display modes */
body.bookmark-hide .verse-bookmark-btn { display: none !important; }
body.bookmark-verse-only .verse-bookmark-btn { display: inline-flex !important; }
body.bookmark-verse-only #bookmarksToggle { display: none !important; }
body.bookmark-verse-only .floating-bookmarks-btn { display: none !important; }
body.bookmark-header-only .verse-bookmark-btn { display: none !important; }
body.bookmark-header-only #bookmarksToggle { display: flex !important; }
body.bookmark-header-only .floating-bookmarks-btn { display: flex !important; }

/* AUTOPLAY button display modes */
body.autoplay-hide .verse-play-btn { display: none !important; }
body.autoplay-hide .auto-play-btn { display: none !important; }
body.autoplay-hide .floating-auto-play-btn { display: none !important; }
body.autoplay-verse-only .verse-play-btn { display: inline-flex !important; }
body.autoplay-verse-only .auto-play-btn { display: none !important; }
body.autoplay-verse-only .floating-auto-play-btn { display: none !important; }
body.autoplay-header-only .verse-play-btn { display: none !important; }
body.autoplay-header-only .auto-play-btn { display: inline-flex !important; }
body.autoplay-header-only .floating-auto-play-btn { display: flex !important; }

/* TAFSIR button display modes */
body.tafsir-hide .verse-tafsir-btn { display: none !important; }
body.tafsir-verse-only .verse-tafsir-btn { display: inline-flex !important; }
body.tafsir-header-only .verse-tafsir-btn { display: none !important; }

/* COPY button display modes */
body.copy-hide .verse-copy-btn { display: none !important; }
body.copy-verse-only .verse-copy-btn { display: inline-flex !important; }
body.copy-header-only .verse-copy-btn { display: none !important; }