/* ==========================================================================
   CRM Locatif - SCI B.B Maurice THOREZ
   Feuille de styles personnalisée & Spécifications Quittance A4
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --font-ui: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-quittance: Arial, Helvetica, sans-serif;
}

body {
  font-family: var(--font-ui);
  background-color: #f8fafc;
  color: #0f172a;
  overflow-x: hidden;
}

/* Typographie spécifique pour la quittance de loyer */
.font-arial {
  font-family: var(--font-quittance) !important;
}

/* Scrollbar élégante */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Page Quittance A4 réaliste */
.quittance-container-wrapper {
  background: #64748b;
  padding: 2.5rem 1rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100%;
  overflow-y: auto;
  border-radius: 0.75rem;
}

.quittance-page {
  width: 210mm;
  min-height: 297mm;
  background: #ffffff;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.05);
  margin: 0 auto;
  box-sizing: border-box;
  position: relative;
  transition: transform 0.2s ease;
}

/* Animations et transitions */
.fade-in {
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* Toast Notifications */
.toast-item {
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Impression : Uniquement la quittance */
@media print {
  body * {
    visibility: hidden;
  }

  .sidebar,
  .top-navbar,
  .no-print,
  button,
  header {
    display: none !important;
  }

  #quittance-print-target,
  #quittance-print-target * {
    visibility: visible;
  }

  #quittance-print-target {
    position: absolute;
    left: 0;
    top: 0;
    width: 210mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    padding: 20mm 20mm 15mm 20mm !important;
    box-shadow: none !important;
    background: #ffffff !important;
  }

  @page {
    size: A4 portrait;
    margin: 0;
  }
}

/* Grille Calendrier */
.calendar-day-cell {
  min-height: 105px;
  transition: all 0.15s ease;
}

.calendar-day-cell:hover {
  background-color: #f1f5f9;
}

/* Statuts colorés */
.badge-paye {
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.badge-attente {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-retard {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.badge-relance-mail {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-relance-tel {
  background-color: #f3e8ff;
  color: #6b21a8;
  border: 1px solid #e9d5ff;
}

/* ==========================================================================
   ANIMATIONS & MICRO-INTERACTIONS DYNAMIQUES
   ========================================================================== */

/* Carte de graphique moderne avec survol dynamique */
.chart-card {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.chart-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 32px -8px rgba(99, 102, 241, 0.12), 0 4px 12px -2px rgba(0, 0, 0, 0.05);
}

/* Effet de lueur et pulsation pour les alertes urgentes */
@keyframes pulse-subtle {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.85;
  }
}

.animate-pulse-subtle {
  animation: pulse-subtle 2.5s infinite ease-in-out;
}

@keyframes glow-red {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(244, 63, 94, 0);
  }
}

.alert-pulse-glow {
  animation: glow-red 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

/* Animation d'apparition en fondu et zoom léger */
@keyframes fadeInUpScale {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.animate-fade-in-scale {
  animation: fadeInUpScale 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Compteur de statistiques interactif */
.counter-value {
  transition: color 0.2s ease, transform 0.2s ease;
  display: inline-block;
}

.counter-value:hover {
  transform: scale(1.03);
}

/* Style des pills d'émojis */
.emoji-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05));
  transition: transform 0.2s ease;
}

.emoji-badge:hover {
  transform: scale(1.2) rotate(5deg);
}

/* ==========================================================================
   RESPONSIVE DESIGN UNIVERSEL MULTI-APPAREILS
   (iPhone, iPad, Pliables Fold/Flip, Galaxy S/A/Tab, Desktop, Ultra-wide 4K)
   ========================================================================== */

/* 1. Safe Areas iOS & Android (Dynamic Island, encoches, barre d'accueil) */
.safe-area-top {
  padding-top: env(safe-area-inset-top, 0px);
}
.safe-area-bottom {
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
}
.safe-area-left {
  padding-left: env(safe-area-inset-left, 0px);
}
.safe-area-right {
  padding-right: env(safe-area-inset-right, 0px);
}

/* 2. Barre de Navigation Mobile Native (Smartphones & Pliables fermés) */
#mobile-bottom-nav {
  padding-bottom: max(0.4rem, env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 25px -2px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.mobile-nav-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: all 0.2s ease;
}

.mobile-nav-btn.active {
  color: #818cf8 !important;
}

.mobile-nav-btn.active span:first-child {
  transform: scale(1.18);
  filter: drop-shadow(0 2px 6px rgba(99, 102, 241, 0.4));
}

/* 3. Conteneur et mise à l'échelle adaptative Quittance A4 */
#quittance-preview-container {
  -webkit-overflow-scrolling: touch;
  position: relative;
  width: 100%;
}

#quittance-scale-wrapper {
  --quittance-scale: 1;
  transform: scale(var(--quittance-scale));
  transform-origin: top center;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

/* 4. Format Ultra-Compact (< 380px : Écrans externes Flip, iPhone mini/SE) */
@media (max-width: 380px) {
  .chart-card {
    padding: 0.75rem !important;
  }
  .mobile-nav-btn {
    min-width: 48px !important;
  }
  .mobile-nav-btn span:last-child {
    font-size: 9px !important;
  }
}

/* 5. Format Pliable Déplié (Galaxy Z Fold, iPhone pliant ~4:3, 768px-900px) */
@media (min-width: 600px) and (max-width: 900px) and (min-aspect-ratio: 3/4) and (max-aspect-ratio: 4/3) {
  .view-section {
    max-width: 100% !important;
  }
}

@media (horizontal-viewport-segments: 2) {
  #quittance-zoom-controls {
    flex-wrap: nowrap;
  }
}

/* 6. Écrans Ultra-Larges & 4K (> 1920px et > 2560px) */
@media (min-width: 1920px) {
  .chart-card {
    padding: 1.5rem;
  }
  .quittance-container-wrapper {
    padding: 3rem 2rem;
  }
}

@media (min-width: 2560px) {
  body {
    font-size: 15.5px;
  }
}

/* ==========================================================================
   BARRE DE NAVIGATION BASSE & DÉPLACEMENT DROITE / GAUCHE
   ========================================================================== */

/* Masquage propre de la scrollbar sur le carrousel horizontal */
.scrollbar-none::-webkit-scrollbar,
.no-scrollbar::-webkit-scrollbar {
  display: none !important;
}
.scrollbar-none,
.no-scrollbar {
  -ms-overflow-style: none !important;
  scrollbar-width: none !important;
}

/* Animations de transition glissante (Slide Droite / Gauche) */
@keyframes slideFromRight {
  0% {
    opacity: 0;
    transform: translateX(45px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideFromLeft {
  0% {
    opacity: 0;
    transform: translateX(-45px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.slide-from-right {
  animation: slideFromRight 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.slide-from-left {
  animation: slideFromLeft 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Style de la barre de navigation basse dockée */
#bottom-nav-container {
  touch-action: pan-x pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.bottom-nav-item {
  scroll-snap-align: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-nav-item.active {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 14px -1px rgba(79, 70, 229, 0.45);
  transform: translateY(-2px);
}

.bottom-nav-item.active .nav-icon {
  transform: scale(1.15);
}

/* Espace au bas du document pour que le contenu ne soit jamais masqué par la barre */
.has-bottom-nav {
  padding-bottom: 6rem !important;
}

/* ==========================================================================
   MODE NUIT (DARK MODE) — Activé par la classe .dark sur <html>
   ========================================================================== */

/* ── Transitions globales pour un basculement fluide ────────────────────── */
*,
*::before,
*::after {
  transition-property: background-color, border-color, color, fill, stroke, box-shadow;
  transition-duration: 200ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Exceptions : les éléments qui ne doivent PAS hériter des transitions globales */
.no-transition,
.no-transition *,
[data-lucide],
canvas,
img,
video,
.quittance-page,
.quittance-page * {
  transition: none !important;
}

/* ── Body & fond principal ──────────────────────────────────────────────── */
.dark body {
  background-color: #0d1117;
  color: #e2e8f0;
}

/* ── Zone principale de contenu (main scrollable) ───────────────────────── */
.dark main,
.dark #main-content {
  background-color: #0d1117;
}

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.dark #main-topbar,
.dark header {
  background-color: #161b22 !important;
  border-bottom-color: #30363d !important;
}

/* ── Cards & Panels blancs → dark ──────────────────────────────────────── */
.dark .bg-white {
  background-color: #161b22 !important;
}

.dark .bg-slate-50 {
  background-color: #0d1117 !important;
}

.dark .bg-slate-100 {
  background-color: #1c2128 !important;
}

.dark .bg-slate-100\/70 {
  background-color: rgba(28, 33, 40, 0.7) !important;
}

.dark .bg-slate-50\/50 {
  background-color: rgba(13, 17, 23, 0.5) !important;
}

/* ── Bordures ───────────────────────────────────────────────────────────── */
.dark .border-slate-200,
.dark .border-slate-200\/80 {
  border-color: #30363d !important;
}

.dark .border-slate-100 {
  border-color: #21262d !important;
}

.dark .divide-slate-100 > * + * {
  border-color: #21262d !important;
}

.dark .divide-y > * + * {
  border-color: #21262d !important;
}

/* ── Textes ─────────────────────────────────────────────────────────────── */
.dark .text-slate-900 {
  color: #f0f6fc !important;
}

.dark .text-slate-800 {
  color: #e6edf3 !important;
}

.dark .text-slate-700 {
  color: #c9d1d9 !important;
}

.dark .text-slate-600 {
  color: #8b949e !important;
}

.dark .text-slate-500 {
  color: #6e7681 !important;
}

/* ── Inputs & Select ────────────────────────────────────────────────────── */
.dark input[type="text"],
.dark input[type="number"],
.dark input[type="email"],
.dark input[type="date"],
.dark input[type="password"],
.dark textarea,
.dark select {
  background-color: #0d1117 !important;
  border-color: #30363d !important;
  color: #e6edf3 !important;
}

.dark input::placeholder,
.dark textarea::placeholder {
  color: #484f58 !important;
}

/* ── Tableaux ───────────────────────────────────────────────────────────── */
.dark table thead tr,
.dark .bg-slate-50 th {
  background-color: #161b22 !important;
}

.dark tbody tr:hover {
  background-color: #1c2128 !important;
}

/* ── Modals ─────────────────────────────────────────────────────────────── */
.dark .modal-backdrop > div,
.dark [id^="modal-"] > div {
  background-color: #161b22 !important;
  border: 1px solid #30363d;
}

/* ── Badges de statut ───────────────────────────────────────────────────── */
.dark .badge-paye   { background-color: #14532d !important; color: #86efac !important; border-color: #166534 !important; }
.dark .badge-attente{ background-color: #78350f !important; color: #fde68a !important; border-color: #92400e !important; }
.dark .badge-retard { background-color: #7f1d1d !important; color: #fca5a5 !important; border-color: #991b1b !important; }
.dark .badge-relance-mail { background-color: #0c4a6e !important; color: #7dd3fc !important; border-color: #0284c7 !important; }
.dark .badge-relance-tel  { background-color: #581c87 !important; color: #d8b4fe !important; border-color: #7e22ce !important; }

/* ── Calendrier ─────────────────────────────────────────────────────────── */
.dark #cal-days-grid .day-cell {
  background-color: #161b22;
  border-color: #21262d;
  color: #c9d1d9;
}

.dark #cal-days-grid .day-cell.today {
  background-color: #1e2a4a !important;
  border-color: #3b82f6 !important;
}

/* ── Quittance wrapper (zone grise fond de preview) ─────────────────────── */
.dark .quittance-container-wrapper {
  background: #1c2128 !important;
}

/* ── Onglets de navigation ──────────────────────────────────────────────── */
.dark .nav-item.active,
.dark .nav-item:hover {
  background-color: #21262d !important;
}

/* ── Cards avec bg indigo/violet (KPIs) ─────────────────────────────────── */
.dark .bg-indigo-50 {
  background-color: #1e1b4b !important;
}

.dark .bg-indigo-50\/50 {
  background-color: rgba(30, 27, 75, 0.5) !important;
}

.dark .border-indigo-100 {
  border-color: #3730a3 !important;
}

/* ── Scrollbar dark ─────────────────────────────────────────────────────── */
.dark ::-webkit-scrollbar-track {
  background: #161b22;
}

.dark ::-webkit-scrollbar-thumb {
  background: #30363d;
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: #484f58;
}

/* ── Shadow ajustements ─────────────────────────────────────────────────── */
.dark .shadow-sm {
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.4) !important;
}

.dark .shadow-md {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.4) !important;
}

/* ── Hover states ───────────────────────────────────────────────────────── */
.dark .hover\:bg-slate-50:hover {
  background-color: #21262d !important;
}

.dark .hover\:bg-slate-100:hover {
  background-color: #1c2128 !important;
}

/* ── Barre de navigation basse mobile ───────────────────────────────────── */

/* Cache la scrollbar horizontale dans la piste de la barre */
#bottom-nav > div::-webkit-scrollbar {
  display: none;
}

/* Etat actif : fond dégradé + indicateur en haut du bouton */
#bottom-nav .mobile-nav-btn.active {
  color: #6366f1;        /* indigo-500 */
  background-color: rgba(99, 102, 241, 0.08);
  position: relative;
}

#bottom-nav .mobile-nav-btn.active::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  border-radius: 999px;
  background: #6366f1;
}

/* Masque la barre quand l'écran de connexion est visible */
body:has(#auth-screen:not(.hidden)) #bottom-nav {
  display: none;
}

/* Espacement du contenu principal pour ne pas être caché par la barre */
@media (max-width: 767px) {
  main {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* Dark mode : barre déjà bien couverte par le classe Tailwind dark:bg-slate-900/95 */
.dark #bottom-nav {
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.4);
}

.dark #bottom-nav .mobile-nav-btn.active {
  color: #818cf8;        /* indigo-400 */
  background-color: rgba(129, 140, 248, 0.10);
}

.dark #bottom-nav .mobile-nav-btn.active::before {
  background: #818cf8;
}
