/* The Cairo font ships with the program - see vendor/fonts/cairo.css, loaded
   from index.html so the browser can fetch it in parallel with this file. */

:root {
  --primary: #1e3a8a;
  --primary-dark: #172554;
  --primary-light: #3b82f6;
  --secondary: #854d0e;
  --accent: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

input, textarea, select {
  -webkit-user-select: auto;
  user-select: auto;
}

body {
  direction: rtl;
  text-align: right;
  background-color: var(--bg);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  display: flex;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: #0f172a;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  box-shadow: -2px 0 10px rgba(0,0,0,0.05);
  z-index: 20;
}

.brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #1e293b;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 11px;
  color: #94a3b8;
}

.nav-links {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item:hover {
  background: #1e293b;
  color: #f8fafc;
}

.nav-item.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.nav-icon {
  font-size: 18px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #1e293b;
  font-size: 11px;
  color: #64748b;
  text-align: center;
}

/* Main Content */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
}

.top-bar {
  height: 64px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 10;
}

.top-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
}
.btn-primary:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-success {
  background: #059669;
  color: #ffffff;
}
.btn-success:hover {
  background: #047857;
}

.btn-danger {
  background: #dc2626;
  color: #ffffff;
}
.btn-danger:hover {
  background: #b91c1c;
}

.btn-outline {
  background: #ffffff;
  color: #334155;
  border: 1px solid var(--border);
}
.btn-outline:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* Content Area */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.tab-view {
  display: none;
}
.tab-view.active {
  display: block;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.05);
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* Table Card */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  margin-bottom: 24px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 13px;
}

.data-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

.data-table tr:hover {
  background: #f8fafc;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.form-select, .form-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: #ffffff;
  color: var(--text-main);
  min-width: 160px;
}

.form-select:focus, .form-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: #ffffff;
  width: 540px;
  max-width: 95vw;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  animation: modalIn 0.2s ease-out;
}

.modal-lg {
  width: 920px;
  max-width: 96vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.modal-lg .modal-body {
  overflow-y: auto;
  max-height: calc(92vh - 130px);
  padding: 24px;
}

.badge-blue {
  background: #eff6ff;
  color: #2563eb;
}

.badge-purple {
  background: #f5f3ff;
  color: #7c3aed;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  margin: 2px;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}

.interactive-link {
  color: #2563eb;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.interactive-link:hover {
  text-decoration: underline;
  color: #1d4ed8;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 20px 24px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #64748b;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.live-balance-card {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.modal-footer {
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Wide tables scroll inside their card instead of being clipped by it */
.table-scroll {
  overflow-x: auto;
}
.table-scroll > .data-table {
  min-width: 880px;
}
.data-table td.cell-wrap {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;   /* long file paths must be allowed to break */
  unicode-bidi: plaintext;   /* ...without scrambling the Arabic around them */
}

/* Column widths are honoured exactly; the remaining space goes to the
   unsized column (the details), so the log needs no horizontal scrolling. */
.data-table.table-fixed {
  table-layout: fixed;
  width: 100%;
}
.table-scroll > .data-table.table-fixed {
  min-width: 760px;
}
.mono {
  font-family: Consolas, 'Courier New', monospace;
  direction: ltr;
  unicode-bidi: embed;
}


/* =====================================================================
   شاشة الدخول — the lock screen sits above everything, including modals,
   and is present in the markup from the first paint so no data can flash
   on screen before the password is accepted.
   ===================================================================== */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #172554 100%);
}
.lock-screen.hidden {
  display: none;
}

.lock-card {
  width: 100%;
  max-width: 400px;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 32px 28px 22px;
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.45);
  text-align: center;
}

.lock-logo {
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb, #1e3a8a);
}

.lock-title {
  font-size: 19px;
  font-weight: 800;
  color: var(--text-main);
}
.lock-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 6px 0 20px;
  line-height: 1.8;
}

.lock-card .form-group {
  text-align: right;
  margin-bottom: 14px;
}
.lock-card .form-label {
  display: block;
  margin-bottom: 6px;
}

/* The eye button sits inside the field, so the field itself is the anchor. */
.lock-field {
  position: relative;
}
.lock-field .form-input {
  width: 100%;
  padding: 10px 12px;
  padding-left: 38px;         /* room for the eye (the field is LTR) */
  font-size: 14px;
  letter-spacing: 1px;
}
.lock-eye {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
}
.lock-eye:hover {
  background: #f1f5f9;
  color: #475569;
}

.lock-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  text-align: right;
  line-height: 1.7;
  margin-bottom: 12px;
}

.lock-submit {
  width: 100%;
  justify-content: center;
  padding: 11px;
  font-size: 14px;
}
.lock-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.lock-help {
  margin-top: 16px;
  font-size: 12px;
}
.lock-help a {
  color: #64748b;
  text-decoration: none;
}
.lock-help a:hover {
  color: #2563eb;
  text-decoration: underline;
}

/* Password fields on the «الإعدادات» page */
.pw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  max-width: 640px;
  margin-top: 12px;
}


/* =====================================================================
   قوائم البحث بالاسم — a <select> with a text box in front of it, so a
   long list of investors is typed into instead of scrolled through.
   ===================================================================== */
.combo {
  position: relative;
  display: inline-block;
  min-width: 190px;
}

.combo-hidden-select {
  display: none !important;
}

.combo-input {
  width: 100%;
  padding-left: 28px;          /* room for the chevron (the box reads RTL) */
  cursor: text;
}

.combo-caret {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
}
.combo-caret:hover {
  color: #2563eb;
}

/* The list is placed on <body> and positioned from JS, so neither the card nor
   the modal («تسجيل حركة» clips its own content) can cut it off. */
.combo-list {
  display: none;
  position: fixed;
  z-index: 9500;               /* above the modals (100) and the lock screen (9000) */
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}
.combo-list.open {
  display: block;
}

.combo-option {
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.combo-option.active {
  background: #eff6ff;
  color: #1d4ed8;
}
.combo-option.current {
  font-weight: 700;
}
.combo-option.current::after {
  content: '✓';
  float: left;
  color: #059669;
}

.combo-empty {
  padding: 10px;
  font-size: 12.5px;
  color: #94a3b8;
  text-align: center;
}
