/* Smart Core — Operations UI, Odoo-flavored (light theme, purple accent,
   control panel + list/form views with a statusbar). RTL Arabic. */
:root {
  /* Trust-blue brand palette (confident, professional). The legacy --o-purple*
     names are kept as aliases so every existing rule reskins automatically. */
  --o-primary: #1766c4;
  --o-primary-d: #11508f;
  --o-primary-l: #e8f1fc;
  --o-purple: var(--o-primary);
  --o-purple-d: var(--o-primary-d);
  --o-purple-l: var(--o-primary-l);
  --o-accent: #017e84;        /* teal action accent */
  --o-bg: #f0f0f0;
  --o-panel: #ffffff;
  --o-text: #374151;
  --o-muted: #8f8f8f;
  --o-line: #dcdcdc;
  --o-line-soft: #ebebeb;
  --o-hover: #f5f5f5;
  --o-green: #28a745;
  --o-blue: #2f7de1;
  --o-red: #d9534f;
  --o-amber: #b58a00;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Tajawal", "Roboto", system-ui, -apple-system, sans-serif;
  background: var(--o-bg);
  color: var(--o-text);
  font-size: 14px;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
a { color: var(--o-purple); text-decoration: none; }

/* ---------- Login ---------- */
.o-login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1766c4, #0f447e); padding: 24px; }
.o-login-card { width: min(420px, 100%); background: #fff; border-radius: 8px; box-shadow: 0 18px 50px rgba(0,0,0,.25); padding: 32px; }
.o-login-card .o-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.o-login-card h1 { font-size: 22px; margin: 0 0 4px; color: #111; }
.o-login-card .o-sub { color: var(--o-muted); margin: 0 0 22px; font-size: 13px; }
.o-login-card label { display: block; font-weight: 700; font-size: 13px; color: #555; margin-bottom: 6px; }
.o-login-card input { width: 100%; border: 1px solid var(--o-line); border-radius: 4px; padding: 10px 12px; margin-bottom: 16px; }
.o-login-card input:focus { outline: none; border-color: var(--o-purple); box-shadow: 0 0 0 3px rgba(113,75,103,.12); }
.o-login-msg { color: var(--o-red); font-weight: 700; min-height: 20px; font-size: 13px; }

/* ---------- App shell ---------- */
.o-navbar { height: 46px; background: var(--o-purple); color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 14px; position: sticky; top: 0; z-index: 30; }
.o-navbar .o-brand-mark { width: 28px; height: 28px; border-radius: 7px; display: block; }
.o-navbar .o-app-name { font-weight: 700; }
.o-navbar .o-home { display: flex; align-items: center; gap: 10px; color: #fff; }
.o-navbar .o-home:hover { opacity: .9; }
.o-navbar .o-homebtn { display: inline-flex; align-items: center; gap: 6px; color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 4px; padding: 4px 10px; font-size: 13px; font-weight: 700; }
.o-navbar .o-homebtn:hover { background: rgba(255,255,255,.14); }
.o-navbar .o-homebtn svg { display: block; }
.o-navbar .o-bc { opacity: .85; font-size: 13px; }
.o-navbar .o-spacer { margin-inline-start: auto; }
.o-navbar .o-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.o-navbar .o-user button { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 4px; padding: 4px 10px; font-size: 12px; }
.o-navbar .o-user button:hover { background: rgba(255,255,255,.12); }

.o-app { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 46px); }
.o-sidebar { background: #fafafa; border-inline-end: 1px solid var(--o-line); padding: 10px 8px; }
.o-menu-label { color: var(--o-muted); font-size: 11px; font-weight: 800; padding: 8px 10px 4px; letter-spacing: .4px; }
.o-menu-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: start; background: transparent; border: 0; border-radius: 4px; padding: 9px 11px; color: var(--o-text); font-weight: 600; }
.o-menu-item:hover { background: var(--o-hover); }
.o-menu-item.active { background: var(--o-purple-l); color: var(--o-purple); font-weight: 800; }
.o-ic { display: inline-flex; align-items: center; }
.o-ic svg { display: block; }
.o-bc-title .o-ic { color: var(--o-purple); }

.o-main { min-width: 0; display: flex; flex-direction: column; }

/* ---------- Control panel ---------- */
.o-cp { background: var(--o-panel); border-bottom: 1px solid var(--o-line); padding: 8px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; position: sticky; top: 46px; z-index: 20; }
.o-cp .o-bc-title { font-size: 18px; font-weight: 700; color: #111; display: flex; align-items: center; gap: 6px; }
.o-cp .o-bc-title .o-sep { color: var(--o-muted); font-weight: 400; }
.o-cp .o-bc-title .o-rec { color: var(--o-purple); }
.o-cp .o-cp-actions { display: flex; align-items: center; gap: 8px; }
.o-cp .o-spacer { margin-inline-start: auto; }
.o-search { display: flex; align-items: center; gap: 6px; border: 1px solid var(--o-line); border-radius: 4px; padding: 5px 9px; background: #fff; min-width: 200px; }
.o-search input { border: 0; outline: none; flex: 1; background: transparent; }
.o-search .o-ic { color: var(--o-muted); }
.o-pager { display: flex; align-items: center; gap: 4px; color: #555; font-size: 13px; white-space: nowrap; }
.o-pager button { background: #fff; border: 1px solid var(--o-line); border-radius: 4px; width: 26px; height: 26px; line-height: 1; color: #555; }
.o-pager button:hover:not(:disabled) { background: var(--o-hover); }
.o-pager button:disabled { opacity: .4; cursor: default; }

/* ---------- Buttons ---------- */
.o-btn { border: 1px solid transparent; border-radius: 4px; padding: 6px 14px; font-weight: 700; font-size: 13px; }
.o-btn-primary { background: var(--o-purple); color: #fff; }
.o-btn-primary:hover { background: var(--o-purple-d); }
.o-btn-secondary { background: #fff; color: var(--o-purple); border-color: var(--o-purple); }
.o-btn-secondary:hover { background: var(--o-purple-l); }
.o-btn-default { background: #fff; color: #444; border-color: var(--o-line); }
.o-btn-default:hover { background: var(--o-hover); }
.o-btn:disabled { opacity: .5; cursor: not-allowed; }
.o-btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---------- List view ---------- */
.o-content { padding: 0; overflow: auto; flex: 1; }
.o-list-wrap { background: var(--o-panel); }
.o-list { width: 100%; border-collapse: collapse; }
.o-list thead th { text-align: start; font-size: 12px; font-weight: 800; color: #555; background: #f7f7f7; border-bottom: 1px solid var(--o-line); padding: 9px 12px; white-space: nowrap; position: sticky; top: 0; }
.o-list tbody td { padding: 9px 12px; border-bottom: 1px solid var(--o-line-soft); }
.o-list tbody tr { cursor: pointer; }
.o-list tbody tr:hover { background: var(--o-purple-l); }
.o-list .o-ref { font-weight: 700; color: var(--o-purple); }
.o-list .o-num { text-align: start; font-variant-numeric: tabular-nums; }
.o-empty { padding: 40px 16px; text-align: center; color: var(--o-muted); }

/* status badges */
.o-badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 12px; padding: 2px 10px; font-size: 12px; font-weight: 800; border: 1px solid; }
.o-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.o-badge.draft { color: var(--o-muted); border-color: #d4d4d4; background: #f3f3f3; }
.o-badge.confirmed { color: var(--o-blue); border-color: #bcd8f5; background: #eaf2fc; }
.o-badge.received, .o-badge.delivered, .o-badge.done { color: var(--o-green); border-color: #bfe3c8; background: #ecf7ee; }
.o-badge.cancelled { color: var(--o-red); border-color: #f0c6c4; background: #fbecec; }

/* ---------- Form view ---------- */
.o-form-wrap { padding: 16px; }
.o-form { background: var(--o-panel); border: 1px solid var(--o-line); border-radius: 6px; max-width: 1100px; margin: 0 auto; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.o-form-header { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--o-line); flex-wrap: wrap; }
.o-form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.o-form-header .o-spacer { margin-inline-start: auto; }

/* statusbar pipeline */
.o-statusbar { display: flex; align-items: stretch; border: 1px solid var(--o-line); border-radius: 4px; overflow: hidden; }
.o-status-step { padding: 5px 16px 5px 22px; font-size: 12px; font-weight: 700; color: var(--o-muted); background: #fff; position: relative; display: flex; align-items: center; }
.o-status-step + .o-status-step { border-inline-start: 1px solid var(--o-line); }
.o-status-step.done { color: #555; }
.o-status-step.current { background: var(--o-purple); color: #fff; }
.o-status-step.cancelled { background: var(--o-red); color: #fff; }

.o-form-sheet { padding: 18px 22px; }
.o-form-title { font-size: 24px; font-weight: 800; color: #111; margin: 0 0 4px; }
.o-form-subtitle { color: var(--o-muted); margin: 0 0 18px; font-size: 13px; }
.o-group { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 36px; margin-bottom: 14px; }
.o-field { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--o-line-soft); }
.o-field > label { color: #555; font-weight: 700; font-size: 13px; }
.o-field input, .o-field select { width: 100%; border: 1px solid transparent; border-radius: 4px; padding: 6px 8px; background: transparent; }
.o-field input:hover, .o-field select:hover { border-color: var(--o-line); }
.o-field input:focus, .o-field select:focus { outline: none; border-color: var(--o-purple); background: #fff; box-shadow: 0 0 0 2px rgba(113,75,103,.1); }

/* notebook / lines */
.o-notebook { margin-top: 8px; }
.o-notebook-tab { display: inline-block; padding: 8px 14px; border-bottom: 2px solid var(--o-purple); font-weight: 800; color: var(--o-purple); }
.o-line-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.o-line-table th { text-align: start; font-size: 12px; color: #777; font-weight: 700; border-bottom: 1px solid var(--o-line); padding: 7px 8px; }
.o-line-table td { border-bottom: 1px solid var(--o-line-soft); padding: 3px 8px; }
.o-line-table input, .o-line-table select { width: 100%; border: 1px solid transparent; border-radius: 4px; padding: 6px 6px; background: transparent; }
.o-line-table input:hover, .o-line-table select:hover { border-color: var(--o-line); }
.o-line-table input:focus, .o-line-table select:focus { outline: none; border-color: var(--o-purple); background: #fff; }
.o-line-del { color: var(--o-red); background: transparent; border: 0; font-size: 16px; padding: 0 6px; }
.o-add-line { margin-top: 8px; background: transparent; border: 0; color: var(--o-purple); font-weight: 800; padding: 6px 0; }
.o-add-line:hover { text-decoration: underline; }

/* form notice (missing required reference data) */
.o-notice { background: #fff8e6; border: 1px solid #f0d98a; color: #7a5d00; border-radius: 4px; padding: 10px 14px; margin: 14px 22px 0; font-weight: 600; }

/* detail meta line in list-expand */
.o-meta { color: var(--o-muted); font-size: 12px; }

/* ---------- Admin ---------- */
.o-admin-grid { padding: 16px; display: grid; gap: 14px; max-width: 900px; }
.o-card { background: #fff; border: 1px solid var(--o-line); border-radius: 6px; padding: 16px 18px; }
.o-card h3 { margin: 0 0 2px; font-size: 16px; }
.o-card .o-live { background: var(--o-green); color: #fff; border-radius: 12px; padding: 2px 10px; font-size: 11px; font-weight: 800; margin-inline-start: 8px; }
.o-card .o-cfg { background: #efefef; color: #777; border-radius: 12px; padding: 2px 10px; font-size: 11px; font-weight: 800; margin-inline-start: 8px; }
.o-checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.o-check { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--o-line); border-radius: 4px; cursor: pointer; }
.o-check input { accent-color: var(--o-purple); }

/* ---------- Hub (launcher) ---------- */
.o-hub { padding: 40px 28px; max-width: 1080px; margin: 0 auto; }
.o-hub-head { margin-bottom: 26px; }
.o-hub-head h1 { font-size: 28px; margin: 0 0 4px; color: #111; }
.o-hub-head p { margin: 0; color: var(--o-muted); }
.o-apps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.o-app-card { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; text-align: start; background: #fff; border: 1px solid var(--o-line); border-radius: 10px; padding: 24px; min-height: 188px; color: var(--o-text); transition: box-shadow .15s, border-color .15s, transform .15s; }
.o-app-card:hover:not(.disabled) { box-shadow: 0 10px 28px rgba(23,102,196,.16); border-color: var(--o-primary); transform: translateY(-2px); }
.o-app-card .o-app-ic { width: 56px; height: 56px; border-radius: 13px; background: var(--o-primary-l); color: var(--o-primary); display: grid; place-items: center; }
.o-app-card .o-app-ic svg { width: 30px; height: 30px; }
.o-app-card b { font-size: 19px; color: #111; }
.o-app-card small { color: var(--o-muted); line-height: 1.7; }
.o-app-card .o-open { margin-top: auto; color: var(--o-primary); font-weight: 800; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.o-app-card.disabled { opacity: .6; cursor: default; }
.o-app-card.disabled .o-app-ic { background: #efefef; color: #9a9a9a; }
.o-app-card .o-soon { margin-top: auto; background: #efefef; color: #777; border-radius: 12px; padding: 3px 11px; font-size: 12px; font-weight: 800; }

/* ---------- Toast ---------- */
.o-toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 99; min-width: 240px; max-width: 90vw; text-align: center; padding: 11px 18px; border-radius: 6px; color: #fff; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.2); display: none; }
.o-toast.ok { background: #2e7d46; }
.o-toast.err { background: #c0392b; }

@media (max-width: 820px) {
  .o-app { grid-template-columns: 1fr; }
  .o-sidebar { display: flex; flex-wrap: wrap; gap: 4px; }
  .o-group { grid-template-columns: 1fr; }
  .o-checks { grid-template-columns: 1fr; }
}
