/* ============================================
   IMMOGESTION v2.2 - Thème bleu nuit global
   Sauf : quittances (toujours fond blanc pour impression)
   ============================================ */

:root {
  /* Couleurs neutres (utilisées dans cartes blanches) */
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #f5f5f3;
  --color-bg-tertiary: #ebebe8;
  --color-bg-info: #e6f1fb;
  --color-bg-success: #eaf3de;
  --color-bg-warning: #faeeda;
  --color-bg-danger: #fcebeb;
  --color-text-primary: #1a1a1a;
  --color-text-secondary: #5f5e5a;
  --color-text-tertiary: #888780;
  --color-text-info: #0c447c;
  --color-text-success: #27500a;
  --color-text-warning: #633806;
  --color-text-danger: #791f1f;
  --color-border-tertiary: rgba(0, 0, 0, 0.08);
  --color-border-secondary: rgba(0, 0, 0, 0.15);
  --color-border-primary: rgba(0, 0, 0, 0.25);
  --color-border-info: #378add;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Thème bleu nuit */
  --dash-bg-start: #0f172a;
  --dash-bg-mid: #1e293b;
  --dash-bg-end: #1e3a8a;
  --dash-accent: #3b82f6;
}

* { box-sizing: border-box; }

html {
  background-color: #0f172a;
  min-height: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background-color: #0f172a;
  background-image: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1e3a8a 100%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: cover;
  color: white;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app-root {
  min-height: 100vh;
  background: transparent;
}

.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: white;
}

/* ============ BOUTONS ============ */
.imm-btn-primary {
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: var(--border-radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(30, 58, 138, 0.2);
}
.imm-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}
.imm-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.imm-btn-secondary {
  background: white;
  color: var(--color-text-primary);
  border: 0.5px solid var(--color-border-secondary);
  padding: 9px 16px;
  border-radius: var(--border-radius-md);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.imm-btn-secondary:hover { background: var(--color-bg-secondary); }

.imm-btn-danger {
  background: var(--color-bg-danger);
  color: var(--color-text-danger);
  border: none;
  padding: 8px 14px;
  border-radius: var(--border-radius-md);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.imm-btn-danger:hover { opacity: 0.85; }

/* ============ FORMS ============ */
.imm-input {
  width: 100%;
  padding: 9px 12px;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--border-radius-md);
  font-size: 14px;
  background: white;
  color: var(--color-text-primary);
  font-family: inherit;
}
.imm-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--dash-accent);
  border-color: var(--dash-accent);
}
.imm-input:disabled { background: var(--color-bg-secondary); }

.imm-label {
  display: block;
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

/* ============ CARDS (glassmorphism sur fond bleu nuit) ============ */
.imm-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius-lg);
  padding: 1.25rem;
  color: var(--color-text-primary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.imm-stat {
  background: rgba(255, 255, 255, 0.95);
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius-md);
  padding: 1rem;
  color: var(--color-text-primary);
}
.imm-stat-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}
.imm-stat-value {
  font-size: 22px;
  font-weight: 500;
  color: var(--color-text-primary);
}

/* ============ NAVIGATION ============ */
.imm-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
  transition: all 0.15s;
  user-select: none;
}
.imm-nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}
.imm-nav-item.active {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  color: white;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* ============ TABLES ============ */
.imm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.imm-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 500;
  font-size: 12px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  background: var(--color-bg-secondary);
}
.imm-table td {
  padding: 12px;
  border-bottom: 0.5px solid var(--color-border-tertiary);
}
.imm-table tr:hover td { background: var(--color-bg-secondary); }
.imm-table tr:last-child td { border-bottom: none; }

/* ============ BADGES ============ */
.imm-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.imm-badge-success { background: var(--color-bg-success); color: var(--color-text-success); }
.imm-badge-warning { background: var(--color-bg-warning); color: var(--color-text-warning); }
.imm-badge-danger { background: var(--color-bg-danger); color: var(--color-text-danger); }
.imm-badge-info { background: var(--color-bg-info); color: var(--color-text-info); }
.imm-badge-secondary { background: rgba(148,163,184,0.18); color: #94a3b8; }

/* ============ MODAL ============ */
.imm-modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
}
.imm-modal {
  background: white;
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  color: var(--color-text-primary);
  box-shadow: 0 24px 48px rgba(0,0,0,0.3);
}

/* ============ TABS ============ */
.imm-tab {
  padding: 10px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  font-family: inherit;
}
.imm-tab.active {
  color: var(--color-text-primary);
  border-bottom-color: var(--dash-accent);
  font-weight: 500;
}

.admin-tab {
  padding: 8px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-text-secondary);
  border-radius: 6px;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s;
}
.admin-tab:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
}
.admin-tab.active {
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: white;
  font-weight: 500;
}

/* ============ LAYOUT ============ */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: transparent;
}

.app-sidebar {
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 0.5px solid rgba(255, 255, 255, 0.1);
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  color: white;
}

.app-main {
  padding: 1.5rem 2rem;
  overflow-y: auto;
  max-width: 1400px;
  width: 100%;
  color: white;
}

/* En-têtes blancs sur le fond bleu nuit */
.app-main h1,
.app-main h2 {
  color: white;
}
.app-main h1 + p,
.app-main h2 + p {
  color: rgba(255, 255, 255, 0.75);
}

/* ============ DASHBOARD CARDS (glassmorphism foncé) ============ */
.dash-stat {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 1.25rem;
  transition: all 0.2s;
  color: white;
}
.dash-stat:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.dash-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;
}
.dash-stat-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}
.dash-stat-value {
  font-size: 26px;
  font-weight: 600;
  color: white;
}

.dash-card {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 1.5rem;
  color: white;
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  color: white;
}
.dash-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 500;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);
}
.dash-table td {
  padding: 12px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
}
.dash-table tr:last-child td { border-bottom: none; }

/* ============ AUTH SCREEN ============ */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background: transparent;
}
.auth-box {
  width: 100%;
  max-width: 440px;
}
.auth-card {
  background: white;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(255, 255, 255, 0.3);
}

/* ============ QUITTANCE (fond blanc immuable pour impression) ============ */
.receipt-wrapper {
  background: white;
  min-height: 100vh;
  padding: 1.5rem 2rem;
  color: var(--color-text-primary);
}
.receipt-wrapper h1 {
  color: var(--color-text-primary);
}

.imm-receipt {
  background: white;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--border-radius-lg);
  padding: 2.5rem;
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  max-width: 800px;
  margin: 0 auto;
}

/* ============ TOAST ============ */
.imm-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  border-radius: var(--border-radius-md);
  font-size: 14px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  color: white;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s;
  max-width: calc(100vw - 48px);
}
.imm-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.imm-toast-success { background: rgba(34, 197, 94, 0.95); }
.imm-toast-error { background: rgba(220, 38, 38, 0.95); }
.imm-toast-info { background: rgba(59, 130, 246, 0.95); }

/* ============ UPLOAD ZONE ============ */
.upload-zone {
  border: 2px dashed var(--color-border-secondary);
  border-radius: var(--border-radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--color-bg-secondary);
}
.upload-zone:hover {
  border-color: var(--dash-accent);
  background: var(--color-bg-info);
}
.upload-zone.drag-over {
  border-color: var(--dash-accent);
  background: var(--color-bg-info);
  transform: scale(1.01);
}

/* ============ CHECKBOXES PERMISSIONS ============ */
.perm-cb {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--dash-accent);
}
.perm-cb-delete { accent-color: var(--color-text-danger); }

/* ============ ANIMATIONS ============ */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ============ MENU HAMBURGER (mobile) ============ */
.hamburger-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1001;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(30, 58, 138, 0.95);
  border: 0.5px solid rgba(255,255,255,0.2);
  color: white;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.hamburger-btn i { font-size: 24px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .hamburger-btn { display: flex; }

  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 270px;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    border-right: 0.5px solid rgba(255, 255, 255, 0.1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }
  .app-sidebar.open { transform: translateX(0); }

  .app-main { padding: 1rem; padding-top: 64px; }
  .imm-receipt { padding: 1.5rem; }

  /* Tableaux scrollables sur mobile */
  .imm-card { overflow-x: auto; }
}

@media (min-width: 769px) {
  .hamburger-btn { display: none !important; }
  .sidebar-overlay { display: none !important; }
}

/* ============ PRINT (quittance) ============ */
@media print {
  body { background: white !important; }
  body * { visibility: hidden; }
  #receipt-printable, #receipt-printable * { visibility: visible; }
  #receipt-printable {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    border: none;
    box-shadow: none;
  }
}
