/* === Subtitle Translator — Dark Theme === */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2332;
    --bg-input: #0d1321;
    --border: #1e3a5f;
    --border-light: #2a4a6f;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59,130,246,0.3);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --gold: #fbbf24;
    --purple: #a855f7;
    --gradient-1: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --gradient-2: linear-gradient(135deg, #06b6d4, #3b82f6);
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    direction: rtl;
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* === Layout === */
.app-container { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    z-index: 100;
}
.main-content {
    flex: 1;
    margin-right: 260px;
    padding: 24px;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}
.sidebar-logo {
    font-size: 1.4rem;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.sidebar-nav { flex: 1; padding: 12px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    margin-bottom: 4px;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: var(--accent); color: white; }
.nav-item svg { width: 20px; height: 20px; }
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}
.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}
.btn-primary {
    background: var(--gradient-1);
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* === Forms === */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
    direction: ltr;
    text-align: left;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-textarea { min-height: 100px; resize: vertical; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* === Tables === */
.table-container { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
th, td {
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}
th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
tr:hover { background: rgba(59,130,246,0.05); }

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* === Tags & Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--accent); }

/* === Toggle Switch === */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    display: inline-block;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    top: 2px; right: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}
.toggle input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}
.toggle input:checked + .toggle-slider::before {
    transform: translateX(-20px);
    background: white;
}

/* === Login Page === */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.login-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 0.9rem;
}
.login-error {
    background: rgba(239,68,68,0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.85rem;
    display: none;
}

/* === Editor Layout === */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: calc(100vh - 180px);
}
.editor-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.editor-panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
}
.editor-panel-title {
    font-weight: 600;
    font-size: 0.95rem;
}
.editor-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* === Subtitle Block === */
.subtitle-block {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: start;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: var(--transition);
    background: var(--bg-input);
}
.subtitle-block:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-glow);
}
.subtitle-block.translated {
    border-color: var(--success);
}
.block-index {
    background: var(--accent);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.block-content { min-width: 0; }
.block-timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    margin-bottom: 4px;
    direction: ltr;
    text-align: left;
}
.block-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    word-wrap: break-word;
}
.block-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

/* === Upload Zone === */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    background: rgba(59,130,246,0.05);
}
.upload-icon { font-size: 3rem; margin-bottom: 12px; }
.upload-text { color: var(--text-secondary); }
.upload-formats { font-size: 0.75rem; color: var(--text-muted); margin-top: 8px; }

/* === Modal === */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: var(--transition);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 20px;
}

/* === Progress Bar === */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0;
}
.progress-fill {
    height: 100%;
    background: var(--gradient-1);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* === Toolbar === */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.toolbar-separator {
    width: 1px;
    height: 24px;
    background: var(--border);
}

/* === Toast === */
.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: var(--accent); color: white; }

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

/* === Loading Spinner === */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Responsive === */
@media (max-width: 1024px) {
    .sidebar { width: 70px; }
    .sidebar .nav-text, .sidebar-header .sidebar-logo, .sidebar-footer { display: none; }
    .nav-item { justify-content: center; padding: 12px; }
    .main-content { margin-right: 70px; }
    .editor-container { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .sidebar { display: none; }
    .main-content { margin-right: 0; }
    .stats-grid { grid-template-columns: 1fr; }
}
