/* =========================================================
   NWC BI Service Request Portal - Styles
   Themes are driven by CSS variables on <html data-theme / data-mode>
   ========================================================= */
:root {
  --primary: #0067b1; --primary-2: #00a3e0; --primary-soft: #e6f2fb; --accent: #00b5ad;
  --bg: #f3f6fa; --surface: #ffffff; --surface-2: #f8fafc; --border: #e3e8ef;
  --text: #1b2a3a; --muted: #6b7a8c; --shadow: 0 2px 10px rgba(16, 42, 67, .06);
  --success: #16a34a; --warning: #f59e0b; --danger: #dc2626; --info: #0ea5e9; --purple: #7c3aed;
  --radius: 14px; --sidebar-w: 260px;
  --font: 'IBM Plex Sans Arabic', 'Inter', system-ui, sans-serif;
}
html[data-theme="teal"]    { --primary: #0f766e; --primary-2: #14b8a6; --primary-soft: #e6f7f5; --accent: #0891b2; }
html[data-theme="emerald"] { --primary: #047857; --primary-2: #10b981; --primary-soft: #e7f8f0; --accent: #65a30d; }
html[data-theme="royal"]   { --primary: #5b21b6; --primary-2: #8b5cf6; --primary-soft: #f1ebfe; --accent: #db2777; }
html[data-theme="sunset"]  { --primary: #c2410c; --primary-2: #f97316; --primary-soft: #fff1e8; --accent: #e11d48; }
html[data-theme="slate"]   { --primary: #334155; --primary-2: #64748b; --primary-soft: #eef1f5; --accent: #0ea5e9; }

html[data-mode="dark"] {
  --bg: #0d1520; --surface: #152232; --surface-2: #1b2b3e; --border: #26384d;
  --text: #e6edf5; --muted: #93a4b8; --shadow: 0 2px 12px rgba(0,0,0,.35);
  --primary-soft: rgba(255,255,255,.06);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; transition: background .25s, color .25s; }
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }
h1, h2, h3, h4 { margin: 0; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-inline-end: 1px solid var(--border);
  position: fixed; inset-block: 0; inset-inline-start: 0; display: flex; flex-direction: column; z-index: 40; transition: transform .25s;
}
.brand { padding: 18px 18px 14px; border-bottom: 1px solid var(--border); text-align: center; }
.brand-logo-wrap { background: #fff; border-radius: 12px; padding: 8px; display: flex; align-items: center; justify-content: center; min-height: 64px; border: 1px solid var(--border); }
.brand-logo { max-height: 56px; max-width: 100%; object-fit: contain; }
.brand-title { margin-top: 10px; font-weight: 700; font-size: 14px; color: var(--primary); }
html[data-mode="dark"] .brand-title { color: var(--primary-2); }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { padding: 12px; flex: 1; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; color: var(--muted);
  font-weight: 500; cursor: pointer; margin-bottom: 4px; transition: all .15s; border: none; background: none; width: 100%; text-align: start; font-size: 14px;
}
.nav-link i { width: 20px; text-align: center; }
.nav-link:hover { background: var(--primary-soft); color: var(--primary); }
.nav-link.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.nav-badge { margin-inline-start: auto; background: var(--danger); color: #fff; border-radius: 20px; font-size: 11px; padding: 1px 8px; }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); text-align: center; }

.main { flex: 1; margin-inline-start: var(--sidebar-w); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 12px 24px;
}
.topbar h1 { font-size: 18px; font-weight: 700; }
.topbar .crumb { font-size: 12px; color: var(--muted); }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; transition: .15s; position: relative;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.lang-btn { width: auto; padding: 0 12px; font-weight: 600; font-size: 13px; gap: 6px; }
.menu-toggle { display: none; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 30px; background: var(--surface-2); border: 1px solid var(--border); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.theme-pop { position: absolute; top: 46px; inset-inline-end: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 12px; width: 220px; display: none; z-index: 50; text-align: start; }
.theme-pop.open { display: block; }
.theme-pop h4 { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }

.content { padding: 24px; max-width: 1500px; margin: 0 auto; }
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(120deg, var(--primary), var(--primary-2)); color: #fff; border-radius: var(--radius);
  padding: 22px 26px; display: flex; align-items: center; gap: 20px; margin-bottom: 20px; position: relative; overflow: hidden;
}
.hero::after { content: ''; position: absolute; width: 280px; height: 280px; border-radius: 50%; background: rgba(255,255,255,.08); inset-inline-end: -60px; top: -120px; }
.hero h2 { font-size: 22px; font-weight: 700; }
.hero p { margin: 6px 0 0; opacity: .9; }
.hero .btn { background: #fff; color: var(--primary); position: relative; z-index: 1; }
.hero-text { flex: 1; position: relative; z-index: 1; }

/* ---------- Cards / Grid ---------- */
.grid { display: grid; gap: 16px; }
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; }
.chart-grid { grid-template-columns: repeat(12, 1fr); }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.card-head h3 { font-size: 15px; font-weight: 600; }
.chart-box { position: relative; height: 280px; }

.kpi { display: flex; gap: 14px; align-items: center; }
.kpi-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
.kpi-val { font-size: 24px; font-weight: 700; line-height: 1.1; }
.kpi-lbl { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi-sub { font-size: 11px; color: var(--muted); }
.ic-blue { background: rgba(14,165,233,.12); color: #0ea5e9; } .ic-green { background: rgba(22,163,74,.12); color: var(--success); }
.ic-amber { background: rgba(245,158,11,.14); color: var(--warning); } .ic-red { background: rgba(220,38,38,.12); color: var(--danger); }
.ic-purple { background: rgba(124,58,237,.12); color: var(--purple); } .ic-primary { background: var(--primary-soft); color: var(--primary); }
html[data-mode="dark"] .ic-primary { color: var(--primary-2); }

/* ---------- Filters ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.filter-bar .field { min-width: 150px; flex: 1; max-width: 220px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 14px; transition: border .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { min-height: 100px; resize: vertical; }
.search-wrap { position: relative; flex: 2; min-width: 200px; }
.search-wrap i { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: 12px; color: var(--muted); }
.search-wrap .input { padding-inline-start: 36px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; font-weight: 600; font-size: 14px; transition: .15s; white-space: nowrap; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: rgba(220,38,38,.1); color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-submitted { background: rgba(100,116,139,.14); color: #64748b; }
.b-review { background: rgba(14,165,233,.14); color: #0284c7; }
.b-approved { background: rgba(99,102,241,.14); color: #4f46e5; }
.b-in_progress { background: rgba(245,158,11,.16); color: #b45309; }
.b-uat { background: rgba(168,85,247,.14); color: #9333ea; }
.b-deployed { background: rgba(20,184,166,.14); color: #0f766e; }
.b-closed { background: rgba(22,163,74,.14); color: #15803d; }
.b-rejected { background: rgba(220,38,38,.12); color: #b91c1c; }
.b-on_hold { background: rgba(120,113,108,.16); color: #78716c; }
.p-critical { background: #dc2626; color: #fff; } .p-high { background: rgba(249,115,22,.16); color: #c2410c; }
.p-medium { background: rgba(14,165,233,.14); color: #0369a1; } .p-low { background: rgba(100,116,139,.14); color: #475569; }
.p-critical::before { background: #fff; }
html[data-mode="dark"] .badge:not(.p-critical) { filter: brightness(1.5); }
.sla-ok { color: var(--success); } .sla-risk { color: var(--warning); } .sla-bad { color: var(--danger); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; min-width: 900px; }
table.data th { text-align: start; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; cursor: pointer; user-select: none; }
table.data td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr { cursor: pointer; transition: background .12s; }
table.data tbody tr:hover { background: var(--primary-soft); }
.req-no { font-family: 'Inter', monospace; font-weight: 600; color: var(--primary); font-size: 13px; }
html[data-mode="dark"] .req-no { color: var(--primary-2); }
.cell-title { font-weight: 600; max-width: 280px; }
.cell-sub { font-size: 12px; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; color: var(--muted); font-size: 13px; flex-wrap: wrap; gap: 8px; }
.pager-btns { display: flex; gap: 6px; }
.empty { text-align: center; padding: 40px; color: var(--muted); }
.empty i { font-size: 34px; margin-bottom: 10px; display: block; opacity: .5; }

/* ---------- Catalog ---------- */
.cat-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { padding: 8px 14px; border-radius: 30px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500; font-size: 13px; color: var(--text); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.service-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.service-card { display: flex; flex-direction: column; gap: 10px; transition: transform .15s, box-shadow .15s; position: relative; }
.service-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.08); }
.svc-top { display: flex; gap: 12px; align-items: flex-start; }
.svc-icon { width: 48px; height: 48px; border-radius: 12px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.svc-code { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .5px; }
.svc-name { font-weight: 700; font-size: 15px; line-height: 1.35; }
.svc-desc { color: var(--muted); font-size: 13px; line-height: 1.6; flex: 1; }
.svc-meta { display: flex; flex-direction: column; gap: 6px; font-size: 12px; background: var(--surface-2); border-radius: 10px; padding: 10px; }
.svc-meta b { color: var(--text); }
.svc-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.svc-count { font-size: 12px; color: var(--muted); }
.svc-edit { position: absolute; top: 12px; inset-inline-end: 12px; opacity: 0; transition: .15s; }
.service-card:hover .svc-edit { opacity: 1; }

/* ---------- Form ---------- */
.form-card { max-width: 1050px; margin: 0 auto; }
.form-section { margin-bottom: 22px; }
.form-section h3 { font-size: 14px; color: var(--primary); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; padding-bottom: 8px; border-bottom: 1px dashed var(--border); }
html[data-mode="dark"] .form-section h3 { color: var(--primary-2); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label.lbl { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
label.lbl .req { color: var(--danger); }
.prio-select { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.prio-opt { border: 1.5px solid var(--border); border-radius: 10px; padding: 10px; text-align: center; cursor: pointer; font-weight: 600; font-size: 13px; transition: .15s; background: var(--surface); }
.prio-opt input { display: none; }
.prio-opt.sel { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
html[data-mode="dark"] .prio-opt.sel { color: var(--primary-2); }
.sla-hint { display: flex; align-items: center; gap: 10px; background: var(--primary-soft); border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.svc-info { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 13px; color: var(--muted); line-height: 1.6; display: none; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 16px; }

/* ---------- SLA Matrix ---------- */
table.sla th, table.sla td { text-align: center; }
table.sla td:first-child, table.sla th:first-child { text-align: start; }
table.sla tbody tr { cursor: default; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 20, 35, .55); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 30px 16px; overflow-y: auto; }
.modal-back.open { display: flex; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 920px; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: fade .2s; }
.modal-sm { max-width: 620px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.kv div span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.kv div b { font-weight: 600; font-size: 13px; }
.block-txt { background: var(--surface-2); border-radius: 10px; padding: 12px; font-size: 13px; line-height: 1.7; margin-bottom: 12px; white-space: pre-wrap; }
.side-panel { background: var(--surface-2); border-radius: 12px; padding: 14px; }
.side-panel h4 { font-size: 13px; margin-bottom: 10px; }

/* Workflow stepper */
.stepper { display: flex; align-items: flex-start; margin: 6px 0 22px; overflow-x: auto; padding-bottom: 4px; }
.step { flex: 1; text-align: center; position: relative; min-width: 80px; }
.step::before { content: ''; position: absolute; top: 15px; inset-inline-start: -50%; width: 100%; height: 3px; background: var(--border); z-index: 0; }
.step:first-child::before { display: none; }
.step .dot { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--border); color: var(--muted); margin: 0 auto 6px; display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; font-size: 12px; }
.step .lbl2 { font-size: 11px; color: var(--muted); }
.step.done::before, .step.current::before { background: var(--primary); }
.step.done .dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.current .dot { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.step.current .lbl2 { color: var(--text); font-weight: 600; }

.timeline { list-style: none; padding: 0; margin: 0; max-height: 240px; overflow-y: auto; }
.timeline li { position: relative; padding-inline-start: 22px; padding-bottom: 12px; font-size: 12px; }
.timeline li::before { content: ''; position: absolute; inset-inline-start: 4px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); }
.timeline li::after { content: ''; position: absolute; inset-inline-start: 8px; top: 15px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .t-when { color: var(--muted); font-size: 11px; }
.stars { display: flex; gap: 4px; font-size: 20px; color: #d1d5db; cursor: pointer; }
.stars i.on { color: #f59e0b; }

/* ---------- Settings ---------- */
.settings-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.theme-swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.swatch { border: 2px solid var(--border); border-radius: 12px; padding: 10px; cursor: pointer; text-align: center; font-size: 12px; font-weight: 600; background: var(--surface); color: var(--text); }
.swatch .sw-color { height: 30px; border-radius: 8px; margin-bottom: 6px; }
.swatch.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.theme-pop .theme-swatches { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.theme-pop .swatch { padding: 5px; font-size: 10px; }
.theme-pop .swatch .sw-color { height: 20px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg button { border: none; background: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--primary); color: #fff; }
.logo-preview { background: #fff; border: 1px dashed var(--border); border-radius: 12px; height: 120px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.logo-preview img { max-height: 90px; max-width: 90%; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 20px; inset-inline-end: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface); border: 1px solid var(--border); border-inline-start: 4px solid var(--success); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); min-width: 240px; display: flex; gap: 10px; align-items: center; animation: fade .2s; }
.toast.err { border-inline-start-color: var(--danger); }

.sidebar-overlay { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .span-8 { grid-column: span 12; }
  .span-4 { grid-column: span 6; }
  .span-4:nth-last-child(4) { grid-column: span 12; } /* SLA gauge full width to keep rows even */
}
@media (max-width: 900px) {
  .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
  .detail-grid { grid-template-columns: 1fr; }
}
table.data td { white-space: nowrap; }
table.data td .cell-title { white-space: normal; min-width: 200px; }
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .main { margin-inline-start: 0; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 10px 14px; }
  .user-chip .u-name, .topbar .crumb { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .prio-select { grid-template-columns: repeat(2, 1fr); }
  .hero { flex-direction: column; align-items: flex-start; }
  .kv { grid-template-columns: 1fr 1fr; }
  .filter-bar .field { max-width: none; min-width: 45%; }
  .topbar h1 { font-size: 15px; }
}
