/* Dragon Transcoder V2 - shared design system. One file, no per-page overrides
   unless a module genuinely needs one. RTL Arabic first; use .ltr for IPs/paths/
   logs/code. */

:root {
    --bg: #0d0f14;
    --surface-1: #14171d;
    --surface-2: #1a1e26;
    --surface-3: #232833;

    --text-primary: #e8eaed;
    --text-secondary: #a8adb8;
    --text-muted: #6b7280;

    --border: #262b35;
    --border-strong: #333a47;

    --accent: #ff5a36;
    --accent-hover: #ff7452;
    --accent-soft: rgba(255, 90, 54, .14);

    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, .14);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, .14);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, .14);
    --info: #38bdf8;
    --info-soft: rgba(56, 189, 248, .14);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow: 0 8px 24px rgba(0, 0, 0, .35);

    --sidebar-w: 264px;
    --sidebar-w-collapsed: 72px;
    --topbar-h: 60px;

    --font: 'Segoe UI', Tahoma, 'Cairo', Arial, sans-serif;
    --font-mono: 'Consolas', 'SFMono-Regular', Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
}

body { min-height: 100vh; }

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; }

.ltr {
    direction: ltr;
    unicode-bidi: isolate;
    font-family: var(--font-mono);
    font-size: 13px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-1); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }

/* ---------- App shell ---------- */

.dt-shell { display: flex; min-height: 100vh; }

.dt-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface-1);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width .15s ease;
}
.dt-shell.is-collapsed .dt-sidebar { width: var(--sidebar-w-collapsed); }

.dt-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    height: var(--topbar-h);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.dt-sidebar-brand img { width: 28px; height: 28px; border-radius: var(--radius-sm); }
.dt-sidebar-brand-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; }
.dt-shell.is-collapsed .dt-sidebar-brand-name { display: none; }

.dt-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.dt-nav-group { margin-bottom: 4px; }
.dt-nav-group-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    padding: 12px 10px 6px;
    font-weight: 600;
}
.dt-shell.is-collapsed .dt-nav-group-label { display: none; }

.dt-nav-link, .dt-nav-parent {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13.5px;
    cursor: pointer;
    white-space: nowrap;
}
.dt-nav-link:hover, .dt-nav-parent:hover { background: var(--surface-2); color: var(--text-primary); }
.dt-nav-link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dt-nav-link .icon, .dt-nav-parent .icon { width: 18px; height: 18px; flex-shrink: 0; }
.dt-nav-children { padding-inline-start: 26px; display: none; }
.dt-nav-group.is-open .dt-nav-children { display: block; }
.dt-nav-parent .chev { margin-inline-start: auto; transition: transform .12s; width: 14px; height: 14px; }
.dt-nav-group.is-open .dt-nav-parent .chev { transform: rotate(90deg); }
.dt-nav-link.is-disabled { opacity: .45; cursor: not-allowed; }
.dt-nav-link.is-disabled:hover { background: none; color: var(--text-secondary); }
.dt-nav-soon { margin-inline-start: auto; font-size: 10px; color: var(--text-muted); border: 1px solid var(--border-strong); border-radius: 999px; padding: 1px 6px; }

.dt-sidebar-toggle {
    border-top: 1px solid var(--border);
    padding: 10px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
}
.dt-sidebar-toggle:hover { color: var(--text-primary); background: var(--surface-2); }

.dt-main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.dt-topbar {
    height: var(--topbar-h);
    border-bottom: 1px solid var(--border);
    background: var(--surface-1);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 14px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 20;
}
.dt-topbar-title { font-weight: 700; font-size: 15px; }
.dt-breadcrumbs { color: var(--text-muted); font-size: 12.5px; display: flex; gap: 6px; align-items: center; }
.dt-breadcrumbs a:hover { color: var(--text-secondary); }
.dt-topbar-spacer { flex: 1; }
.dt-topbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.dt-topbar-user .role { color: var(--text-muted); font-size: 11.5px; }
.dt-worker-pill {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
    color: var(--text-secondary); border: 1px solid var(--border); border-radius: 999px;
    padding: 4px 10px;
}
.dt-worker-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.dt-worker-pill.is-active .dot { background: var(--success); }

.dt-content { flex: 1; padding: 22px; }
.dt-footer { padding: 14px 22px; color: var(--text-muted); font-size: 12px; border-top: 1px solid var(--border); }

.dt-mobile-toggle { display: none; }
.dt-sidebar-overlay { display: none; }

/* ---------- Dropdown (topbar user menu, table row actions) ---------- */

.dt-dropdown { position: relative; }
.dt-dropdown-menu {
    display: none; position: absolute; inset-inline-end: 0; top: calc(100% + 6px);
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
    box-shadow: var(--shadow); min-width: 180px; z-index: 30; overflow: hidden;
}
.dt-dropdown.is-open .dt-dropdown-menu { display: block; }
.dt-dropdown-item {
    display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 13px;
    color: var(--text-secondary); cursor: pointer; width: 100%; background: none; border: none; text-align: start;
}
.dt-dropdown-item:hover { background: var(--surface-3); color: var(--text-primary); }

@media (max-width: 900px) {
    .dt-sidebar {
        position: fixed; inset-inline-start: 0; top: 0; bottom: 0; z-index: 40;
        transform: translateX(110%);
    }
    html[dir="rtl"] .dt-sidebar { transform: translateX(-110%); }
    .dt-shell.is-drawer-open .dt-sidebar { transform: none; }
    .dt-shell.is-drawer-open .dt-sidebar-overlay {
        display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 39;
    }
    .dt-mobile-toggle { display: inline-flex; }
    .dt-content { padding: 14px; }
}

/* ---------- Page header ---------- */

.dt-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.dt-page-title { font-size: 19px; font-weight: 700; margin: 0 0 4px; }
.dt-page-subtitle { color: var(--text-muted); font-size: 13px; }
.dt-page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- Cards / stat tiles ---------- */

.dt-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
}
.dt-card + .dt-card { margin-top: 16px; }
.dt-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dt-card-title { font-weight: 700; font-size: 14.5px; }

.dt-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 900px) { .dt-stat-grid { grid-template-columns: repeat(2, 1fr); } }
.dt-stat {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 16px; display: flex; flex-direction: column; gap: 6px;
}
.dt-stat-label { color: var(--text-muted); font-size: 12px; }
.dt-stat-value { font-size: 24px; font-weight: 700; }
.dt-stat.is-accent .dt-stat-value { color: var(--accent); }
.dt-stat.is-success .dt-stat-value { color: var(--success); }
.dt-stat.is-warning .dt-stat-value { color: var(--warning); }
.dt-stat.is-danger .dt-stat-value { color: var(--danger); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
    border: 1px solid transparent; cursor: pointer; line-height: 1.3;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-3); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--border-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn .icon { width: 15px; height: 15px; }

/* ---------- Badges / alerts ---------- */

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--surface-3); color: var(--text-muted); }

.alert { padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid transparent; font-size: 13px; margin-bottom: 14px; }
.alert-success { background: var(--success-soft); border-color: rgba(34,197,94,.3); color: var(--success); }
.alert-warning { background: var(--warning-soft); border-color: rgba(245,158,11,.3); color: var(--warning); }
.alert-danger { background: var(--danger-soft); border-color: rgba(239,68,68,.3); color: var(--danger); }
.alert-info { background: var(--info-soft); border-color: rgba(56,189,248,.3); color: var(--info); }

/* ---------- Tables ---------- */

.dt-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.dt-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dt-table th, .dt-table td { padding: 11px 14px; text-align: start; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dt-table th { color: var(--text-muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-1); }
.dt-table tbody tr:hover { background: var(--surface-3); }
.dt-table tbody tr:last-child td { border-bottom: none; }
.dt-table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.dt-table-search { display: flex; align-items: center; gap: 8px; }

/* ---------- Forms ---------- */

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-inline-start: 3px; }
.form-help { color: var(--text-muted); font-size: 12px; margin-top: 5px; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 5px; }
.form-control {
    width: 100%; background: var(--surface-1); border: 1px solid var(--border-strong);
    color: var(--text-primary); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13.5px;
    font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-control.has-error { border-color: var(--danger); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

.form-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.form-switch input { display: none; }
.form-switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: background .15s; }
.form-switch .track::after { content: ''; position: absolute; top: 1px; inset-inline-start: 1px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-muted); transition: .15s; }
.form-switch input:checked + .track { background: var(--accent-soft); border-color: var(--accent); }
.form-switch input:checked + .track::after { background: var(--accent); inset-inline-start: 17px; }

/* ---------- Tabs ---------- */

.dt-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.dt-tab { padding: 10px 4px; margin-inline-end: 20px; color: var(--text-muted); font-size: 13.5px; font-weight: 600; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.dt-tab:hover { color: var(--text-primary); }
.dt-tab.is-active { color: var(--accent); border-color: var(--accent); }

/* ---------- Modal / toast ---------- */

.dt-modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none;
    align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.dt-modal-backdrop.is-open { display: flex; }
.dt-modal { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 460px; box-shadow: var(--shadow); }
.dt-modal-header { padding: 16px 18px; border-bottom: 1px solid var(--border); font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.dt-modal-body { padding: 18px; font-size: 13.5px; color: var(--text-secondary); }
.dt-modal-footer { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.dt-modal-close { cursor: pointer; color: var(--text-muted); background: none; border: none; font-size: 18px; }

.dt-toast-stack { position: fixed; bottom: 20px; inset-inline-end: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; width: min(340px, 90vw); }
.dt-toast {
    background: var(--surface-2); border: 1px solid var(--border); border-inline-start: 3px solid var(--info);
    border-radius: var(--radius-md); padding: 12px 14px; font-size: 13px; box-shadow: var(--shadow);
    animation: dt-toast-in .15s ease;
}
.dt-toast.is-success { border-inline-start-color: var(--success); }
.dt-toast.is-warning { border-inline-start-color: var(--warning); }
.dt-toast.is-danger { border-inline-start-color: var(--danger); }
@keyframes dt-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Empty / error / loading / skeleton ---------- */

.dt-empty { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.dt-empty .icon { width: 40px; height: 40px; margin: 0 auto 12px; opacity: .5; }

.dt-error-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.dt-error-code { font-size: 56px; font-weight: 800; color: var(--accent); }
.dt-error-title { color: var(--text-secondary); margin-bottom: 12px; }

.dt-skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: dt-skeleton 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes dt-skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.dt-progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.dt-progress > span { display: block; height: 100%; background: var(--accent); }

.dt-pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.dt-pagination a, .dt-pagination span { padding: 6px 11px; border-radius: var(--radius-sm); font-size: 13px; color: var(--text-secondary); border: 1px solid var(--border); }
.dt-pagination a:hover { background: var(--surface-3); }
.dt-pagination .is-active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Auth page ---------- */

.dt-auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 0%, #1b1410 0%, var(--bg) 55%); padding: 20px; }
.dt-auth-card { width: 100%; max-width: 380px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 30px; box-shadow: var(--shadow); }
.dt-auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.dt-auth-brand img { width: 46px; height: 46px; }
.dt-auth-brand-name { font-weight: 800; font-size: 17px; }

/* ---------- Utilities ---------- */

.u-flex { display: flex; }
.u-gap-8 { gap: 8px; }
.u-items-center { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-text-muted { color: var(--text-muted); }
.u-text-secondary { color: var(--text-secondary); }
.u-mt-0 { margin-top: 0; }
.u-w-full { width: 100%; }
