/* =========================================================
   SIB Real Estate Finance Hub — Enterprise Design System
   Brand: Sohar International (official palette)
   Primary: #FF6A00  ·  Dark text: #0d0d10  ·  Neutrals: metallic graphite
   ========================================================= */

:root {
  /* Official Sohar International brand — exact palette from brand mark */
  --sib-primary:        #FF6A00;   /* official Sohar orange */
  --sib-primary-hover:  #e65d00;
  --sib-primary-dark:   #b84a00;
  --sib-primary-light:  #ff7a1a;
  --sib-surface-soft:   #fff5ec;   /* very light tint */
  --sib-border-soft:    #ffc999;

  /* Secondary — warm bronze accent */
  --sib-gold:           #c98821;
  --sib-gold-light:     #dea032;
  --sib-gold-soft:      #fdf6ec;

  /* Neutral — metallic silver grays (from logo emblem) */
  --ink-950: #050507;
  --ink-900: #0d0d10;
  --ink-800: #1f1f22;
  --ink-700: #363639;
  --ink-600: #4a4a51;
  --ink-500: #64646d;
  --ink-400: #8a8a93;
  --ink-300: #b4b4bb;
  --ink-200: #d8d8dc;
  --ink-100: #ededef;
  --ink-50:  #f7f7f8;

  --bg-canvas:       #f7f7f8;
  --border-default:  #d8d8dc;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  direction: rtl;
  text-align: right;
}

body {
  font-feature-settings: 'ss01', 'cv01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-canvas);
  color: var(--ink-900);
}

/* Arabic numerals in English (tabular) for data tables */
.tabular-nums { font-variant-numeric: tabular-nums; }

/* Latin numerals in Arabic context look better */
.num-latin { font-family: 'IBM Plex Sans', sans-serif; font-variant-numeric: tabular-nums; }

/* ========== SIB brand gradients — Sohar International signature ========== */
.sib-gradient {
  background: linear-gradient(135deg, #ff7a1a 0%, #FF6A00 45%, #e65d00 100%);
}
.sib-gradient-soft {
  background: linear-gradient(135deg, #fff5ec 0%, #ffe5cc 100%);
}
.sib-gradient-dark {
  background: linear-gradient(135deg, #1f1f22 0%, #0d0d10 100%);
}
/* Metallic silver sweep — mimics the emblem's 3D gradient */
.sib-metallic {
  background: linear-gradient(135deg, #f7f7f8 0%, #d8d8dc 30%, #8a8a93 60%, #4a4a51 100%);
}
.gold-gradient {
  background: linear-gradient(135deg, #dea032 0%, #c98821 50%, #855418 100%);
}

/* ========== Pattern background for hero sections ========== */
.pattern-arab {
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255, 106, 0, 0.07) 0%, transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(201, 136, 33, 0.05) 0%, transparent 45%);
}

/* ========== Sohar signature orange accent line (vertical) ========== */
.sohar-accent-line {
  position: relative;
}
.sohar-accent-line::before {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #FF6A00 0%, #e65d00 100%);
  border-radius: 2px;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #f8f7f6; }
::-webkit-scrollbar-thumb { background: #bdb5ae; border-radius: 5px; border: 2px solid #f8f7f6; }
::-webkit-scrollbar-thumb:hover { background: #938a82; }

/* ========== Cards ========== */
.card {
  background: white;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  box-shadow: 0 1px 2px 0 rgba(21, 19, 15, 0.04), 0 1px 3px 0 rgba(21, 19, 15, 0.05);
}

.card-hover {
  transition: all 0.2s ease;
}
.card-hover:hover {
  box-shadow: 0 6px 14px -4px rgba(21, 19, 15, 0.08), 0 3px 6px -3px rgba(21, 19, 15, 0.04);
  border-color: #bdb5ae;
  transform: translateY(-1px);
}

/* ========== Status badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-success { background: #effaf3; color: #126340; border-color: #cdeed8; }
.badge-warning { background: #fff8eb; color: #8c570c; border-color: #f8e1b4; }
.badge-danger  { background: #fdf2f2; color: #971d1d; border-color: #f8cfcf; }
.badge-info    { background: #eef5ff; color: #1b457f; border-color: #c9dcf8; }
.badge-neutral { background: #eeece9; color: #403c37; border-color: #dcd7d2; }
.badge-primary { background: #fff5ec; color: #b84a00; border-color: #ffc999; }
.badge-gold    { background: #fdf6ec; color: #855418; border-color: #f2d28a; }

.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary {
  background: #FF6A00;
  color: white;
  box-shadow: 0 1px 2px rgba(176, 70, 9, 0.2);
}
.btn-primary:hover {
  background: #e65d00;
  box-shadow: 0 4px 10px rgba(255, 106, 0, 0.28);
}

.btn-gold {
  background: #c98821;
  color: white;
}
.btn-gold:hover { background: #a86d1a; }

.btn-secondary {
  background: white;
  color: #403c37;
  border-color: #dcd7d2;
  font-weight: 500;
}
.btn-secondary:hover { background: #f8f7f6; border-color: #bdb5ae; color: #15130f; }

.btn-ghost {
  background: transparent;
  color: #545049;
  font-weight: 500;
}
.btn-ghost:hover { background: #eeece9; color: #15130f; }

.btn-danger {
  background: white;
  color: #971d1d;
  border-color: #f8cfcf;
}
.btn-danger:hover { background: #fdf2f2; }

.btn-dark {
  background: #15130f;
  color: white;
}
.btn-dark:hover { background: #2a2724; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ========== Forms ========== */
.input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #dcd7d2;
  border-radius: 8px;
  background: white;
  font-size: 14px;
  color: #15130f;
  transition: all 0.15s;
  font-family: inherit;
}
.input:focus {
  outline: none;
  border-color: #FF6A00;
  box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.12);
}
.input::placeholder { color: #938a82; }

.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #403c37;
  margin-bottom: 6px;
}

/* ========== Sidebar ========== */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #bdb5ae;
  font-size: 14px;
  transition: all 0.15s;
  text-decoration: none;
}
.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
}
.sidebar-link.active {
  background: rgba(255, 106, 0, 0.14);
  color: #ff7a1a;
  border-right: 3px solid #FF6A00;
}
.sidebar-link i { width: 20px; text-align: center; }

/* ========== Tables ========== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th {
  text-align: right;
  padding: 12px 16px;
  background: #f8f7f6;
  color: #545049;
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid #dcd7d2;
}
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid #eeece9;
  color: #15130f;
}
.table tbody tr:hover { background: #f8f7f6; }
.table tbody tr:last-child td { border-bottom: 0; }

/* ========== Timeline ========== */
.timeline { position: relative; padding-right: 32px; }
.timeline::before {
  content: '';
  position: absolute;
  right: 14px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: #dcd7d2;
}
.timeline-item { position: relative; padding-bottom: 24px; }
.timeline-item::before {
  content: '';
  position: absolute;
  right: -23px;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  border: 2px solid #bdb5ae;
  z-index: 2;
}
.timeline-item.done::before { background: #1fa368; border-color: #1fa368; }
.timeline-item.current::before { background: #FF6A00; border-color: #FF6A00; box-shadow: 0 0 0 4px rgba(255, 106, 0, 0.2); }
.timeline-item.pending::before { background: white; border-color: #bdb5ae; }
.timeline-item.failed::before { background: #d53030; border-color: #d53030; }

/* ========== Stepper ========== */
.stepper { display: flex; align-items: center; gap: 0; }
.stepper-item { display: flex; align-items: center; gap: 8px; flex: 1; }
.stepper-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  background: white;
  border: 2px solid #bdb5ae;
  color: #938a82;
  flex-shrink: 0;
}
.stepper-item.done .stepper-circle { background: #1fa368; border-color: #1fa368; color: white; }
.stepper-item.current .stepper-circle { background: #FF6A00; border-color: #FF6A00; color: white; }
.stepper-line { flex: 1; height: 2px; background: #dcd7d2; margin: 0 8px; }
.stepper-item.done + .stepper-line,
.stepper-line.done { background: #1fa368; }

/* ========== Avatars ========== */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  background: #FF6A00;
  font-size: 13px;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }

/* ========== KPI card ========== */
.kpi-card {
  background: white;
  border: 1px solid #dcd7d2;
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s;
}
.kpi-card:hover { box-shadow: 0 4px 6px -1px rgba(21, 19, 15, 0.06); }
.kpi-value { font-size: 28px; font-weight: 700; color: #15130f; letter-spacing: -0.02em; }
.kpi-label { font-size: 13px; color: #6f6763; margin-bottom: 8px; }
.kpi-delta { font-size: 12px; font-weight: 500; }
.kpi-delta.up { color: #1fa368; }
.kpi-delta.down { color: #d53030; }

/* ========== Progress bar ========== */
.progress { height: 6px; background: #eeece9; border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: #FF6A00; border-radius: 3px; transition: width 0.3s; }
.progress-bar.gold { background: #c98821; }
.progress-bar.success { background: #1fa368; }
.progress-bar.warning { background: #d68a14; }

/* ========== Portal tags ========== */
.portal-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  background: #eeece9;
  color: #403c37;
}

/* ========== Case ID style ========== */
.case-id {
  font-family: 'IBM Plex Sans', monospace;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #b84a00;
  background: #fff5ec;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  border: 1px solid #ffc999;
  direction: ltr;
  display: inline-block;
}

/* ========== Sections ========== */
.section-title {
  font-size: 18px;
  font-weight: 600;
  color: #15130f;
  margin-bottom: 4px;
}
.section-subtitle {
  font-size: 13px;
  color: #6f6763;
}

/* ========== Animations ========== */
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(255, 106, 0, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(255, 106, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 106, 0, 0); }
}
.pulse-live { animation: pulse-ring 2s infinite; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease; }

/* ========== Enhanced shadows for premium feel ========== */
.shadow-lift { box-shadow: 0 12px 28px -6px rgba(21, 19, 15, 0.10), 0 4px 10px -4px rgba(21, 19, 15, 0.04); }

/* ========== Utility ========== */
.divider-v { width: 1px; background: #dcd7d2; align-self: stretch; }
.dot-sep::before { content: '·'; margin: 0 6px; color: #bdb5ae; }

/* Remove default blue tap highlight on mobile */
* { -webkit-tap-highlight-color: transparent; }

/* Links */
a { color: inherit; text-decoration: none; }
a.link { color: #FF6A00; }
a.link:hover { color: #e65d00; text-decoration: underline; }

/* Focus styles for accessibility */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid #FF6A00;
  outline-offset: 2px;
}

/* Chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #eeece9;
  border-radius: 6px;
  font-size: 12px;
  color: #403c37;
}

/* Map placeholder */
.map-canvas {
  background:
    linear-gradient(135deg, #f8f7f6 25%, transparent 25%) -10px 0,
    linear-gradient(225deg, #f8f7f6 25%, transparent 25%) -10px 0,
    linear-gradient(315deg, #f8f7f6 25%, transparent 25%),
    linear-gradient(45deg, #f8f7f6 25%, transparent 25%);
  background-size: 20px 20px;
  background-color: #eeece9;
  position: relative;
}

/* Tabs */
.tab-nav { display: flex; gap: 4px; border-bottom: 1px solid #dcd7d2; padding: 0 4px; }
.tab-item {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #6f6763;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -1px;
}
.tab-item:hover { color: #15130f; }
.tab-item.active { color: #FF6A00; border-bottom-color: #FF6A00; }

/* Modal backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(21, 19, 15, 0.5);
  backdrop-filter: blur(4px);
  z-index: 50;
}

/* ═══════════════════════════════════════════════════════════════
   Accessibility & Responsive enhancements (Phase 2 polish)
   ═══════════════════════════════════════════════════════════════ */

/* Keyboard focus for tabs (not caught by generic focus-visible rule) */
.tab-item:focus-visible {
  outline: 2px solid #FF6A00;
  outline-offset: -2px;
  border-radius: 4px;
}

/* Honor users who prefer reduced motion (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High-contrast mode (Windows forced colors) */
@media (forced-colors: active) {
  .card, .kpi-card { border: 1px solid CanvasText; }
  .btn-primary { border: 1px solid ButtonText; }
  .progress-bar { background: Highlight; }
}

/* Print styles — clean output for reports */
@media print {
  /* Hide navigation chrome on print */
  nav, aside, .tab-nav, .noprint, [data-sib-action], .btn, .modal-backdrop {
    display: none !important;
  }
  main, #main-content { max-width: none !important; padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; font-size: 10pt; }
  .card { box-shadow: none !important; border: 1px solid #cbd5e1 !important; break-inside: avoid; }
  .kpi-card { break-inside: avoid; }
  table { break-inside: auto; }
  tr { break-inside: avoid; break-after: auto; }
  thead { display: table-header-group; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #64748b; }
  a[href^="/"]::after { content: none; }
}

/* Responsive table wrappers — allow horizontal scroll on small screens
   without breaking the layout */
@media (max-width: 640px) {
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .table { font-size: 12px; }
  .table th, .table td { padding: 8px; }
  /* Make page headers stack on mobile */
  .page-header-actions { flex-wrap: wrap; gap: 6px; }
}

/* Make kpi-cards adapt gracefully under 400 px */
@media (max-width: 400px) {
  .kpi-card { padding: 12px; }
  .kpi-value { font-size: 18px; }
  .kpi-label { font-size: 10px; }
}

/* Ensure tap targets on touch devices meet WCAG 2.5.5 (≥44×44 px) */
@media (hover: none) and (pointer: coarse) {
  .btn-sm, .btn-xs { min-height: 36px; min-width: 36px; }
  .btn, button.tab-item { min-height: 44px; }
  /* Links inside tables keep natural size, but icon-only action buttons grow */
  td .btn, td button, td a { min-height: 36px; min-width: 36px; }
}

/* Improve text selection contrast */
::selection { background: rgba(255, 106, 0, 0.25); color: #15130f; }

/* Force number elements to use LTR rendering (prevents digit flipping in RTL) */
.num-latin { direction: ltr; unicode-bidi: embed; display: inline-block; }

/* ═══════════════════════════════════════════════════════════════
   Mobile sidebar drawer (≤ 1023 px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  .sib-sidebar {
    position: fixed !important;
    top: 0 !important;
    right: 0;
    z-index: 40;
    height: 100vh !important;
    transform: translateX(100%);
    transition: transform 0.28s ease-out;
    box-shadow: -6px 0 18px rgba(15, 19, 15, 0.18);
    width: min(85vw, 280px) !important;
  }
  .sib-sidebar.is-open { transform: translateX(0); }
  /* Main content should take full width on mobile */
  .sib-sidebar + div { width: 100%; }
}
/* Honor reduced motion preference on the drawer */
@media (prefers-reduced-motion: reduce) {
  .sib-sidebar { transition: none !important; }
}
