/* ============================================================
   TERANGA IMMO — Design System
   ============================================================ */

:root {
  --primary: #1a5276;
  --primary-dark: #154360;
  --primary-light: #2980b9;
  --accent: #f39c12;
  --accent-light: #f8c471;
  --success: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --info: #2980b9;
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --header-height: 60px;
  --text-dark: #1a202c;
  --text-muted: #718096;
  --bg-light: #f7f8fc;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-light);
  color: var(--text-dark);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

/* ── Layout ──────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .3s ease;
}

.content-area {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1a3a5c 0%, #0f2540 100%);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  transition: transform .3s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

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

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: white;
}

.brand-sub {
  font-size: 10px;
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.sidebar-user {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
  margin-top: 3px;
  display: inline-block;
}

.role-admin { background: #e74c3c; color: white; }
.role-manager { background: #2980b9; color: white; }
.role-accounting { background: #27ae60; color: white; }
.role-staff { background: #7f8c8d; color: white; }

.sidebar-nav {
  list-style: none;
  padding: 12px 0;
  margin: 0;
  flex: 1;
}

.nav-label {
  padding: 12px 18px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.35);
  font-weight: 600;
}

.nav-item .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  border-radius: 0 24px 24px 0;
  margin-right: 12px;
  transition: all .2s;
  font-size: 13.5px;
  font-weight: 500;
}

.nav-item .nav-link i {
  font-size: 17px;
  width: 22px;
  flex-shrink: 0;
}

.nav-item .nav-link:hover {
  background: rgba(255,255,255,.1);
  color: white;
}

.nav-item .nav-link.active {
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all .2s;
}

.btn-logout:hover {
  color: white;
  background: rgba(255,255,255,.08);
}

/* ── Header ──────────────────────────────────────────────── */
.top-header {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-toggle-btn {
  color: var(--text-dark) !important;
  padding: 4px;
}

.header-date {
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-menu-btn {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--text-dark) !important;
}

.avatar-sm {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.breadcrumb-item + .breadcrumb-item::before { color: var(--border); }
.breadcrumb-item a { color: var(--primary); text-decoration: none; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: white;
}

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

.card-body { padding: 20px; }

/* ── Stat Cards ──────────────────────────────────────────── */
.stat-card {
  border-radius: var(--radius);
  padding: 20px;
  color: white;
  position: relative;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.stat-card::before {
  content: '';
  position: absolute;
  right: -20px;
  top: -20px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}

.stat-icon {
  font-size: 32px;
  opacity: .85;
  margin-bottom: 12px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  opacity: .8;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.stat-sub {
  font-size: 11px;
  opacity: .7;
  margin-top: 8px;
}

.bg-primary-gradient { background: linear-gradient(135deg, #1a5276, #2980b9); }
.bg-success-gradient { background: linear-gradient(135deg, #1e8449, #27ae60); }
.bg-warning-gradient { background: linear-gradient(135deg, #b7770d, #f39c12); }
.bg-danger-gradient  { background: linear-gradient(135deg, #922b21, #e74c3c); }
.bg-info-gradient    { background: linear-gradient(135deg, #1a5276, #5dade2); }
.bg-purple-gradient  { background: linear-gradient(135deg, #6c3483, #9b59b6); }

/* ── Badges & Status ─────────────────────────────────────── */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 20px;
}

.status-Disponible, .status-disponible { background: #d4efdf; color: #1e8449; }
.status-Loué, .status-loué { background: #d6eaf8; color: #1a5276; }
.status-maintenance, .status-En.maintenance { background: #fdebd0; color: #a04000; }
.status-Vendu, .status-vendu { background: #e8daef; color: #6c3483; }
.status-Réservé { background: #fde8e8; color: #922b21; }

.status-payé { background: #d4efdf; color: #1e8449; }
.status-en_attente { background: #fef9e7; color: #b7770d; }
.status-en_retard { background: #fadbd8; color: #922b21; }
.status-partiel { background: #d6eaf8; color: #1a5276; }

.status-ouverte { background: #fdebd0; color: #a04000; }
.status-en_cours { background: #d6eaf8; color: #1a5276; }
.status-terminée { background: #d4efdf; color: #1e8449; }
.status-annulée { background: #e8e8e8; color: #666; }

.priority-urgente { background: #fadbd8; color: #922b21; }
.priority-haute { background: #fdebd0; color: #a04000; }
.priority-normale { background: #d6eaf8; color: #1a5276; }
.priority-basse { background: #e8e8e8; color: #666; }

.role-badge-admin { background: #fadbd8; color: #922b21; }
.role-badge-manager { background: #d6eaf8; color: #1a5276; }
.role-badge-accounting { background: #d4efdf; color: #1e8449; }
.role-badge-staff { background: #e8e8e8; color: #666; }

/* ── Tables ──────────────────────────────────────────────── */
.table {
  font-size: 13.5px;
}

.table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  padding: 10px 12px;
  background: #fafbfc;
}

.table tbody td {
  padding: 12px;
  vertical-align: middle;
  border-bottom: 1px solid #f0f0f0;
}

.table tbody tr:hover { background: #f8faff; }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Forms ───────────────────────────────────────────────── */
.form-label {
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--text-dark);
}

.form-control, .form-select {
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  padding: 8px 12px;
  transition: border-color .2s, box-shadow .2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,82,118,.1);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  transition: all .2s;
}

.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; line-height: 1; }

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
}

.page-title small {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 8px;
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  padding: 12px 16px;
}

.alert-success { background: #d4efdf; color: #1a6635; }
.alert-danger { background: #fadbd8; color: #922b21; }
.alert-info { background: #d6eaf8; color: #154360; }

/* ── Amount cells ────────────────────────────────────────── */
.amount { font-weight: 600; font-family: 'Courier New', monospace; }
.amount-positive { color: var(--success); }
.amount-negative { color: var(--danger); }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 64px;
  opacity: .3;
  margin-bottom: 16px;
}

/* ── Payment method icons ────────────────────────────────── */
.payment-wave { color: #00c3ff; }
.payment-orange { color: #ff6600; }
.payment-free { color: #cc0000; }
.payment-cash { color: #27ae60; }
.payment-virement { color: #1a5276; }

/* ── Charts ──────────────────────────────────────────────── */
.chart-container {
  position: relative;
  height: 280px;
}

/* ── Mobile Overlay ──────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.show {
    display: block;
  }
  .main-content {
    margin-left: 0;
  }
  .content-area {
    padding: 16px;
  }
  .stat-value { font-size: 22px; }
}

@media (max-width: 575px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .content-area { padding: 12px; }
  .card-body { padding: 14px; }
  .table-responsive-xs { overflow-x: auto; }
}

/* ── Login page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f2540 0%, #1a5276 60%, #2980b9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-brand .logo-icon {
  font-size: 48px;
  color: var(--primary);
}

.login-brand h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  margin: 8px 0 4px;
}

.login-brand p {
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Misc Utils ──────────────────────────────────────────── */
.text-cfa { font-family: 'Courier New', monospace; font-weight: 600; }
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.info-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f5f5f5;
}

.info-row:last-child { border-bottom: none; }

.info-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 140px;
  flex-shrink: 0;
}

.info-value {
  font-size: 13.5px;
  color: var(--text-dark);
  font-weight: 500;
}

.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
/* ── Modals & Previews ────────────────────────────────────── */
.modal-content {
  border-radius: var(--radius);
  overflow: hidden;
}

.modal-header {
  border-bottom: none;
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem;
}

.btn-check:checked + .btn-outline-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(26, 82, 118, 0.2);
}

#receiptFrame {
  background: #333;
  border-radius: 4px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
