/* ============================================================
   debt_manager / css / main.css  — النسخة النظيفة
============================================================ */

/* ── Print styles ──────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .stats-grid, .currency-tabs,
  .modal-actions-bar, .modal-topbar button,
  .nav-item, .btn, .icon-btn, .action-btns,
  .bottom-nav, .menu-toggle { display: none !important; }

  body { background: #fff !important; color: #111 !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  .statement-overlay { position: static !important; background: none !important; }
  .statement-modal { border: none !important; max-height: none !important; box-shadow: none !important; }
  .sum-table th { background: #f0f0f0 !important; color: #333 !important; }
  .detail-row { background: #fafafa !important; border-color: #ddd !important; }
  .statement-header { background: #f5f5f5 !important; border-color: #ddd !important; }
}

/* ── SweetAlert2 — يرث ألوان الثيم ────────────────────────── */
.swal2-popup {
  font-family: 'Cairo', sans-serif !important;
  direction: rtl !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 18px !important;
}
.swal2-title     { color: var(--text) !important; font-size: 18px !important; }
.swal2-html-container { color: var(--text-dim) !important; }
.swal2-input, .swal2-textarea, .swal2-select {
  background: var(--input-bg) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  font-family: 'Cairo', sans-serif !important;
}
.swal2-input:focus, .swal2-textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-glow) !important;
}
.swal2-confirm { font-family: 'Cairo', sans-serif !important; font-weight: 700 !important; }
.swal2-cancel {
  background: var(--surface2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  font-family: 'Cairo', sans-serif !important;
  font-weight: 700 !important;
}
.swal2-icon.swal2-warning { border-color: var(--gold)  !important; color: var(--gold)  !important; }
.swal2-icon.swal2-error   { border-color: var(--red)   !important; color: var(--red)   !important; }
.swal2-icon.swal2-success { border-color: var(--green) !important; color: var(--green) !important; }
.swal2-icon.swal2-success [class^='swal2-success-line'] { background: var(--green) !important; }
.swal2-icon.swal2-success .swal2-success-ring { border-color: rgba(46,213,115,.3) !important; }

/* ── Scrollbar global ──────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Payments drawer ──────────────────────────────────────── */
.payments-drawer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(5px);
  z-index: 150;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
}
.payments-drawer.open { display: flex; }

.drawer-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  animation: drawerUp .3s cubic-bezier(.4,0,.2,1);
}

@keyframes drawerUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.drawer-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0;
  background: var(--surface);
  z-index: 2;
}
.drawer-header h4 { font-size: 16px; font-weight: 800; color: var(--text); }

.payment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  transition: background .15s;
}
.payment-item:hover { background: rgba(0,0,0,.04); }
.payment-item:last-child { border-bottom: none; }
.payment-amount { font-size: 15px; font-weight: 900; color: var(--green); margin-right: auto; }
.payment-date   { font-size: 11px; color: var(--text-muted); }
.payment-note   { font-size: 11px; color: var(--text-muted); }

/* ── Progress bar ─────────────────────────────────────────── */
.progress-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .5s ease;
  background: linear-gradient(90deg, var(--accent), var(--green));
}

/* ── Responsive sidebar toggle ───────────────────────────── */
.menu-toggle {
  display: none;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  place-items: center;
  font-size: 16px;
}

/* ── Mobile card list ────────────────────────────────────── */
.debt-card-list { display: none; }

/* ── Light theme overrides ───────────────────────────────── */
[data-theme="light"] .drawer-panel,
[data-theme="light"] .statement-modal { background: var(--surface); border-color: var(--border); }

[data-theme="light"] .debt-table thead th { background: var(--surface2); }
[data-theme="light"] .debt-table tbody tr:hover { background: rgba(0,0,0,.02); }
[data-theme="light"] .person-card:hover { border-color: var(--border2); }
[data-theme="light"] .modal-topbar { background: var(--surface); }
[data-theme="light"] .drawer-header { background: var(--surface); }
[data-theme="light"] .nav-item.active {
  background: rgba(0,168,150,.1);
  border-color: rgba(0,168,150,.25);
}
[data-theme="light"] .bottom-nav-item.active { color: var(--accent); }
[data-theme="light"] .toast { background: var(--surface); border-color: var(--border); color: var(--text); }

/* ── Bottom Nav ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .menu-toggle { display: grid; }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 40;
  }
  .sidebar-overlay.open { display: block; }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--nav-bg);
    border-top: 1px solid var(--border);
    z-index: 55;
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,.25);
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 4px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 9px;
    font-weight: 700;
    border: none;
    background: none;
    font-family: 'Cairo', sans-serif;
    position: relative;
    transition: color .2s;
  }
  .bottom-nav-item i { font-size: 18px; }
  .bottom-nav-item.active { color: var(--accent); }
  .bottom-nav-item .bnav-badge {
    position: absolute;
    top: 4px; left: 50%;
    transform: translateX(6px);
    background: var(--red);
    color: white;
    font-size: 9px;
    width: 16px; height: 16px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: 900;
  }
  .bottom-nav-item .bnav-badge.visible { display: flex; }
}

@media (min-width: 769px) {
  .bottom-nav { display: none !important; }
}

/* ── Mobile debt cards ≤ 640px ───────────────────────────── */
@media (max-width: 640px) {
  .debt-table-wrap { display: none; }
  .debt-card-list  { display: block; padding: 0; }

  /* كل بطاقة */
  .dcard {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  /* السطر العلوي: أفاتار + اسم */
  .dcard-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }
  .dcard-head .mini-avatar {
    width: 36px; height: 36px;
    border-radius: 9px;
    font-size: 14px;
    flex-shrink: 0;
  }
  .dcard-head-name {
    font-weight: 800;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    flex: 1;
    min-width: 0;
  }

  /* صف المبلغ: يملأ العرض كاملاً */
  .dcard-amount-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
    margin-bottom: 8px;
    gap: 8px;
  }
  .dcard-amount-val {
    font-weight: 900;
    font-size: 16px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* شارات النوع والعملة */
  .dcard-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
  }

  /* شبكة التفاصيل 2×2 */
  .dcard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 8px;
  }
  .dcard-cell {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 6px 8px;
    min-width: 0;
    overflow: hidden;
  }
  .dcard-cell-lbl {
    font-size: 9px;
    color: var(--text-muted);
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
  }
  .dcard-cell-val {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* أزرار الإجراءات */
  .dcard-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }
  .dcard-actions .btn {
    font-size: 11px !important;
    padding: 7px 4px !important;
    justify-content: center;
    min-width: 0;
    white-space: nowrap;
  }
}
