/* ══════════════════════════════════════════
   AI Video Portal — Arabic RTL UI
   ══════════════════════════════════════════ */

:root {
    --primary:       #6c5ce7;
    --primary-dark:  #5a4bd1;
    --primary-light: #a29bfe;
    --success:       #00b894;
    --warning:       #fdcb6e;
    --danger:        #d63031;
    --bg:            #0d0d14;
    --bg-card:       #13131f;
    --bg-card2:      #10101a;
    --border:        rgba(255,255,255,0.07);
    --text:          #e2e2f0;
    --text-muted:    #7a7a9a;
    --radius:        12px;
    --shadow:        0 2px 20px rgba(0,0,0,0.5);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    direction: rtl;
}

/* ── NAVBAR ── */
.navbar {
    background: rgba(13,13,20,0.96);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    color: white;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-link {
    padding: 7px 14px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.nav-link:hover, .nav-link.active {
    background: rgba(108,92,231,0.12);
    color: var(--primary-light);
}

.nav-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
    flex-shrink: 0;
}

.status-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--danger); }

/* ── LAYOUT ── */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 36px 24px;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light), #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.page-header p { color: var(--text-muted); font-size: 0.95rem; }

.card-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}

.sidebar { display: flex; flex-direction: column; gap: 16px; }

/* ── CARDS ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-muted);
}

.card-desc { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 16px; line-height: 1.6; }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 7px;
    font-size: 0.9rem;
}

.required { color: var(--danger); }
.optional { color: var(--text-muted); font-weight: 400; font-size: 0.82rem; }

.form-control {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 11px 14px;
    color: var(--text);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.92rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    direction: rtl;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}

.form-control::placeholder { color: var(--text-muted); opacity: 0.6; }

.form-control-file {
    width: 100%;
    color: var(--text-muted);
    font-size: 0.88rem;
    padding: 8px 0;
}

.form-hint { font-size: 0.82rem; color: var(--text-muted); margin-top: 8px; }

.font-mono { font-family: 'Courier New', monospace; direction: ltr; text-align: left; }

/* ── DROP ZONE ── */
.drop-zone {
    position: relative;
    border: 1.5px dashed rgba(255,255,255,0.12);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    transition: all 0.15s;
    cursor: pointer;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(108,92,231,0.05);
}

.drop-zone.has-file { border-style: solid; border-color: var(--primary); }

.drop-type-label {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    background: rgba(108,92,231,0.15);
    color: var(--primary-light);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.drop-text { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 4px; }
.drop-hint { font-size: 0.8rem; color: var(--text-muted); opacity: 0.6; }

.image-preview {
    position: relative;
    display: flex;
    justify-content: center;
}

.image-preview img {
    max-height: 180px;
    border-radius: 8px;
    object-fit: cover;
}

.btn-remove {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: 9px;
    border: none;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}

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

.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover { border-color: rgba(255,255,255,0.15); color: var(--text); }

.btn-full { width: 100%; justify-content: center; }
.btn-large { padding: 14px 28px; font-size: 1rem; }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; border-radius: 7px; }

.btn-danger {
    background: rgba(220, 53, 69, 0.15);
    color: #ff6b7a;
    border: 1px solid rgba(220, 53, 69, 0.35);
}
.btn-danger:hover { background: rgba(220, 53, 69, 0.28); border-color: rgba(220, 53, 69, 0.6); }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

.actions-cell { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.btn-link {
    background: none;
    border: none;
    color: var(--primary-light);
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-size: inherit;
    text-decoration: underline;
    padding: 0;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ── INFO / STAGES ── */
.info-list { display: flex; flex-direction: column; gap: 0; margin-bottom: 20px; }

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.info-value { font-weight: 700; color: var(--primary-light); font-size: 0.85rem; }

.stages { display: flex; flex-direction: column; gap: 12px; }

.stage {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.stage-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(108,92,231,0.2);
    color: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
    flex-shrink: 0;
    border: 1px solid rgba(108,92,231,0.3);
}

.stage strong { display: block; font-size: 0.88rem; margin-bottom: 2px; }
.stage p { font-size: 0.78rem; color: var(--text-muted); }

/* ── TIPS ── */
.tips-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.tips-list li {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-right: 18px;
    position: relative;
    line-height: 1.5;
}

.tips-list li::before {
    content: '–';
    position: absolute;
    right: 0;
    color: var(--primary-light);
    font-weight: 700;
}

/* ── HASH BOX ── */
.hash-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.hash-label { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; }

.hash-box code {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--primary-light);
    word-break: break-all;
    flex: 1;
}

.btn-copy {
    background: rgba(108,92,231,0.15);
    border: 1px solid rgba(108,92,231,0.2);
    color: var(--primary-light);
    cursor: pointer;
    font-size: 0.78rem;
    font-family: 'Tajawal', sans-serif;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 5px;
    transition: background 0.15s;
    white-space: nowrap;
}

.btn-copy:hover { background: rgba(108,92,231,0.25); }

/* ── ALERTS ── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.88rem;
    margin-top: 14px;
    line-height: 1.5;
}

.alert-error {
    background: rgba(214,48,49,0.1);
    border: 1px solid rgba(214,48,49,0.25);
    color: #ff7675;
}

.alert-success {
    background: rgba(0,184,148,0.1);
    border: 1px solid rgba(0,184,148,0.25);
    color: #55efc4;
}

/* ── MODAL ── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    text-align: center;
    max-width: 360px;
    width: 90%;
    box-shadow: var(--shadow);
}

.modal-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(108,92,231,0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

.modal-box h3 { margin-bottom: 20px; font-size: 1.05rem; }
.modal-hint { font-size: 0.82rem; color: var(--text-muted); margin-top: 14px; }

/* ── PROGRESS BAR ── */
.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 99px;
    overflow: hidden;
}

.progress-bar.large { height: 10px; }

.progress-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: width 0.5s ease;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 24px 0;
}

.progress-pct {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--primary-light);
    min-width: 40px;
    text-align: left;
}

/* ── JOB STATUS PAGE ── */
.job-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    align-items: start;
}

.status-card { text-align: center; padding: 40px 28px; }

.status-indicator { margin-bottom: 20px; }

.status-spinner {
    width: 56px;
    height: 56px;
    border: 3px solid rgba(108,92,231,0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.status-icon {
    font-size: 3rem;
    line-height: 56px;
}

.status-info { margin-bottom: 8px; }
.status-info h2 { font-size: 1.35rem; margin-bottom: 8px; font-weight: 700; }
.status-stage { color: var(--primary-light); font-size: 0.9rem; }

/* ── TIMELINE ── */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 24px 0;
    text-align: right;
}

.tl-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 11px 0;
    opacity: 0.35;
    transition: opacity 0.3s;
}

.tl-item.active { opacity: 1; }
.tl-item.done { opacity: 0.65; }

.tl-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    margin-top: 5px;
    transition: background 0.3s, box-shadow 0.3s;
}

.tl-item.active .tl-dot {
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.tl-item.done .tl-dot { background: var(--success); }

.tl-content strong { display: block; font-size: 0.92rem; margin-bottom: 2px; }
.tl-content span { font-size: 0.8rem; color: var(--text-muted); }

.job-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 28px;
}

/* ── DETAILS CARD ── */
.details-list { display: flex; flex-direction: column; gap: 16px; }

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.detail-value { font-size: 0.88rem; word-break: break-all; }

/* ── HISTORY TABLE ── */
.jobs-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.jobs-table {
    width: 100%;
    border-collapse: collapse;
}

.jobs-table th, .jobs-table td {
    padding: 14px 20px;
    text-align: right;
    font-size: 0.88rem;
}

.jobs-table th {
    background: rgba(255,255,255,0.03);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.jobs-table tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
.jobs-table tr:hover td { background: rgba(255,255,255,0.015); }

.job-title-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    display: block;
    font-size: 0.9rem;
}

.job-title-link:hover { color: var(--primary-light); }

.job-audio { color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; display: block; }

/* ── BADGES ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-completed { background: rgba(0,184,148,0.12); color: #2dd4bf; border: 1px solid rgba(0,184,148,0.2); }
.badge-processing { background: rgba(108,92,231,0.12); color: var(--primary-light); border: 1px solid rgba(108,92,231,0.2); }
.badge-queued { background: rgba(253,203,110,0.12); color: #fbbf24; border: 1px solid rgba(253,203,110,0.2); }
.badge-failed { background: rgba(214,48,49,0.12); color: #f87171; border: 1px solid rgba(214,48,49,0.2); }

/* ── EMPTY STATE ── */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
}

.empty-graphic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: rgba(108,92,231,0.1);
    border: 1px solid rgba(108,92,231,0.15);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary-light);
    margin-bottom: 20px;
    letter-spacing: 0.5px;
}

.empty-state h3 { font-size: 1.2rem; margin-bottom: 8px; color: var(--text); font-weight: 700; }
.empty-state p { margin-bottom: 24px; font-size: 0.9rem; }

/* ── UTILITIES ── */
.hidden { display: none !important; }
.dir-ltr { direction: ltr; text-align: left; }

/* ── FOOTER ── */
.footer {
    text-align: center;
    padding: 20px 24px;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
    .card-grid, .job-container { grid-template-columns: 1fr; }
    .sidebar { display: contents; }
    .card-main { order: 1; }
}

@media (max-width: 600px) {
    .main-content { padding: 20px 16px; }
    .page-header h1 { font-size: 1.45rem; }
    .nav-inner { gap: 12px; }
    .nav-links { display: none; }
}
