/* ============================================
   RESLANCO — Global Stylesheet v1.0
   ============================================ */

:root {
  --primary:        #1e40af;
  --primary-hover:  #1e3a8a;
  --primary-light:  #dbeafe;
  --secondary:      #0d9488;
  --secondary-light:#ccfbf1;
  --success:        #16a34a;
  --warning:        #d97706;
  --danger:         #dc2626;
  --info:           #0284c7;

  --gray-50:  #f8fafc; --gray-100: #f1f5f9;
  --gray-200: #e2e8f0; --gray-300: #cbd5e1;
  --gray-400: #94a3b8; --gray-500: #64748b;
  --gray-600: #475569; --gray-700: #334155;
  --gray-800: #1e293b; --gray-900: #0f172a;

  --sidebar-w:   260px;
  --topbar-h:    64px;
  --radius:      10px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.07);
  --shadow-md:   0 4px 12px rgba(0,0,0,.1);
  --shadow-lg:   0 8px 28px rgba(0,0,0,.13);

  --font:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-ar: 'Cairo', 'Inter', sans-serif;

  /* Light theme defaults */
  --bg:      #f8fafc;
  --bg-card: #ffffff;
  --bg-side: #1e293b;
  --text:    #1e293b;
  --muted:   #64748b;
  --border:  #e2e8f0;
}

[data-theme="dark"] {
  --bg:      #0f172a;
  --bg-card: #1e293b;
  --bg-side: #0f172a;
  --text:    #e2e8f0;
  --muted:   #94a3b8;
  --border:  #334155;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
}
body[dir="rtl"] { font-family: var(--font-ar); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* ============ LAYOUT ============ */
.layout { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-side);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform .28s ease;
}
[dir="rtl"] .sidebar { left: auto; right: 0; }

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sidebar-brand a {
  color: #fff;
  text-decoration: none;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -.5px;
}
.sidebar-brand a span { color: #5eead4; }

.sidebar-nav  { padding: .5rem 0; flex: 1; }
.sidebar-sect {
  padding: .35rem 1.25rem .1rem;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.3);
  margin-top: .5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1.5rem;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  position: relative;
  transition: all .15s;
}
.nav-link i { font-size: 1rem; width: 20px; flex-shrink: 0; }
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(255,255,255,.07); }
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: #5eead4;
  border-radius: 0 3px 3px 0;
}
[dir="rtl"] .nav-link.active::before { left:auto; right:0; border-radius:3px 0 0 3px; }
.nav-link .nbadge { margin-left: auto; font-size: .7rem; }
[dir="rtl"] .nav-link .nbadge { margin-left: 0; margin-right: auto; }

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 900;
}
.topbar-left { flex: 1; display: flex; align-items: center; gap: .75rem; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.3rem;
  padding: .3rem;
  line-height: 1;
  display: none;
}

.search-wrap { position: relative; max-width: 300px; flex: 1; }
.search-wrap i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; }
[dir="rtl"] .search-wrap i { left: auto; right: .75rem; }
.search-wrap input {
  width: 100%;
  padding: .5rem 1rem .5rem 2.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--gray-50);
  font-size: .875rem;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
  color: var(--text);
}
.search-wrap input:focus { border-color: var(--primary); }
[dir="rtl"] .search-wrap input { padding: .5rem 2.25rem .5rem 1rem; }

.icon-btn {
  width: 36px; height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: 1.1rem;
  transition: background .15s;
  position: relative;
}
.icon-btn:hover { background: var(--gray-100); }
.notif-dot {
  position: absolute;
  top: 5px; right: 5px;
  width: 7px; height: 7px;
  background: var(--danger);
  border-radius: 50%;
}

.user-chip {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .82rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* ---- Main ---- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
[dir="rtl"] .main { margin-left: 0; margin-right: var(--sidebar-w); }

.page { padding: 1.5rem 2rem; flex: 1; }

.page-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-title { font-size: 1.3rem; font-weight: 700; margin: 0; }
.page-sub   { color: var(--muted); font-size: .875rem; margin: 0; }

.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 999;
}
.overlay.show { display: block; }

/* ============ CARDS ============ */
.card-r {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-r-hdr {
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: .9rem;
}
.card-r-body { padding: 1.25rem; }

/* ---- Stat cards ---- */
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.stat:hover { box-shadow: var(--shadow-md); }
.stat-ico {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; flex-shrink: 0;
}
.ico-blue  { background: var(--primary-light);   color: var(--primary); }
.ico-teal  { background: var(--secondary-light);  color: var(--secondary); }
.ico-green { background: #dcfce7; color: var(--success); }
.ico-amber { background: #fef3c7; color: var(--warning); }
.stat-lbl  { font-size: .78rem; color: var(--muted); font-weight: 500; }
.stat-val  { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-note { font-size: .75rem; }
.note-up   { color: var(--success); }
.note-dn   { color: var(--danger); }

/* ============ TABLE ============ */
.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
.tbl th {
  background: var(--gray-50);
  color: var(--muted);
  font-weight: 600; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .5px;
  padding: .7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
[dir="rtl"] .tbl th { text-align: right; }
.tbl td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--gray-50); }
.tbl tbody tr:last-child td { border: none; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: 8px; border: none;
  cursor: pointer; font-size: .875rem; font-weight: 600;
  text-decoration: none; transition: all .15s;
  white-space: nowrap; font-family: inherit;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-pri  { background: var(--primary);   color: #fff; }
.btn-pri:hover  { background: var(--primary-hover); }
.btn-sec  { background: var(--secondary); color: #fff; }
.btn-sec:hover  { background: #0f766e; }
.btn-ok   { background: var(--success);   color: #fff; }
.btn-red  { background: var(--danger);    color: #fff; }
.btn-warn { background: var(--warning);   color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }

/* ============ BADGES ============ */
.badge-r {
  display: inline-flex; align-items: center;
  padding: .22rem .6rem;
  border-radius: 20px; font-size: .73rem; font-weight: 600;
}
.b-pending    { background:#fef3c7; color:#92400e; }
.b-processing { background:#dbeafe; color:#1e40af; }
.b-ready      { background:var(--secondary-light); color:#0f766e; }
.b-delivered  { background:#dcfce7; color:#15803d; }
.b-cancelled  { background:#fee2e2; color:#991b1b; }
.b-active     { background:#dcfce7; color:#15803d; }
.b-inactive   { background:var(--gray-200); color:var(--gray-600); }
.b-draft      { background:var(--gray-100); color:var(--gray-500); }
.b-paid       { background:#dcfce7; color:#15803d; }
.b-unpaid     { background:#fee2e2; color:#991b1b; }
.b-overdue    { background:#fce7f3; color:#9d174d; }
.b-partial    { background:#fef3c7; color:#92400e; }

/* ============ FORMS ============ */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .35rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: .6rem .875rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-card); color: var(--text);
  font-size: .9rem; outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,64,175,.1);
}

/* ============ PAGINATION ============ */
.pager { display: flex; align-items: center; gap: .25rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }
.pager a, .pager span {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px;
  border: 1px solid var(--border);
  font-size: .82rem; font-weight: 500;
  text-decoration: none; color: var(--text);
  transition: all .15s;
}
.pager a:hover { border-color: var(--primary); color: var(--primary); }
.pager .cur    { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============ TOAST ============ */
#toasts {
  position: fixed; top: 1rem; right: 1rem;
  z-index: 9999;
  display: flex; flex-direction: column; gap: .5rem;
}
[dir="rtl"] #toasts { right: auto; left: 1rem; }
.toast-r {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .8rem 1.1rem;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: .75rem;
  min-width: 260px; max-width: 380px;
  animation: tslide .25s ease;
}
.toast-r.success { border-left: 4px solid var(--success); }
.toast-r.error   { border-left: 4px solid var(--danger); }
.toast-r.info    { border-left: 4px solid var(--primary); }
.toast-r.warning { border-left: 4px solid var(--warning); }
@keyframes tslide { from { opacity:0; transform:translateX(16px); } to { opacity:1; transform:none; } }

/* ============ MODAL ============ */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1050;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--bg-card);
  border-radius: 14px;
  width: 100%; max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: mscale .2s ease;
}
@keyframes mscale { from { opacity:0; transform:scale(.95); } to { opacity:1; transform:none; } }
.modal-hdr { padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border); font-weight: 700; display:flex; align-items:center; justify-content:space-between; }
.modal-bdy { padding: 1.5rem; }
.modal-ftr { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display:flex; gap:.5rem; justify-content:flex-end; }

/* ============ MOBILE ============ */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0 !important; margin-right: 0 !important; }
  .sidebar-toggle { display: flex !important; }
  .page { padding: 1rem; }
}
@media (max-width: 575px) {
  .search-wrap { display: none; }
  .stat-val { font-size: 1.25rem; }
  .page-hdr { flex-direction: column; align-items: flex-start; }
}
