/* ═══════════════════════════════════════════════════════════════
   Atic ERP — Main Stylesheet  (RTL / Bootstrap 5 RTL)
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────────────── */
:root {
  /* Layout */
  --sidebar-width : 255px;
  --topbar-height : 58px;
  --page-bg       : #eef0f5;
  --card-radius   : .6rem;

  /* Brand */
  --sidebar-bg    : #0c1a2e;
  --sidebar-hover : rgba(255,255,255,.09);
  --sidebar-active: #1749c9;

  /* Palette */
  --blue    : #1749c9;
  --amber   : #d97706;
  --amber-lt: #fef3c7;
  --green   : #059669;
  --green-lt: #d1fae5;
  --red     : #dc2626;
  --red-lt  : #fee2e2;
  --slate   : #64748b;
  --slate-lt: #f1f5f9;

  /* Text */
  --t-head  : #0f172a;
  --t-body  : #374151;
  --t-muted : #6b7280;
  --t-subtle: #9ca3af;

  /* Surfaces */
  --border    : #e2e8f0;
  --shadow-sm : 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md : 0 4px 16px rgba(0,0,0,.1);
}

/* ── Font-weight utilities (Bootstrap 5 has fw-bold=700 but not 600/800) ── */
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }

/* ── Body & font ──────────────────────────────────────────────── */
body {
  background : var(--page-bg);
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  font-size  : .9rem;
  color      : var(--t-body);
}

/* ── Sidebar ──────────────────────────────────────────────────── */
#sidebar {
  width         : var(--sidebar-width);
  min-height    : 100vh;
  background    : var(--sidebar-bg);
  position      : fixed;
  right         : 0;
  top           : 0;
  z-index       : 1040;
  display       : flex;
  flex-direction: column;
  overflow-y    : auto;
  overflow-x    : hidden;
}

.sidebar-brand {
  padding      : 1.2rem 1.1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand .brand-title {
  font-size  : 1.08rem;
  font-weight: 700;
  color      : #fff;
  line-height: 1.2;
}
.sidebar-brand .brand-sub {
  font-size     : .68rem;
  color         : rgba(255,255,255,.38);
  letter-spacing: .03em;
}

.sidebar-section-title {
  font-size     : .66rem;
  font-weight   : 700;
  color         : rgba(255,255,255,.26);
  letter-spacing: .09em;
  padding       : .95rem 1.1rem .2rem;
  text-transform: uppercase;
}

.sidebar-nav .nav-link {
  display    : flex;
  align-items: center;
  gap        : .55rem;
  color      : rgba(255,255,255,.65);
  padding    : .42rem .85rem;
  margin     : .1rem .5rem;
  border-radius: .38rem;
  font-size  : .85rem;
  transition : background .15s, color .15s;
  white-space: nowrap;
}
.sidebar-nav .nav-link i            { font-size:1rem; flex-shrink:0; width:1.2rem; text-align:center; }
.sidebar-nav .nav-link:hover        { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active       { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar-nav .nav-link.disabled-link{ opacity: .28; pointer-events: none; }

.sidebar-footer {
  margin-top  : auto;
  padding     : .75rem 1rem;
  border-top  : 1px solid rgba(255,255,255,.07);
  font-size   : .73rem;
  color       : rgba(255,255,255,.25);
  text-align  : center;
}

/* ── Page wrapper ─────────────────────────────────────────────── */
.page-wrapper {
  margin-right  : var(--sidebar-width);
  min-height    : 100vh;
  display       : flex;
  flex-direction: column;
}

/* ── Top bar ──────────────────────────────────────────────────── */
.topbar {
  height       : var(--topbar-height);
  background   : #fff;
  border-bottom: 1px solid var(--border);
  display      : flex;
  align-items  : center;
  padding      : 0 1.5rem;
  gap          : .75rem;
  position     : sticky;
  top          : 0;
  z-index      : 1030;
}
.topbar .page-heading {
  font-size  : 1rem;
  font-weight: 700;
  color      : var(--t-head);
  flex       : 1;
}
.topbar .user-pill {
  display       : flex;
  align-items   : center;
  gap           : .4rem;
  background    : var(--slate-lt);
  border-radius : 2rem;
  padding       : .28rem .75rem;
  font-size     : .79rem;
  color         : var(--slate);
  text-decoration: none;
  transition    : background .15s;
}
.topbar .user-pill:hover { background: #e2e8f0; }
.topbar .user-pill i     { font-size: .88rem; }

/* ── Page content ─────────────────────────────────────────────── */
.page-content { flex:1; padding: 1.4rem 1.75rem 1.5rem; }

/* ── Breadcrumb ───────────────────────────────────────────────── */
.breadcrumb { font-size: .77rem; margin: 0; }
.breadcrumb-item + .breadcrumb-item::before { content: "‹"; }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  border       : 1px solid var(--border) !important;
  border-radius: var(--card-radius);
  box-shadow   : var(--shadow-sm);
  background   : #fff;
}
.card-header {
  background   : #f9fafb;
  border-bottom: 1px solid var(--border);
  font-weight  : 600;
  font-size    : .86rem;
  color        : var(--t-head);
  padding      : .6rem .9rem;
  border-radius: calc(var(--card-radius) - 1px) calc(var(--card-radius) - 1px) 0 0 !important;
}
.card-body { padding: .9rem; }

/* ── Stat cards ───────────────────────────────────────────────── */
.stat-card {
  border-inline-start: 4px solid var(--stat-color, #1749c9) !important;
  border-inline-end  : 1px solid var(--border) !important;
}
.stat-card .stat-icon {
  width: 44px; height: 44px; border-radius: .48rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  background: color-mix(in srgb, var(--stat-color, #1749c9) 11%, transparent);
  color: var(--stat-color, #1749c9);
}
.stat-card .stat-value { font-size:1.8rem; font-weight:800; line-height:1.1; color:var(--t-head); }
.stat-card .stat-label { font-size:.75rem; color:var(--t-muted); font-weight:500; }

/* ── Tables ───────────────────────────────────────────────────── */
.table { font-size: .855rem; }
.table th {
  font-size:.76rem; font-weight:700; color:var(--t-muted);
  background:#f8fafc; white-space:nowrap; border-top:none;
  padding:.5rem .7rem; letter-spacing:.015em;
}
.table td { vertical-align:middle; padding:.45rem .7rem; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: #f4f7ff; }
.table-sm th, .table-sm td { padding: .32rem .6rem; }

/* ── Badges ───────────────────────────────────────────────────── */
.badge { font-size:.71rem; font-weight:600; letter-spacing:.01em; }
.badge-warehouse { background:#dbeafe; color:#1e40af; }
.badge-driver    { background:var(--green-lt); color:#166534; }

/* Status badges */
.badge-open      { background:var(--green-lt); color:#065f46; }
.badge-closed    { background:var(--slate-lt);  color:#475569; }
.badge-breakdown { background:var(--red-lt);    color:#991b1b; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-label { font-weight:600; font-size:.81rem; color:#374151; margin-bottom:.28rem; }
.form-control, .form-select {
  font-size:.875rem; border-color:#d1d5db; border-radius:.38rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--blue);
  box-shadow  : 0 0 0 3px rgba(23,73,201,.13);
}
.form-control-sm, .form-select-sm { font-size:.815rem; }
.form-check-input:checked { background-color:var(--blue); border-color:var(--blue); }
.form-check-input:focus   { box-shadow: 0 0 0 3px rgba(23,73,201,.13); }
.input-group-text {
  font-size:.82rem; background:#f9fafb;
  border-color:#d1d5db; color:var(--t-muted);
}

/* ── Alerts ───────────────────────────────────────────────────── */
.alert { border-radius:.5rem; font-size:.875rem; border:1px solid rgba(0,0,0,.06); }
.alert-error { background:#fee2e2; color:#991b1b; border-color:#fecaca; }

/* ── Login page ───────────────────────────────────────────────── */
.login-bg {
  min-height:100vh;
  background: linear-gradient(135deg, #0c1a2e 0%, #1a4a8a 60%, #1749c9 100%);
  display:flex; align-items:center; justify-content:center; padding:1rem;
}
.login-card {
  background:#fff; border-radius:1.1rem;
  box-shadow:0 24px 64px rgba(0,0,0,.28);
  padding:2.5rem 2.25rem; width:100%; max-width:410px;
}
.login-logo {
  width:60px; height:60px; background:var(--sidebar-active);
  border-radius:.75rem; display:flex; align-items:center; justify-content:center;
  font-size:1.6rem; color:#fff; margin:0 auto 1.25rem;
}
.ticket-count-badge { font-size:1.5rem; font-weight:700; color:var(--blue); }

/* ════════════════════════════════════════════════════════════════
   MANIFESTO MODULE
   ════════════════════════════════════════════════════════════════ */

/* ── Identity strip — status-colored inline-start border ─────── */
.ms-id-strip {
  border-inline-start: 4px solid var(--ms-border, var(--blue)) !important;
  transition: border-color .25s;
}
.ms-open      { --ms-border: #059669; }
.ms-closed    { --ms-border: #94a3b8; }
.ms-breakdown { --ms-border: #ef4444; }

/* ── Manifesto number — typographic anchor of the page ────────── */
.ms-num {
  font-size    : 2rem;
  font-weight  : 800;
  color        : var(--t-head);
  letter-spacing: -.03em;
  line-height  : 1;
}
.ms-num .ms-hash { font-size:1.1rem; font-weight:400; color:var(--t-subtle); }

/* ── Operational strip — warm tinted data-entry zone ─────────── */
.ms-ops-strip > .card-header {
  background: linear-gradient(135deg, #eef3ff 0%, #f9fafb 100%);
  border-bottom-color: #d8e0f0;
}
.ms-ops-strip > .card-body { background: #f7f9ff; }
.ms-ops-strip .form-control, .ms-ops-strip .form-select {
  background: #fff;
}

/* ── Operational metrics (read-only closed state) ─────────────── */
.ms-metric { min-width: 80px; }
.ms-metric-label {
  font-size: .7rem; font-weight: 700; color: var(--t-subtle);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: .18rem;
}
.ms-metric-value { font-size:.95rem; font-weight:700; color:var(--t-head); }
.ms-metric-divider { border-inline-start: 1px solid var(--border); padding-inline-start: 1.25rem; }

/* ── Tab nav — underline / indicator style ────────────────────── */
.ms-tabs {
  border-bottom: 2px solid var(--border);
  gap: 0; flex-wrap: nowrap;
}
.ms-tabs .nav-link {
  color: var(--t-muted); font-weight: 600; font-size: .875rem;
  padding: .52rem 1rem;
  border: none; border-bottom: 3px solid transparent;
  margin-bottom: -2px; border-radius: 0;
  background: transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.ms-tabs .nav-link:hover { color: var(--t-body); border-bottom-color: #cbd5e1; }
.ms-tabs .nav-link.active { color: var(--blue); border-bottom-color: var(--blue); background: transparent; }
.ms-tabs .nav-link.active .badge { background-color: var(--blue) !important; }
.ms-tabs .nav-link .badge { transition: background-color .15s; }

.ms-tab-panel {
  background  : #fff;
  border      : 1px solid var(--border);
  border-top  : none;
  border-radius: 0;            /* rev-bar closes the bottom */
  padding     : .9rem;
  min-height  : 180px;
}

/* ── Revenue summary bar — fused footer below tab panel ──────── */
.rev-bar {
  display      : flex;
  align-items  : center;
  flex-wrap    : wrap;
  background   : #f4f6fa;
  border       : 1px solid var(--border);
  border-top   : 1px solid #dce4ef;
  border-radius: 0 0 var(--card-radius) var(--card-radius);
  padding      : .4rem .7rem;
  margin-bottom: .85rem;
  gap          : 0;
}
.rev-bar-cell {
  display       : flex;
  flex-direction: column;
  padding       : .2rem .65rem;
  border-inline-start: 1px solid #dce4ef;
}
.rev-bar-cell:first-child { border-inline-start: none; }
.rev-bar-lbl {
  font-size     : .67rem;
  font-weight   : 700;
  color         : var(--t-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  line-height   : 1.2;
  white-space   : nowrap;
}
.rev-bar-val { font-size: .88rem; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.rev-bar-op  { font-size: .85rem; color: var(--t-subtle); padding: 0 .15rem; align-self: center; }
.rev-bar-net {
  margin-inline-start: auto;
  border-inline-start: 2px solid var(--border) !important;
  padding-inline-start: 1rem;
  padding-inline-end  : .3rem;
}

/* ── Custody table — ticket booking rows ─────────────────────── */
.custody-table td, .custody-table th { font-size: .84rem; }
.custody-table tr { transition: background .1s; }
.custody-table tr.row-checked { background: rgba(23,73,201,.05) !important; }
.custody-table .form-check-input {
  width:1.2em; height:1.2em; cursor:pointer;
  margin-top: .1em; border-color:#b0bcd0;
}
.custody-table .form-check-input:checked { background-color:var(--blue); border-color:var(--blue); }

/* ── Revenue summary table ────────────────────────────────────── */
.rev-table td { border:none; padding:.38rem .7rem; font-size:.875rem; }
.rev-table .rev-gross td { font-weight:700; }
.rev-table .rev-net td {
  border-top: 2px solid var(--border);
  padding-top: .65rem; padding-bottom: .3rem;
  font-weight: 800;
}
.rev-table .rev-net .rev-label  { font-size:.95rem; color:var(--t-head); }
.rev-table .rev-net .rev-amount { font-size:1.3rem; color: var(--green); }

/* ── Entitlement card ─────────────────────────────────────────── */
.ms-entitlement {
  border-inline-start: 3px solid var(--green) !important;
}
.ms-entitlement .card-header {
  background: linear-gradient(135deg, #f0fdf4 0%, #f9fafb 100%);
  color: #065f46;
  border-bottom-color: #bbf7d0;
}
.ms-entitlement .ent-net td {
  font-weight:800; border-top:2px solid var(--border); padding-top:.6rem;
}

/* ── Action bar — sticky bottom ─────────────────────────────────
   Bleeds to page edges, floats above content on scroll.          */
.ms-action-bar {
  position: sticky;
  bottom  : 0;
  background  : #fff;
  border-top  : 1px solid var(--border);
  box-shadow  : 0 -4px 24px rgba(0,0,0,.09);
  margin      : 1.5rem -1.75rem -1.5rem;
  padding     : .7rem 1.75rem;
  z-index     : 200;
  display     : flex;
  align-items : center;
  gap         : .65rem;
  flex-wrap   : wrap;
}

/* ── Manifesto list ───────────────────────────────────────────── */
.ms-list-row td { transition: background .1s; }
.ms-list-row:hover td { background: #f0f5ff; }
.ms-num-cell {
  font-size: .98rem; font-weight: 800;
  color: var(--blue); letter-spacing: -.02em;
}
.ms-status-dot {
  display: inline-block; width:.5rem; height:.5rem;
  border-radius:50%; vertical-align: middle; margin-inline-end:.35rem;
  flex-shrink: 0;
}
.ms-status-dot.open      { background:var(--green); box-shadow:0 0 0 2px var(--green-lt); }
.ms-status-dot.closed    { background:#94a3b8; }
.ms-status-dot.breakdown { background:var(--red); box-shadow:0 0 0 2px var(--red-lt); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar       { transform: translateX(100%); }
  .page-wrapper  { margin-right: 0; }
  .ms-action-bar { margin: 1rem -1.75rem -1.5rem; }
}
