/* =============================================
   Transaction Tracker — Main Stylesheet
   Theme: Dark Navy + Gold — Financial / Professional
   ============================================= */

:root {
  --navy:        #0a0f1e;
  --navy-mid:    #111827;
  --navy-light:  #1a2540;
  --navy-border: #1e2d4a;
  --gold:        #c9a84c;
  --gold-light:  #e2c47e;
  --gold-dim:    #8a6d2c;
  --white:       #f0f4ff;
  --muted:       #6b7a9a;
  --danger:      #e05252;
  --success:     #3ecf8e;
  --warning:     #f59e0b;
  --info:        #38bdf8;
  --purple:      #a78bfa;

  /* Status colors */
  --s-pending:    #6b7a9a;
  --s-received:   #38bdf8;
  --s-reserved:   #a78bfa;
  --s-deposit:    #f59e0b;
  --s-transferred:#3ecf8e;
  --s-completed:  #c9a84c;
  --s-cancelled:  #e05252;

  --sidebar-w: 260px;
  --topbar-h:  60px;
  --radius:    10px;
  --font:      'IBM Plex Sans Arabic', sans-serif;
  --mono:      'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--navy);
  color: var(--white);
  display: flex;
  min-height: 100vh;
  direction: rtl;
}

a { color: inherit; text-decoration: none; }

/* =============================================
   Sidebar
   ============================================= */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy-mid);
  border-left: 1px solid var(--navy-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 100;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}

.sidebar-header {
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--navy-border);
}

.logo {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.logo-icon {
  font-size: 1.8rem;
  color: var(--gold);
  animation: spin 8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.logo-text { line-height: 1.2; }
.logo-main {
  display: block;
  font-weight: 700;
  font-size: .95rem;
  color: var(--white);
}
.logo-sub {
  display: block;
  font-size: .7rem;
  color: var(--gold);
  font-family: var(--mono);
  letter-spacing: .05em;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.25rem;
  margin: .15rem .75rem;
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--muted);
  transition: all .2s;
  cursor: pointer;
}
.nav-item:hover { background: var(--navy-light); color: var(--white); }
.nav-item.active { background: var(--navy-light); color: var(--gold); border-right: 3px solid var(--gold); }

.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.nav-divider {
  font-size: .7rem;
  color: var(--muted);
  padding: .75rem 1.25rem .35rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-family: var(--mono);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--navy-border);
  display: flex;
  align-items: center;
  gap: .75rem;
}

.user-badge { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; color: var(--navy);
  flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name { display: block; font-size: .85rem; font-weight: 600; truncate; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { display: block; font-size: .72rem; color: var(--muted); }

.logout-btn {
  color: var(--muted);
  font-size: 1.1rem;
  padding: .3rem;
  border-radius: 6px;
  transition: all .2s;
  flex-shrink: 0;
}
.logout-btn:hover { color: var(--danger); background: rgba(224,82,82,.1); }

/* =============================================
   Main Layout
   ============================================= */
.main-wrapper {
  margin-right: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  background: var(--navy-mid);
  border-bottom: 1px solid var(--navy-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.25rem;
  cursor: pointer;
}

.page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--white);
  flex: 1;
}

.topbar-date {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--muted);
}

.page-content {
  padding: 1.5rem;
  flex: 1;
}

/* =============================================
   Cards
   ============================================= */
.card {
  background: var(--navy-mid);
  border: 1px solid var(--navy-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--navy-border);
}

.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--gold);
}

/* =============================================
   Stats Grid
   ============================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--navy-mid);
  border: 1px solid var(--navy-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 4px; height: 100%;
}
.stat-card.gold::before   { background: var(--gold); }
.stat-card.blue::before   { background: var(--info); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.green::before  { background: var(--success); }
.stat-card.orange::before { background: var(--warning); }
.stat-card.red::before    { background: var(--danger); }

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--mono);
  line-height: 1;
  margin-bottom: .35rem;
}
.stat-label { font-size: .8rem; color: var(--muted); }

/* =============================================
   Table
   ============================================= */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  text-align: right;
  padding: .75rem 1rem;
  color: var(--muted);
  font-weight: 500;
  font-size: .78rem;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--navy-border);
  white-space: nowrap;
  font-family: var(--mono);
  text-transform: uppercase;
}

tbody tr {
  border-bottom: 1px solid rgba(30,45,74,.5);
  transition: background .15s;
  cursor: pointer;
}
tbody tr:hover { background: var(--navy-light); }

tbody td {
  padding: .85rem 1rem;
  vertical-align: middle;
  white-space: nowrap;
}

.ref-code {
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--gold);
  font-weight: 600;
}

.amount-cell {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--gold-light);
}

/* =============================================
   Status Badges
   ============================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .75rem;
  border-radius: 50px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-pending      { background: rgba(107,122,154,.15); color: var(--s-pending); }
.status-received     { background: rgba(56,189,248,.15);  color: var(--s-received); }
.status-reserved     { background: rgba(167,139,250,.15); color: var(--s-reserved); }
.status-deposit      { background: rgba(245,158,11,.15);  color: var(--s-deposit); }
.status-transferred  { background: rgba(62,207,142,.15);  color: var(--s-transferred); }
.status-completed    { background: rgba(201,168,76,.15);  color: var(--s-completed); }
.status-cancelled    { background: rgba(224,82,82,.15);   color: var(--s-cancelled); }

/* =============================================
   Forms
   ============================================= */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: .82rem;
  color: var(--muted);
  font-weight: 500;
}

input, select, textarea {
  background: var(--navy);
  border: 1px solid var(--navy-border);
  border-radius: 8px;
  padding: .65rem .85rem;
  color: var(--white);
  font-family: var(--font);
  font-size: .9rem;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
  direction: rtl;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(201,168,76,.12);
}
textarea { resize: vertical; min-height: 90px; }

select option { background: var(--navy-mid); }

/* =============================================
   Buttons
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .6rem 1.25rem;
  border-radius: 8px;
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--gold);
  color: var(--navy);
}
.btn-primary:hover { background: var(--gold-light); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--navy-border);
  color: var(--white);
}
.btn-outline:hover { border-color: var(--gold-dim); background: var(--navy-light); }

.btn-success {
  background: rgba(62,207,142,.15);
  color: var(--success);
  border: 1px solid rgba(62,207,142,.3);
}
.btn-success:hover { background: rgba(62,207,142,.25); }

.btn-danger {
  background: rgba(224,82,82,.15);
  color: var(--danger);
  border: 1px solid rgba(224,82,82,.3);
}
.btn-danger:hover { background: rgba(224,82,82,.25); }

.btn-sm { padding: .4rem .85rem; font-size: .8rem; }
.btn-lg { padding: .8rem 1.75rem; font-size: 1rem; }

/* =============================================
   Filter Bar
   ============================================= */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1.25rem;
  background: var(--navy-mid);
  border: 1px solid var(--navy-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.filter-bar input,
.filter-bar select {
  width: auto;
  min-width: 160px;
  padding: .5rem .75rem;
  font-size: .85rem;
}

/* =============================================
   Timeline (history)
   ============================================= */
.timeline { position: relative; padding-right: 1.5rem; }
.timeline::before {
  content: '';
  position: absolute;
  right: .45rem; top: 0; bottom: 0;
  width: 2px;
  background: var(--navy-border);
}

.timeline-item {
  position: relative;
  padding: 0 1.5rem .5rem 0;
  margin-bottom: 1rem;
}

.timeline-dot {
  position: absolute;
  right: -2px;
  top: .3rem;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--navy-border);
  border: 2px solid var(--navy-mid);
}
.timeline-dot.active { background: var(--gold); }

.timeline-title {
  font-weight: 600;
  font-size: .875rem;
  margin-bottom: .2rem;
}
.timeline-meta {
  font-size: .78rem;
  color: var(--muted);
  font-family: var(--mono);
}

/* =============================================
   Alert / Flash messages
   ============================================= */
.alert {
  border-radius: var(--radius);
  padding: .85rem 1.25rem;
  margin-bottom: 1rem;
  font-size: .875rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.alert-success { background: rgba(62,207,142,.12); border: 1px solid rgba(62,207,142,.3); color: var(--success); }
.alert-danger   { background: rgba(224,82,82,.12);  border: 1px solid rgba(224,82,82,.3);  color: var(--danger); }
.alert-info     { background: rgba(56,189,248,.12); border: 1px solid rgba(56,189,248,.3); color: var(--info); }

/* =============================================
   Login Page
   ============================================= */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  top: -30%; left: -20%;
  width: 700px; height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,168,76,.06) 0%, transparent 70%);
  pointer-events: none;
}

.login-box {
  background: var(--navy-mid);
  border: 1px solid var(--navy-border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  position: relative;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .logo-icon { font-size: 2.5rem; display: block; margin-bottom: .5rem; }
.login-logo h1 { font-size: 1.25rem; font-weight: 700; color: var(--white); }
.login-logo p  { font-size: .8rem; color: var(--muted); margin-top: .25rem; }

/* =============================================
   Step indicator
   ============================================= */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  padding-bottom: .25rem;
}
.step {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .75rem;
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
}
.step.done { color: var(--success); }
.step.current { color: var(--gold); font-weight: 600; }
.step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  flex-shrink: 0;
}
.step.done .step-num { background: var(--success); border-color: var(--success); color: var(--navy); }
.step-arrow { color: var(--navy-border); font-size: .9rem; }

/* =============================================
   Modal
   ============================================= */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--navy-mid);
  border: 1px solid var(--navy-border);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  padding: 2rem;
  transform: translateY(20px);
  transition: transform .25s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--navy-border);
}

.modal-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-right: 0;
  }
  .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar input, .filter-bar select { width: 100%; }
}

/* =============================================
   Misc utilities
   ============================================= */
.text-muted { color: var(--muted); }
.text-gold  { color: var(--gold); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.font-mono  { font-family: var(--mono); }
.d-flex     { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }
.flex-1 { flex: 1; }
.justify-between { justify-content: space-between; }
.text-sm { font-size: .82rem; }
.fw-600 { font-weight: 600; }
