/* Base Variables */
:root {
    --secondary: #10b981;
    --accent: #f59e0b;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg: #ffffff;
    --bg-secondary: #f9fafb;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 12px;
    --radius-sm: 8px;
}


.dark-mode {
    --secondary-light: var(--js-secondary-light, #34d399) !important;
    --accent: #f59e0b;
    --text: #f9fafb;
    --text-light: #d1d5db;
    --bg: #111827;
    --bg-secondary: #1f2937;
    --border: #374151;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}


/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Translation Styles */
.help-icon {
    margin-left: 8px;
    color: var(--text-secondary);
    cursor: help;
}

.help-icon:hover {
    background:
        linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)),
        var(--primary);
    background-blend-mode: darken;
}

.translation-example {
    margin-top: 10px;
    padding: 12px;
    background: var(--background-light);
    border-radius: var(--radius);
    border-left: 3px solid var(--primary);
}

.logo img {
    width: 2.5rem;
}

.example-code {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 8px 0;
}

.example-btn {
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 8px;
    transition: all 0.3s ease;
}

.example-btn:hover {
    background:
        linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)),
        var(--primary);
    background-blend-mode: darken;
    color: white;
}

.example-btn i {
    margin-right: 5px;
}

/* Preview translations */
.preview-translations-section {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px solid var(--border-color);
}

.translations-list {
    max-height: 200px;
    overflow-y: auto;
    background: var(--background-light);
    border-radius: var(--radius);
    padding: 15px;
    margin-top: 10px;
}

.translation-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--background);
    border-radius: 6px;
    margin-bottom: 6px;
    border: 1px solid var(--border-color);
}

.translation-word {
    font-weight: 600;
    color: var(--text-primary);
}

.translation-meaning {
    color: var(--primary);
    font-weight: 500;
}

.translation-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 5px;
}



/* Dark mode adjustments */
body.dark-mode .example-code {
    background: #2d2d2d;
}

body.dark-mode .translation-example {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .translation-item {
    background: rgba(255, 255, 255, 0.03);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    color: black;
    text-decoration: none;
}

.dark-mode .logo {
    color: white;
}

.logo i {
    font-size: 1.8rem;
}


.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

#lvl {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;

}

#lvlcefr {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;

}

.level-section {
    display: flex;
    align-items: center;
    gap: 6px;
}

.beginner,
.A1,
.A2 {
    background-color: #dcfce7;
    color: #166534;
    width: fit-content;
}

.intermediate,
.B1,
.B2 {
    background-color: #fef3c7;
    color: #92400e;
    width: fit-content;

}

.advanced,
.C1,
.C2 {
    background-color: #fee2e2;
    color: #991b1b;
    width: fit-content;

}



.theme-toggle {
    background: none;
    border: 2px solid var(--border);
    color: var(--text);
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background:
        linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)),
        var(--primary);
    background-blend-mode: darken;
    color: white;
    border-color: var(--primary);
}

/* Main Content */
.main-content {
    padding: 30px 0;
    min-height: calc(100vh - 140px);
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* Story Reader Styles */
.story-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--primary);
}

.back-button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
}

.back-button:hover {
    background:
        linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)),
        var(--primary);
    background-blend-mode: darken;
    transform: translateX(-3px);
}

#storyTitle {
    font-size: 2.2rem;
    color: var(--primary) !important;
    margin: 0;
    flex-grow: 1;
}

.reading-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    position: sticky;
    top: 70px;
    z-index: 10;
    backdrop-filter: blur(10px);
}



.control-btn:hover {
    background:
        linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)),
        var(--primary);
    background-blend-mode: darken;
    color: black;
    transform: translateY(-2px);
}

.dark-mode .control-btn:hover {
    color: white;
}

.control-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.story-text-container {
    padding: 30px;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 40px;
}

.story-text {
    font-size: 1.2rem;
    line-height: 1.8;
    text-align: justify;
    transition: font-size 0.3s ease, line-height 0.3s ease;
}

.paragraph {
    margin-bottom: 2em;
    padding: 14px;
    border-radius: var(--radius-sm);
    /* background: var(--bg-secondary); */
    border-left: 4px solid transparent;
    transition: background-color 0.3s ease;
}

.paragraph:hover {
    background: var(--bg);
    border-left-color: var(--primary);
}

.paragraph .mark {
    background: #ff7b0023;
    border-bottom: 2px dashed #ff7b00;
    cursor: pointer;

    border-radius: 4px;
    margin: 0 1px;
    position: relative;
    transition: all 0.2s ease;
    display: inline-block;
}

.word {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    margin: 0 1px;
    position: relative;
    transition: all 0.2s ease;
    display: inline-block;
}

.word:hover {
    background: rgba(79, 70, 229, 0.15);
    transform: translateY(-1px);
}

.word.saved {
    background: rgba(16, 185, 129, 0.15);
    border-bottom: 2px solid #10b981;
}

.word.no-translation {
    background: rgba(156, 163, 175, 0.15);
    border-bottom: 2px dashed var(--border);
}

/* Dictionary Popup - Simple Version */
.dictionary-popup {
    position: absolute;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    max-width: 350px;
    z-index: 1000;
    display: none;
    border: 1px solid var(--border);
}

.dictionary-popup.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dictionary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.dictionary-word {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary);
    margin-right: 10px;
}

.dictionary-pos {
    color: var(--text-light);
    font-style: italic;
    margin-bottom: 10px;
    font-size: 0.9rem;
    display: none;
    /* Hidden as in original */
}

.dictionary-definition {
    margin-bottom: 10px;
    line-height: 1.5;
    font-size: 0.95rem;
    display: none;
    /* Hidden as in original */
}

.dictionary-example {
    background: var(--bg-secondary);
    padding: 10px;
    border-radius: var(--radius);
    margin-bottom: 15px;
    font-style: italic;
    color: var(--text-light);
    font-size: 0.9rem;
    display: none;
    /* Hidden as in original */
}

.dictionary-translation {
    font-size: 20px;
    /* Fixed size as in original */
    color: var(--text);
    margin-bottom: 20px;
    text-align: center;
    font-weight: 500;
    direction: rtl;
    /* For Arabic text */
}

.dictionary-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
}

.dictionary-actions-buttom {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.dictionary-actions-buttom .btns {
    width: 48%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 5px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.dictionary-actions-buttom .btns:hover {
    background:
        linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)),
        var(--primary);
    background-blend-mode: darken;

}

.save-word {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.save-word:hover {
    background:
        linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)),
        var(--primary);
    background-blend-mode: darken;
}

.save-word:disabled {
    background: var(--border);
    cursor: not-allowed;
}

.close-popup {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.close-popup:hover {
    color: var(--text);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    display: none;
    backdrop-filter: blur(5px);
}

.modal-overlay.show {
    display: block;
}

/* Reading Progress */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--border);
    z-index: 1000;
}

.reading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    width: 0%;
    transition: width 0.3s ease;
}

/* Vocabulary Page Styles */
.vocabulary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--primary);
}

.vocabulary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--bg);
    padding: 25px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 10px;
}

.stat-label {
    color: var(--text-light);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.vocabulary-list {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.vocabulary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.3s ease;
}

.vocabulary-item:hover {
    background: var(--bg-secondary);
}

.vocabulary-item:last-child {
    border-bottom: none;
}

.word-info {
    flex: 1;
}

.word-main {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.word-text {
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--primary);
}

.word-translation {
    font-size: 16px;

    font-weight: 500;
}

.no-translation-badge {
    background: var(--accent);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}

.word-story {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 5px;
    font-style: italic;
}

.left {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 55%;
}

.word-actions {
    display: flex;
    gap: 10px;
}

.word-actions button {
    background: none;
    border: 2px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.word-actions button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background:
        linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)),
        var(--primary);
    background-blend-mode: darken;
    transform: translateY(-2px);
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--secondary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 1001;
    animation: slideIn 0.3s ease;
    font-weight: 500;
}



.upload-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.control-btn {
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s ease;
}

.control-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

#selectedFileName {
    color: var(--text-light);
    font-size: 0.9rem;
}

#fileError {
    color: #ef4444;
    margin-top: 10px;
}








/* File upload section */
.file-upload-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 25px;
    margin: 30px auto;
    max-width: 800px;
    text-align: center;
    border: 2px dashed var(--primary);
}

.file-upload-section h3 {
    color: var(--primary);
    margin-bottom: 10px;
}

.file-upload-section p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.upload-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

#browseStoryBtn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.3s;
}

#browseStoryBtn:hover {
    opacity: 0.9;
}

#selectedFileName {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.supported-formats {
    margin-top: 15px;
    display: flex;
    gap: 15px;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.supported-formats span {
    display: flex;
    align-items: center;
    gap: 5px;
}


@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Navigation */
.nav-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 30px;
}

.nav-tab {
    padding: 15px 30px;
    background: none;
    border: none;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s ease;
}


.nav-tab:hover {
    color: black;
}

.dark-mode .nav-tab {
    color: white;
}

.nav-tab.active {
    color: black;
    border-bottom-color: var(--primary);
}

.dark-mode .nav-tab.active {
    color: white;
    border-bottom-color: var(--primary);
}

nav ul {
    display: flex;
    list-style: none;
    position: relative;
    gap: 25px;
}

.nav-link {
    color: black;
    width: 100%;


}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 5px;
}

.dark-mode .nav-link {
    color: white;
    width: 100%;

}

nav a {
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    padding: 8px 12px;
    border-radius: var(--radius);
}

nav a:hover,
nav a.active {
    background-color: var(--primary);
    color: white;
}

/* Base more menu (hidden by default) */
.more {
    width: 250px;
    max-width: 280px;
    padding: 20px;
    background-color: white;
    position: absolute;
    top: 50px;
    right: 0px;
    z-index: 1000;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    color: white;
    font-family: inherit;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
}


.dark-mode .more {
    background-color: black;
}

/* When menu is open */
.more.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* صور القصة الأساسية */
.paragraph img {
    max-width: 100%;
    max-height: 200px;
    display: block;
    margin: 0.3rem auto;
    border-radius: 5px;
}

#sound {
    width: 50%;
}

#tts-language-indicator {
    font-size: 11px;
    background: var(--primary);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    margin-left: 5px;
    opacity: 0.8;
    cursor: pointer;
    display: flex;
    transition: opacity 0.2s;
    overflow: hidden;
    gap: 5px;
    justify-content: center;
    align-items: center;
}

/* تصميم متجاوب */
@media (max-width: 768px) {
    .paragraph img {
        margin: 0.8rem auto;
        border-radius: 4px;
    }

    #sound {
        width: 100%;
    }

    .settings-page {
        width: 100%;
        height: 100vh;
        right: -100%;
    }

    .pro {
        display: none;
    }


    .header-actions {
        width: 100%;
        justify-content: end;
    }

    .hero {
        margin-top: 7.3rem;
    }

    .hero-btns {
        flex-direction: column;
    }

    .settings-header {
        padding: 15px;
    }

    .settings-content {
        padding: 15px;
    }

    .setting-item {

        align-items: flex-start;
        gap: 10px;
    }



    .header-content {
        justify-content: center;
        flex-wrap: wrap;
        gap: 15px;
    }

    .left {
        width: 100%;
    }

    nav ul {
        gap: 15px;
    }



    .vocabulary-header {
        flex-direction: column;
        flex-wrap: wrap;
        padding-top: 15px;
        justify-content: center;
        gap: 15px;
    }

    .reading-controls {
        flex-wrap: wrap;
    }

    .footer-content {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }



    .btn-primary {
        width: fit-content;
        justify-content: center;
        padding: 16px 28px;
    }
}

@media (max-width: 480px) {
    .paragraph img {
        margin: 0.5rem auto;
        border-radius: 3px;
    }

    #tts-language-indicator {
        display: none;
    }

}

/* Responsive */
@media (max-width: 768px) {
    .header-content {

        gap: 15px;
        text-align: center;
    }

    #storyTitle {
        font-size: 1.8rem;
        text-align: center;
    }

    .story-header {
        flex-direction: column;
        gap: 15px;
    }

    #tts-language-indicator {
        display: none;
    }

    .story-text-container {
        Padding: 0px;
    }

    .story-text-container .paragraph {
        Padding: 0px;
    }

    .story-text {
        font-size: 1.1rem;
        line-height: 1.7;
        text-align: left;
    }

    .reading-controls {
        padding: 15px;
        gap: 8px;
        top: 60px;
    }

    .control-btn {
        padding: 8px 12px;
        min-width: 40px;
    }

    .control-btn span {
        display: none;
    }

    .vocabulary-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .vocabulary-item {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .word-actions {
        align-self: flex-end;
    }
}

/* Animation for Reading Experience */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.paragraph {
    animation: fadeInUp 0.5s ease forwards;
}

.paragraph:nth-child(odd) {
    animation-delay: 0.1s;
}

.paragraph:nth-child(even) {
    animation-delay: 0.2s;
}