:root {
    --primary: #FF9800; /* High Vis Orange */
    --primary-dim: #F57C00;
    --bg-dark: #121212;
    --bg-card: #1E1E1E;
    --text-main: #FFFFFF;
    --text-dim: #B0B0B0;
    --accent: #00E5FF; /* Cyan */
    --danger: #FF5252;
    --glass-bg: rgba(18, 18, 18, 0.85);
    
    /* Layout dims */
    --nav-height: 65px;
    --header-height: 140px;
    --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    padding-bottom: calc(var(--nav-height) + 20px);
    padding-top: var(--header-height);
    overflow-x: hidden;
}

/* --- Header & Search --- */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 10px 15px;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
}

.header-row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.logo-area span.tech-font {
    color: var(--primary);
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
    background: rgba(255, 152, 0, 0.1);
    padding: 2px 6px;
    border-radius: 6px;
}

.logo-area span { color: var(--primary); }

/* Lang Selector Styling */
.lang-selector {
    background-color: #333;
    color: #fff;
    border: 1px solid #444;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    outline: none;
    -webkit-appearance: none; /* Remove default styling */
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FF9800%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 10px top 50%;
    background-size: 10px auto;
    padding-right: 30px;
}

.search-container { position: relative; margin: 8px 0; }
#searchInput {
    width: 100%;
    padding: 10px 40px 10px 20px;
    background-color: #252525;
    border: 1px solid #444;
    border-radius: 25px;
    color: #fff;
    font-size: 1rem;
    transition: all 0.3s ease;
}
#searchInput:focus { 
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.2);
}
.search-icon { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); opacity: 0.7;}

/* --- Modules & Cards --- */
.module-container {
    background-color: var(--bg-card);
    margin: 15px;
    border-radius: var(--radius);
    overflow: hidden;
}
.module-header {
    padding: 15px;
    background: #252525;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-left: 5px solid var(--primary);
}
.module-header:after { content: '+'; font-size: 1.5rem; color: var(--primary); }
.module-container.open .module-header:after { content: '-'; }

.module-content {
    display: none;
    padding: 10px;
}
.module-container.open .module-content { display: block; }

.category-title {
    color: var(--primary);
    margin: 15px 0 8px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    border-bottom: 1px solid #333;
    padding-bottom: 4px;
}

/* --- Phrase Cards --- */
.card {
    background: linear-gradient(145deg, #1e1e1e, #252525);
    margin-bottom: 8px;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #333;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}
.card:active { background: linear-gradient(145deg, #252525, #2a2a2a); }
.card:hover { border-color: var(--primary); }

.card-text { 
    font-size: 1rem; 
    line-height: 1.4; 
    flex: 1; 
    margin-right: 10px;
    font-family: 'Roboto Mono', monospace; /* Monospaced easier to read for scripts */
    font-size: 0.95rem;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

/* --- Search & Filter Row --- */
.search-row {
    display: flex;
    gap: 10px;
    padding: 0 15px 10px 15px;
    align-items: center;
}

.search-container {
    flex: 2; /* البحث ياخد مساحة أكبر */
    position: relative;
    margin: 0;
}

#searchInput {
    width: 100%;
    padding: 10px 15px;
    background-color: #252525;
    border: 1px solid #444;
    border-radius: 25px;
    color: #fff;
    font-size: 1rem;
    transition: all 0.3s ease;
}

#searchInput:focus { 
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.2);
}

.filter-wrapper {
    flex: 1; /* الفلتر ياخد مساحة أقل */
}

.filter-selector {
    width: 100%;
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid #444;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FF9800%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
    padding-right: 30px;
    cursor: pointer;
}

.filter-selector:hover {
    border-color: var(--primary);
}

.filter-selector:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.2);
}

/* --- Library Accordion Styles (ستايل الطي) --- */
.chapter-block {
    margin-bottom: 20px;
}

/* --- Unified Accordion Styles (ستايل موحد للطي) --- */

/* المستوى الأول: الفصول (Chapters) والموديلات (Modules) */
.level-1-block {
    background-color: var(--bg-card);
    border: 1px solid #333;
    border-radius: 12px;
    margin-bottom: 15px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.level-1-header {
    padding: 15px 20px;
    background: linear-gradient(90deg, #252525, #1e1e1e);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid transparent; /* مخفي افتراضياً */
}

.level-1-title {
    margin: 0;
    color: var(--primary); /* اللون البرتقالي */
    font-size: 1.1rem;
    font-weight: bold;
}

/* المحتوى الداخلي للمستوى الأول */
.level-1-content {
    display: none;
    padding: 10px;
    background: #181818;
}

/* حالة الفتح (Open State) للمستوى الأول */
.level-1-block.open .level-1-content {
    display: block;
    animation: fadeIn 0.3s ease;
}
.level-1-block.open .level-1-header {
    border-bottom: 1px solid #444;
    background: #2a2a2a;
}

/* ---------------------------------------------------- */

/* المستوى الثاني: المواضيع (Topics) والتصنيفات (Categories) */
.level-2-block {
    background-color: #222;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid #3a3a3a;
    overflow: hidden;
    margin-left: 5px; /* ترحيل بسيط للداخل */
    margin-right: 5px;
}

.level-2-header {
    padding: 12px 15px;
    background: #2a2a2a;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.level-2-header:hover {
    background: #333;
}

.level-2-title {
    margin: 0;
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 500;
}

.level-2-content {
    display: none;
    padding: 10px;
    border-top: 1px solid #333;
}

/* حالة الفتح للمستوى الثاني */
.level-2-block.open .level-2-content {
    display: block;
    animation: slideDown 0.2s ease-out;
}

/* ---------------------------------------------------- */

/* أيقونة السهم */
.toggle-icon {
    font-size: 0.8rem;
    color: var(--text-dim);
    transition: transform 0.3s ease;
}

.level-1-block.open .level-1-header .toggle-icon,
.level-2-block.open .level-2-header .toggle-icon {
    transform: rotate(180deg);
    color: var(--primary);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; } to { opacity: 1; }
}



.icon-btn {
    background: #444;
    border: none;
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.copy-btn:active { background: var(--primary); color: #000; }
.speak-btn:active { background: var(--accent); color: #000; }

/* --- 🎨 New Activities Design (Professional Look) --- */

/* 1. Moves / Exercises Style */
.move-item {
    background-color: #252525;
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 10px;
    border-left: 4px solid var(--primary); /* خط برتقالي في الجنب */
    transition: transform 0.2s;
}

.move-item:hover {
    background-color: #2a2a2a;
}

.move-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.move-name {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
}

.move-desc {
    font-size: 0.85rem;
    color: #bbb;
    line-height: 1.4;
    margin-bottom: 8px;
}

.move-cue-box {
    background-color: #1a1a1a;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--accent); /* لون لبني للنداءات */
    font-family: 'Roboto Mono', monospace;
    display: inline-block;
}

/* 2. Music Playlist Style (Spotify Vibe) */
.music-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(145deg, #222, #1f1f1f);
    padding: 10px 15px;
    border-radius: 50px; /* شكل كبسولة */
    margin-bottom: 10px;
    border: 1px solid #333;
    transition: all 0.3s ease;
}

.music-item:hover {
    border-color: var(--primary);
    transform: translateX(5px);
}

.music-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-right: 10px;
}

.music-title {
    font-weight: bold;
    color: #fff;
    font-size: 0.95rem;
}

.music-meta {
    font-size: 0.75rem;
    color: #888;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bpm-tag {
    background-color: #333;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    border: 1px solid #444;
}

.usage-tag {
    color: var(--primary);
    font-weight: 600;
}

/* زرار التشغيل (يوتيوب) */
.play-btn {
    background-color: var(--primary);
    color: #000;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 1rem;
    box-shadow: 0 4px 10px rgba(255, 152, 0, 0.3);
    transition: transform 0.2s;
}

.play-btn:active {
    transform: scale(0.9);
}

/* --- Notes --- */
#view-notes { padding: 15px; }
.note-controls { background: var(--bg-card); padding: 15px; border-radius: var(--radius); margin-bottom: 20px;}
#add-note-form { display: flex; gap: 10px; margin-top: 10px; }
#new-note-input {
    flex: 1;
    padding: 10px;
    border-radius: 6px;
    border: none;
}
.btn-add {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0 15px;
    border-radius: 6px;
    font-weight: bold;
}
.delete-btn { color: var(--danger); font-size: 1rem; cursor: pointer; padding: 5px;}

/* --- Transitions --- */
.view-section.hidden { display: none; }
.view-section.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px);} to { opacity: 1; transform: translateY(0);}}

/* --- Bottom Nav --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: var(--nav-height);
    background: #1a1a1a;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #333;
    z-index: 101;
    padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
    background: none;
    border: none;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.75rem;
    width: 100%;
    padding: 8px 0;
}
.nav-item.active { color: var(--primary); }
.nav-item .icon { font-size: 1.4rem; margin-bottom: 4px;}

/* --- Toast --- */
#toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #000;
    padding: 12px 25px;
    border-radius: 25px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 200;
    transition: opacity 0.3s;
    pointer-events: none;
    text-align: center;
    width: max-content;
}
#toast.hidden { opacity: 0; }

/* --- Library Styles --- */
.lib-en {
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
    font-size: 1rem;
}
.lib-ar {
    font-family: 'Tahoma', sans-serif;
    color: var(--primary);
    font-size: 0.9rem;
    direction: rtl; /* Right to left for Arabic */
}
.desc {
    font-style: italic;
    color: #888;
    margin-bottom: 10px;
}

/* --- Credits --- */
.credits {
    text-align: center;
    padding: 20px;
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 60px; /* مسافة عشان الناف بار مايغطيش عليه */
}
.author {
    color: var(--primary);
    font-weight: bold;
}

/* --- 🌟 تحسينات الكروت الجديدة (الترجمة والنطق) --- */

/* 1. تظبيط شكل المعنى العربي (من اليمين للشمال + خط واضح) */
.card-text + div {
    font-family: 'Tahoma', sans-serif !important;
    direction: rtl; 
    text-align: right;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 10px;
    border-radius: 6px;
    border-right: 3px solid var(--primary);
    margin-top: 8px !important;
    line-height: 1.4;
    color: #ccc !important;
}

/* 2. تظبيط شكل النطق (لون لبني مميز عشان العين تلقطه بسرعة) */
.card-text + div + div {
    color: var(--accent) !important; 
    font-weight: 500;
    background: rgba(0, 229, 255, 0.05);
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
    margin-top: 6px !important;
    letter-spacing: 0.5px;
}

/* --- 🌟 تحسينات الكروت الجديدة (الترجمة والنطق) --- */

/* 1. تظبيط شكل المعنى العربي (من اليمين للشمال + خط واضح) */
.card-text + div {
    font-family: 'Tahoma', sans-serif !important;
    direction: rtl; 
    text-align: right;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 10px;
    border-radius: 6px;
    border-right: 3px solid var(--primary);
    margin-top: 8px !important;
    line-height: 1.4;
    color: #ccc !important;
}

/* 2. تظبيط شكل النطق (لون لبني مميز عشان العين تلقطه بسرعة) */
.card-text + div + div {
    color: var(--accent) !important; 
    font-weight: 500;
    background: rgba(0, 229, 255, 0.05);
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
    margin-top: 6px !important;
    letter-spacing: 0.5px;
}