/* ============================================================
   RIGNEX — Integrated Field Operations ERP
   Visual identity: petroleum steel + safety amber
   BY IMAGYNEX
   ============================================================ */

:root {
    /* Core palette — derived from drilling rig / field safety world */
    --steel-950: #0c1117;   /* deep well / night rig */
    --steel-900: #121821;
    --steel-850: #18202b;
    --steel-800: #1e2733;
    --steel-700: #2a3645;
    --steel-600: #3a4a5e;
    --steel-500: #56697f;
    --steel-300: #93a4b8;
    --steel-200: #c2cdda;
    --steel-100: #e6ecf3;

    --amber:      #f5a623;   /* hi-vis safety amber — the signature */
    --amber-dim:  #c8851a;
    --amber-soft: rgba(245,166,35,0.12);

    --teal:       #1fb6a6;   /* gauge / instrument green */
    --teal-soft:  rgba(31,182,166,0.12);

    --crude:      #d9772b;   /* crude / pipe rust accent */
    --danger:     #e25555;
    --danger-soft:rgba(226,85,85,0.12);
    --ok:         #43c478;
    --ok-soft:    rgba(67,196,120,0.12);

    --paper:      #f4f6f9;
    --line:       rgba(255,255,255,0.07);
    --line-strong:rgba(255,255,255,0.12);

    --sidebar-w: 248px;
    --header-h: 62px;
    --radius: 10px;
    --radius-sm: 7px;

    --font-en: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-ar: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

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

/* Global SVG guard — icons never stretch beyond their intended box */
svg { width: 18px; height: 18px; flex-shrink: 0; }

html, body {
    height: 100%;
    background: var(--steel-950);
    color: var(--steel-100);
    font-family: var(--font-en);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
body[dir="rtl"] { font-family: var(--font-ar); }
body[dir="rtl"] .mono-keep { font-family: var(--font-mono); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--steel-900); }
::-webkit-scrollbar-thumb { background: var(--steel-700); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--steel-600); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
}
.login-brandside {
    position: relative;
    background:
        radial-gradient(120% 80% at 0% 0%, rgba(245,166,35,0.10) 0%, transparent 50%),
        linear-gradient(160deg, var(--steel-900) 0%, var(--steel-950) 100%);
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    border-inline-end: 1px solid var(--line);
}
/* subtle rig-derrick line art */
.login-brandside::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(80% 80% at 70% 30%, #000 0%, transparent 75%);
            mask-image: radial-gradient(80% 80% at 70% 30%, #000 0%, transparent 75%);
    opacity: 0.5;
    pointer-events: none;
}
.login-formside {
    background: var(--steel-900);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; margin-bottom: 6px; }
.login-card .sub { color: var(--steel-300); font-size: 13px; margin-bottom: 30px; }

.brand-mark {
    display: flex; align-items: center; gap: 13px;
    position: relative; z-index: 1;
}
.brand-logo {
    width: 46px; height: 46px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--amber) 0%, var(--amber-dim) 100%);
    display: grid; place-items: center;
    box-shadow: 0 6px 20px rgba(245,166,35,0.28);
    flex-shrink: 0;
}
.brand-logo svg { width: 26px; height: 26px; }
.brand-text .name { font-size: 21px; font-weight: 800; letter-spacing: 1px; }
.brand-text .name span { color: var(--amber); }
.brand-text .tg { font-size: 11px; color: var(--steel-300); letter-spacing: 0.3px; margin-top: 1px; }

.brand-hero { position: relative; z-index: 1; }
.brand-hero h2 {
    font-size: 34px; font-weight: 800; line-height: 1.15;
    letter-spacing: -0.8px; max-width: 14ch;
}
.brand-hero h2 em { color: var(--amber); font-style: normal; }
.brand-hero p { color: var(--steel-300); margin-top: 14px; max-width: 42ch; font-size: 14px; }

.brand-stats { display: flex; gap: 34px; position: relative; z-index: 1; }
.brand-stats .stat .n { font-size: 26px; font-weight: 800; color: var(--steel-100); }
.brand-stats .stat .l { font-size: 11px; color: var(--steel-300); letter-spacing: 0.4px; text-transform: uppercase; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--steel-300); margin-bottom: 7px; font-weight: 500; }
.field input, .field select, .field textarea {
    width: 100%;
    background: var(--steel-850);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--steel-100);
    padding: 11px 13px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-soft);
}
.field-row { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 22px; }
.field-row label { display: flex; align-items: center; gap: 7px; color: var(--steel-300); font-size: 13px; cursor: pointer; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 13.5px; font-weight: 600;
    transition: transform .08s, filter .15s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--amber); color: #1a1206; width: 100%; padding: 12px; font-size: 14.5px; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--steel-200); }
.btn-ghost:hover { border-color: var(--steel-500); background: var(--steel-800); }
.btn-soft { background: var(--steel-800); border-color: var(--line-strong); color: var(--steel-100); }
.btn-soft:hover { background: var(--steel-700); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-amber-soft { background: var(--amber-soft); color: var(--amber); border-color: rgba(245,166,35,0.3); }
.btn-amber-soft:hover { background: rgba(245,166,35,0.2); }

.lang-toggle {
    position: absolute; top: 26px; inset-inline-end: 26px; z-index: 5;
    background: var(--steel-850); border: 1px solid var(--line-strong);
    border-radius: 20px; padding: 7px 15px; font-size: 12.5px; font-weight: 600;
    color: var(--steel-200); display: inline-flex; align-items: center; gap: 7px;
}
.lang-toggle:hover { border-color: var(--amber); color: var(--amber); }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
    background: var(--steel-900);
    border-inline-end: 1px solid var(--line);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-head { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.sidebar-nav { padding: 12px 12px 20px; flex: 1; }
.nav-group { font-size: 10.5px; letter-spacing: 1px; color: var(--steel-500); font-weight: 700; padding: 16px 12px 7px; }
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--steel-300); font-size: 13.5px; font-weight: 500;
    margin-bottom: 2px; transition: background .12s, color .12s;
    position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: var(--steel-800); color: var(--steel-100); }
.nav-item.active { background: var(--amber-soft); color: var(--amber); }
.nav-item.active::before {
    content: ""; position: absolute; inset-inline-start: 0; top: 8px; bottom: 8px;
    width: 3px; border-radius: 3px; background: var(--amber);
}
.nav-badge {
    margin-inline-start: auto; background: var(--steel-700); color: var(--steel-200);
    font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 10px;
}
.nav-item.active .nav-badge { background: var(--amber); color: #1a1206; }

/* ---- Header ---- */
.main-col { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: var(--header-h);
    background: rgba(18,24,33,0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 16px;
    padding: 0 22px;
    position: sticky; top: 0; z-index: 40;
}
.topbar .crumbs { font-size: 13px; color: var(--steel-300); }
.topbar .crumbs b { color: var(--steel-100); font-weight: 600; }
.searchbox {
    margin-inline-start: auto;
    display: flex; align-items: center; gap: 8px;
    background: var(--steel-850); border: 1px solid var(--line-strong);
    border-radius: 20px; padding: 7px 14px; min-width: 220px;
}
.searchbox input { background: none; border: none; color: var(--steel-100); font-size: 13px; width: 100%; outline: none; }
.searchbox svg { width: 15px; height: 15px; color: var(--steel-500); }
.topbar-icon {
    width: 36px; height: 36px; border-radius: 9px;
    display: grid; place-items: center; background: var(--steel-850);
    border: 1px solid var(--line-strong); color: var(--steel-300);
    position: relative;
}
.topbar-icon:hover { color: var(--amber); border-color: var(--amber); }
.topbar-icon .dot { position: absolute; top: 8px; inset-inline-end: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.avatar {
    width: 36px; height: 36px; border-radius: 9px;
    background: linear-gradient(135deg, var(--teal), #178f83);
    display: grid; place-items: center; font-weight: 700; color: #04201d; font-size: 13px;
}

/* ---- Content ---- */
.content { padding: 26px; flex: 1; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .titles h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.page-head .titles p { color: var(--steel-300); font-size: 13.5px; margin-top: 4px; max-width: 70ch; }
.page-head .actions { margin-inline-start: auto; display: flex; gap: 9px; flex-wrap: wrap; }

.demo-banner {
    display: flex; align-items: center; gap: 10px;
    background: var(--amber-soft); border: 1px solid rgba(245,166,35,0.25);
    color: var(--amber); border-radius: var(--radius-sm);
    padding: 9px 14px; font-size: 12.5px; margin-bottom: 20px;
}
.demo-banner svg { width: 16px; height: 16px; flex-shrink: 0; }
.big-icon svg, svg.big-icon { width: 40px; height: 40px; opacity: .4; }

/* ---- KPI cards ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi {
    background: var(--steel-900); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px;
    position: relative; overflow: hidden;
}
.kpi::after {
    content: ""; position: absolute; top: 0; inset-inline-start: 0; width: 3px; height: 100%;
    background: var(--accent, var(--amber));
}
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi .kpi-icn { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft, var(--amber-soft)); color: var(--accent, var(--amber)); }
.kpi .kpi-icn svg { width: 19px; height: 19px; }
.kpi .kpi-trend { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); }
.kpi .kpi-trend.down { background: var(--danger-soft); color: var(--danger); }
.kpi .kpi-val { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.kpi .kpi-label { font-size: 12.5px; color: var(--steel-300); margin-top: 2px; }

/* ---- Cards / panels ---- */
.panel { background: var(--steel-900); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-head h3 { font-size: 15px; font-weight: 700; }
.panel-head .panel-actions { margin-inline-start: auto; display: flex; gap: 8px; }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 1000px){ .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---- Tables ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
    text-align: start; font-size: 11px; letter-spacing: .5px; text-transform: uppercase;
    color: var(--steel-500); font-weight: 700; padding: 12px 16px;
    border-bottom: 1px solid var(--line); background: var(--steel-850);
}
.tbl tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line); color: var(--steel-200); }
.tbl tbody tr:hover { background: var(--steel-850); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .jobid { font-family: var(--font-mono); color: var(--amber); font-weight: 600; font-size: 12.5px; }

.chip {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 20px;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.draft { background: var(--steel-800); color: var(--steel-300); }
.chip.pending { background: var(--amber-soft); color: var(--amber); }
.chip.approved { background: var(--ok-soft); color: var(--ok); }
.chip.dispatched { background: var(--teal-soft); color: var(--teal); }
.chip.completed { background: rgba(86,105,127,0.18); color: var(--steel-200); }
.chip.returned { background: var(--danger-soft); color: var(--danger); }

.row-actions { display: flex; gap: 6px; }
.icon-btn {
    width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center;
    background: var(--steel-800); border: 1px solid var(--line-strong); color: var(--steel-300);
}
.icon-btn:hover { color: var(--amber); border-color: var(--amber); }
.icon-btn svg { width: 15px; height: 15px; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 18px; overflow-x: auto; }
.tab {
    padding: 13px 14px; font-size: 13px; font-weight: 600; color: var(--steel-300);
    border-bottom: 2px solid transparent; white-space: nowrap; background: none; border-top: none; border-inline: none;
}
.tab:hover { color: var(--steel-100); }
.tab.active { color: var(--amber); border-bottom-color: var(--amber); }
.tab .cnt { margin-inline-start: 6px; font-size: 11px; background: var(--steel-800); padding: 1px 7px; border-radius: 9px; color: var(--steel-300); }
.tab.active .cnt { background: var(--amber-soft); color: var(--amber); }

/* ---- Traceability chain ---- */
.chain { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: 4px; }
.chain-node {
    flex: 1; min-width: 110px; text-align: center; padding: 14px 8px;
    position: relative;
}
.chain-node:not(:last-child)::after {
    content: ""; position: absolute; top: 28px; inset-inline-end: -6px;
    width: 12px; height: 2px; background: var(--steel-600);
}
body[dir="rtl"] .chain-node:not(:last-child)::after { transform: scaleX(-1); }
.chain-dot {
    width: 38px; height: 38px; border-radius: 11px; margin: 0 auto 9px;
    display: grid; place-items: center; background: var(--steel-800);
    border: 1px solid var(--line-strong); color: var(--steel-300);
}
.chain-dot svg { width: 18px; height: 18px; }
.chain-node.done .chain-dot { background: var(--ok-soft); color: var(--ok); border-color: rgba(67,196,120,0.3); }
.chain-node.active .chain-dot { background: var(--amber); color: #1a1206; border-color: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }
.chain-node .lbl { font-size: 11.5px; color: var(--steel-300); }
.chain-node.active .lbl { color: var(--amber); font-weight: 600; }

/* ---- Integration cards ---- */
.integ-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.integ-card {
    background: var(--steel-900); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px; display: flex; flex-direction: column; gap: 14px;
    transition: border-color .15s, transform .1s;
}
.integ-card:hover { border-color: var(--steel-600); }
.integ-card .ic-top { display: flex; align-items: center; gap: 12px; }
.integ-logo {
    width: 48px; height: 48px; border-radius: 11px; display: grid; place-items: center;
    font-weight: 800; font-size: 17px; color: #fff; flex-shrink: 0;
}
.integ-card .ic-name { font-weight: 700; font-size: 15px; }
.integ-card .ic-type { font-size: 12px; color: var(--steel-300); }
.integ-card .ic-stat { margin-inline-start: auto; }
.integ-meter { height: 6px; border-radius: 4px; background: var(--steel-800); overflow: hidden; }
.integ-meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--amber)); }
.integ-card .ic-foot { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--steel-300); }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(6,9,13,0.72);
    backdrop-filter: blur(3px); z-index: 100;
    display: none; align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--steel-900); border: 1px solid var(--line-strong);
    border-radius: 14px; width: 100%; max-width: 620px; max-height: 88vh;
    overflow: hidden; display: flex; flex-direction: column;
    box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-head .close { margin-inline-start: auto; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--steel-800); color: var(--steel-300); border: 1px solid var(--line-strong); }
.modal-head .close:hover { color: var(--danger); border-color: var(--danger); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px){ .form-grid { grid-template-columns: 1fr; } }

/* ---- Footer ---- */
.app-footer {
    text-align: center; padding: 16px; font-size: 11px; letter-spacing: 2px;
    color: var(--steel-500); border-top: 1px solid var(--line); font-weight: 700;
}
.app-footer span { color: var(--amber); }

/* ---- Toast ---- */
.toast-wrap { position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--steel-800); border: 1px solid var(--line-strong);
    border-inline-start: 3px solid var(--amber);
    border-radius: 9px; padding: 12px 16px; font-size: 13px; min-width: 240px;
    display: flex; align-items: center; gap: 10px;
    animation: slideIn .25s ease;
    box-shadow: 0 12px 30px rgba(0,0,0,0.4);
}
.toast svg { width: 17px; height: 17px; color: var(--amber); flex-shrink: 0; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Mini info rows ---- */
.info-list { display: flex; flex-direction: column; gap: 0; }
.info-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--steel-300); }
.info-row .v { color: var(--steel-100); font-weight: 600; }

/* ---- Responsive ---- */
@media (max-width: 900px){
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; inset-inline-start: -260px; z-index: 90; transition: inset-inline-start .25s; width: 248px; }
    .sidebar.open { inset-inline-start: 0; }
    .login-wrap { grid-template-columns: 1fr; }
    .login-brandside { display: none; }
}
.menu-btn { display: none; width: 36px; height: 36px; border-radius: 9px; place-items: center; background: var(--steel-850); border: 1px solid var(--line-strong); color: var(--steel-200); }
@media (max-width: 900px){ .menu-btn { display: grid; } }
