/* Style Reset & Theme Settings */
:root {
    --bg-color: #0b0c10;
    --card-bg: rgba(22, 24, 33, 0.6);
    --sidebar-bg: rgba(13, 15, 22, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-primary: #8b5cf6;
    --accent-secondary: #3b82f6;
    --accent-gradient: linear-gradient(135deg, #8b5cf6, #3b82f6);
    --accent-hover: linear-gradient(135deg, #a78bfa, #60a5fa);
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-kurdish: 'Vazirmatn', sans-serif;
    --font-english: 'Plus Jakarta Sans', sans-serif;
}

body.light-theme {
    --bg-color: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.85);
    --sidebar-bg: rgba(248, 250, 252, 0.9);
    --border-color: rgba(0, 0, 0, 0.08);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --accent-primary: #6d28d9;
    --accent-secondary: #1d4ed8;
    --accent-gradient: linear-gradient(135deg, #6d28d9, #1d4ed8);
    --accent-hover: linear-gradient(135deg, #5b21b6, #1e40af);
}

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

html, body {
    height: 100%;
    font-family: var(--font-kurdish);
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    scroll-behavior: smooth;
}

/* LTR layout override */
html[lang="en"] body {
    font-family: var(--font-english);
}

/* Background Glow */
.glow-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glow-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    mix-blend-mode: screen;
    animation: floatGlow 15s infinite alternate ease-in-out;
    will-change: transform;
}

.sphere-1 {
    width: 400px;
    height: 400px;
    background: var(--accent-primary);
    top: -100px;
    right: -100px;
}

.sphere-2 {
    width: 500px;
    height: 500px;
    background: var(--accent-secondary);
    bottom: -150px;
    left: -150px;
    animation-delay: -5s;
}

@keyframes floatGlow {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(50px, 50px) scale(1.15);
    }
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    border-inline-end: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

/* Position based on RTL/LTR */
html[dir="rtl"] .sidebar {
    right: 0;
    left: auto;
}
html[dir="ltr"] .sidebar {
    left: 0;
    right: auto;
}

.sidebar-header {
    margin-bottom: 40px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    box-shadow: 0 8px 16px rgba(139, 92, 246, 0.25);
}

.logo-text h1 {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.logo-text span {
    font-size: 11px;
    color: var(--text-secondary);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    text-align: start;
    transition: var(--transition);
    width: 100%;
}

.nav-item i {
    font-size: 20px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.sidebar-footer {
    margin-top: auto;
}

.footer-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
}

.footer-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    margin-inline-start: 280px;
    min-height: 100vh;
    padding: 30px 40px;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin-inline-end: auto;
    width: calc(100% - 280px);
}

/* Top Bar Styling */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.hamburger-menu {
    display: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-primary);
    padding: 8px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
}

.status-indicator-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.red {
    background-color: var(--danger-color);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.status-dot.green {
    background-color: var(--success-color);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

/* Tabs System */
.tab-content-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-pane.active {
    display: block;
}

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

.pane-header {
    margin-bottom: 25px;
}

.pane-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.pane-header p {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
}

/* Input Section & Upload Zone */
.input-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 30px;
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.upload-zone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    padding: 40px 20px;
    text-align: center;
    position: relative;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.01);
    transition: var(--transition);
    overflow: hidden;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent-primary);
    background: rgba(139, 92, 246, 0.03);
}

.upload-zone.dragover i {
    transform: translateY(-8px);
}

.file-input {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.upload-content i {
    font-size: 48px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: var(--transition);
}

.upload-content h3 {
    font-size: 16px;
    font-weight: 600;
}

.upload-content p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Preview Zone inside Upload Box */
.preview-zone {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.image-preview {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.pdf-preview-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 20px;
}

.pdf-icon {
    font-size: 64px;
    color: var(--danger-color);
}

.pdf-file-name {
    font-size: 15px;
    font-weight: 500;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-remove-file {
    position: absolute;
    top: 15px;
    z-index: 20;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Position remove button based on direction */
html[dir="rtl"] .btn-remove-file {
    left: 15px;
    right: auto;
}
html[dir="ltr"] .btn-remove-file {
    right: 15px;
    left: auto;
}

/* Text Add-ons */
.prompt-addons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.prompt-addons label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.prompt-addons textarea {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    resize: vertical;
    transition: var(--transition);
}

.prompt-addons textarea:focus {
    border-color: var(--accent-secondary);
    background: rgba(255, 255, 255, 0.04);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.35);
}

.btn-action {
    padding: 14px 28px;
    font-size: 15px;
    margin-top: 10px;
}

/* Info Grid and Cards */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 10px;
}

.info-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    backdrop-filter: blur(16px);
    transition: var(--transition);
}

.info-card:hover {
    border-color: rgba(139, 92, 246, 0.3);
    transform: translateY(-4px);
}

.info-icon {
    width: 48px;
    height: 48px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #a78bfa;
    margin-bottom: 16px;
}

.info-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
}

.info-card p {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

/* Results Section Output Card */
.results-wrapper {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 30px;
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.25);
    margin-top: 10px;
    min-height: 200px;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.result-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-title i {
    font-size: 24px;
    color: #a78bfa;
}

.result-title h3 {
    font-size: 18px;
    font-weight: 700;
}

.result-actions {
    display: flex;
    gap: 8px;
}

.btn-icon-action {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: var(--transition);
}

.btn-icon-action:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Loader Animation */
.result-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 20px;
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    position: relative;
}

.double-bounce1, .double-bounce2 {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--accent-primary);
    opacity: 0.6;
    position: absolute;
    top: 0;
    left: 0;
    animation: sk-bounce 2.0s infinite ease-in-out;
}

.double-bounce2 {
    background-color: var(--accent-secondary);
    animation-delay: -1.0s;
}

@keyframes sk-bounce {
    0%, 100% { transform: scale(0.0) }
    50% { transform: scale(1.0) }
}

#loader-message {
    color: var(--text-secondary);
    font-size: 14px;
    animation: pulse 1.5s infinite alternate ease-in-out;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Markdown Formatted Output Styling */
.result-body {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-primary);
}

.result-body h1, .result-body h2, .result-body h3, .result-body h4 {
    color: var(--text-primary);
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 700;
}

.result-body h1 { font-size: 22px; border-bottom: 1px solid var(--border-color); padding-bottom: 8px;}
.result-body h2 { font-size: 19px; }
.result-body h3 { font-size: 17px; }

.result-body p {
    margin-bottom: 16px;
}

.result-body ul, .result-body ol {
    margin-bottom: 16px;
    padding-inline-start: 24px;
}

.result-body li {
    margin-bottom: 6px;
}

.result-body strong {
    color: #a78bfa;
    font-weight: 600;
}

.result-body code {
    background: rgba(255, 255, 255, 0.07);
    padding: 3px 6px;
    border-radius: 4px;
    font-family: Consolas, monospace;
    font-size: 13px;
    color: #f472b6;
}

.result-body pre {
    background: #0f111a;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.result-body pre code {
    background: transparent;
    padding: 0;
    color: #f8fafc;
}

.result-body blockquote {
    border-inline-start: 4px solid var(--accent-primary);
    background: rgba(139, 92, 246, 0.05);
    padding: 12px 20px;
    margin-bottom: 16px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

html[dir="rtl"] .result-body blockquote {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.result-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.result-body th, .result-body td {
    border: 1px solid var(--border-color);
    padding: 12px 14px;
    text-align: start;
}

.result-body th {
    background: rgba(255, 255, 255, 0.03);
    font-weight: 700;
}

.result-body tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.01);
}

/* Modal Window */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-box {
    background: #0f111a;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 500px;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-box {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h3 i {
    color: #a78bfa;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
}

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

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-body p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i {
    position: absolute;
    font-size: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

html[dir="rtl"] .input-with-icon i {
    right: 14px;
}
html[dir="ltr"] .input-with-icon i {
    left: 14px;
}

.input-with-icon input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    outline: none;
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
}

html[dir="rtl"] .input-with-icon input {
    padding: 12px 42px 12px 42px;
}
html[dir="ltr"] .input-with-icon input {
    padding: 12px 42px 12px 42px;
}

.input-with-icon input:focus {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-toggle-visibility {
    position: absolute;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

html[dir="rtl"] .btn-toggle-visibility {
    left: 8px;
}
html[dir="ltr"] .btn-toggle-visibility {
    right: 8px;
}

.btn-toggle-visibility:hover {
    color: var(--text-primary);
}

.help-box {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.help-box h4 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
    color: #a78bfa;
}

.help-box ol {
    padding-inline-start: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 6px;
    line-height: 1.5;
}

.help-box a {
    color: var(--accent-secondary);
    text-decoration: none;
    font-weight: 600;
}

.help-box a:hover {
    text-decoration: underline;
}

.modal-footer {
    padding: 18px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(15, 17, 26, 0.95);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 2000;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    opacity: 0;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    border-color: rgba(16, 185, 129, 0.3);
    color: #a7f3d0;
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.3);
    color: #fecaca;
}

/* Hidden Utility */
.hidden {
    display: none !important;
}

/* --- Chat UI Styles --- */
.chat-input-container {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.chat-input-container textarea {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: inherit;
    resize: none;
    outline: none;
    transition: var(--transition);
}

.chat-input-container textarea:focus {
    border-color: var(--accent-primary);
    background: rgba(0, 0, 0, 0.3);
}

.btn-chat-send {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: var(--transition);
}

.btn-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.chat-message {
    margin-bottom: 20px;
    padding: 16px;
    border-radius: var(--radius-md);
    animation: fadeIn 0.3s ease;
}

.chat-message.user {
    background: rgba(139, 92, 246, 0.1);
    border-inline-start: 4px solid var(--accent-primary);
}

.chat-message.ai {
    background: transparent;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--accent-primary);
}

/* --- Flashcards UI Styles --- */
.flashcards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.flashcard {
    background-color: transparent;
    width: 100%;
    height: 200px;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.flashcard-front {
    background: var(--card-bg);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.1rem;
}

.flashcard-back {
    background: var(--accent-gradient);
    color: white;
    transform: rotateY(180deg);
    font-size: 0.95rem;
    overflow-y: auto;
}

/* Responsive Rules */
@media (max-width: 992px) {
    .sidebar {
        width: 250px;
    }
    .main-content {
        margin-inline-start: 250px;
        width: calc(100% - 250px);
        padding: 24px 30px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        box-shadow: 0 0 30px rgba(0,0,0,0.5);
    }
    
    html[dir="ltr"] .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-inline-start: 0 !important;
        width: 100% !important;
        padding: 20px;
    }

    .hamburger-menu {
        display: block;
    }

    .top-bar {
        padding-bottom: 16px;
        margin-bottom: 20px;
    }

    .input-section {
        padding: 20px;
    }
    
    .results-wrapper {
        padding: 20px;
    }
}

/* --- Voice Input & Mega Features Styles --- */
.input-with-mic {
    position: relative;
    display: flex;
    align-items: stretch;
}

.input-with-mic textarea {
    flex: 1;
}

.btn-mic {
    position: absolute;
    bottom: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    z-index: 5;
}

html[dir="rtl"] .btn-mic {
    left: 8px;
}
html[dir="ltr"] .btn-mic {
    right: 8px;
}

.btn-mic:hover {
    color: var(--accent-primary);
    background: rgba(139, 92, 246, 0.1);
}

.btn-mic.recording {
    color: #ef4444;
    animation: pulseMic 1.5s infinite;
}

@keyframes pulseMic {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Mermaid Container */
.mermaid {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    display: flex;
    justify-content: center;
    margin: 20px 0;
    border: 1px solid var(--border-color);
}
/* --- Phase 2 Mega Upgrade Styles --- */
.quiz-container {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 20px;
}

.quiz-score-board {
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
    color: var(--accent-primary);
}

.quiz-question-box {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.quiz-question-text {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-option {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-align: start;
    font-family: inherit;
    color: var(--text-primary);
}

.quiz-option:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--accent-primary);
}

.quiz-option.correct {
    background: rgba(16, 185, 129, 0.2);
    border-color: #10b981;
    color: #a7f3d0;
}

.quiz-option.wrong {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #fecaca;
}

.quiz-feedback {
    margin-top: 10px;
    font-size: 14px;
    font-weight: 500;
}

.quiz-feedback.correct-text {
    color: #10b981;
}

.quiz-feedback.wrong-text {
    color: #ef4444;
}

/* Pre block wrapper for copy button */
.code-block-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.btn-copy-code {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 10;
}

html[dir="ltr"] .btn-copy-code {
    right: 8px;
    left: auto;
}
html[dir="rtl"] .btn-copy-code {
    left: 8px;
    right: auto;
}

.btn-copy-code:hover {
    background: rgba(255, 255, 255, 0.2);
}
