/* ============================================================
   CUNITRACK — app.css (Nettoyé - Fusion)
   ============================================================ */

/* ── VARIABLES GLOBALES ─────────────────────────────────── */
:root {
  --vert-fonce:    #1B5E20;
  --vert-moyen:    #2E7D32;
  --vert-clair:    #E8F5E9;
  --bleu:          #0D47A1;
  --bleu-clair:    #E3F2FD;
  --rouge:         #B71C1C;
  --rouge-clair:   #FFEBEE;
  --orange:        #E65100;
  --orange-clair:  #FFF3E0;
  --jaune-clair:   #FFF9C4;
  --gris-fonce:    #212121;
  --gris-moyen:    #616161;
  --gris-clair:    #F5F5F5;
  --gris-border:   #E0E0E0;
  --blanc:         #FFFFFF;
  --ombre:         0 2px 8px rgba(0,0,0,0.12);
  --ombre-forte:   0 4px 16px rgba(0,0,0,0.18);
  --radius:        12px;
  --radius-small:  8px;
  --transition:    0.2s ease;
  --header-height: 56px;
  --nav-height:    64px;
}

/* ── RESET & BASE ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gris-clair);
  color: var(--gris-fonce);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
a { color: var(--vert-moyen); text-decoration: none; }
ul { list-style: none; }
.hidden { display: none !important; }

/* ── SPLASH SCREEN ──────────────────────────────────────── */
#splash-screen {
  position: fixed; inset: 0;
  background: var(--vert-fonce);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; z-index: 9999;
}
.splash-logo { font-size: 72px; animation: bounce 1s infinite alternate; }
.splash-title {
  font-size: 2rem; font-weight: 800;
  color: var(--blanc); letter-spacing: 4px;
}
.splash-subtitle { color: rgba(255,255,255,0.75); font-size: 0.9rem; }
.splash-spinner {
  width: 36px; height: 36px; margin-top: 24px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: var(--blanc);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-12px); } }

/* ── LOGIN ──────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  background: linear-gradient(160deg, var(--vert-fonce) 0%, var(--vert-moyen) 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
}
.login-header { text-align: center; color: var(--blanc); margin-bottom: 32px; }
.login-logo { font-size: 64px; margin-bottom: 8px; }
.login-header h1 { font-size: 2rem; font-weight: 800; letter-spacing: 3px; }
.login-header p { opacity: 0.8; margin-top: 6px; }
.login-form { width: 100%; max-width: 400px; padding: 28px; }
.login-demo {
  text-align: center; font-size: 0.8rem;
  color: var(--gris-moyen); margin-top: 16px;
}
.login-footer {
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem; margin-top: 24px;
}

/* ── STATUS BAR (offline) ───────────────────────────────── */
#status-bar {
  background: var(--orange);
  color: var(--blanc);
  text-align: center;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center;
  justify-content: center; gap: 8px;
}

/* ── HEADER ─────────────────────────────────────────────── */
#app-header {
  position: sticky; top: 0; z-index: 90;
  height: var(--header-height);
  background: var(--vert-fonce);
  color: var(--blanc);
  display: flex; align-items: center;
  padding: 0 12px; gap: 8px;
  box-shadow: var(--ombre);
}
.header-title { flex: 1; }
#page-title { font-size: 1.1rem; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.btn-icon {
  width: 40px; height: 40px; border-radius: 50%;
  color: var(--blanc); font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.btn-icon:hover { background: rgba(255,255,255,0.15); }

/* ── BOTTOM NAV ─────────────────────────────────────────── */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--blanc);
  border-top: 1px solid var(--gris-border);
  display: flex; align-items: stretch;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  z-index: 90;
}
.nav-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; position: relative;
  color: var(--gris-moyen);
  transition: color var(--transition);
  padding: 6px 0;
}
.nav-tab.active { color: var(--vert-fonce); }
.nav-tab.active .nav-icon { transform: translateY(-2px); }
.nav-icon { font-size: 1.4rem; transition: transform var(--transition); }
.nav-label { font-size: 0.7rem; font-weight: 600; }

/* ── PAGE CONTENT ───────────────────────────────────────── */
#page-content {
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 16px);
  min-height: calc(100vh - var(--header-height));
}

/* ── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--blanc);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  padding: 16px;
  margin-bottom: 12px;
}

/* ── KPI GRID ───────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.kpi-card {
  background: var(--blanc);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 4px;
  border-left: 4px solid var(--vert-moyen);
}
.kpi-card.bleu   { border-left-color: var(--bleu); }
.kpi-card.rouge  { border-left-color: var(--rouge); }
.kpi-card.orange { border-left-color: var(--orange); }
.kpi-label { font-size: 0.72rem; color: var(--gris-moyen); font-weight: 600; text-transform: uppercase; }
.kpi-value { font-size: 1.6rem; font-weight: 800; color: var(--gris-fonce); line-height: 1; }
.kpi-sub   { font-size: 0.75rem; color: var(--gris-moyen); }

/* ── BADGES STATUTS ─────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.tag-vert    { background: var(--vert-clair);   color: var(--vert-fonce); }
.tag-bleu    { background: var(--bleu-clair);   color: var(--bleu); }
.tag-rouge   { background: var(--rouge-clair);  color: var(--rouge); }

/* ── FORMULAIRES ────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 0.85rem;
  font-weight: 600; color: var(--gris-moyen);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--gris-border);
  border-radius: var(--radius-small);
  font-size: 1rem; transition: border-color var(--transition);
  background: var(--blanc);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--vert-moyen);
  box-shadow: 0 0 0 3px rgba(46,125,50,0.1);
}

/* ── BOUTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 20px;
  border-radius: var(--radius-small);
  font-size: 0.95rem; font-weight: 600;
  transition: all var(--transition); cursor: pointer;
}
.btn-primary   { background: var(--vert-fonce); color: var(--blanc); }
.btn-primary:hover   { background: var(--vert-moyen); box-shadow: var(--ombre); }
.btn-secondary { background: var(--gris-clair); color: var(--gris-fonce); border: 1.5px solid var(--gris-border); }

/* ── MODAL ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200; display: flex;
  align-items: flex-end;
  animation: fadeIn 0.2s ease;
}
.modal-content {
  background: var(--blanc);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  animation: slideUp 0.25s ease;
}
@keyframes fadeIn  { from { opacity:0; } to { opacity:1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ── LOADER INLINE ──────────────────────────────────────── */
.loader-spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--gris-border);
  border-top-color: var(--vert-moyen);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* [FUSION] Suppression du bloc CSS cassé en fin de fichier. Tout ce qui concerne Finances est géré par finances.css */
/* ============================================================ */
/* MODULE IMPRESSION (QR CODES & ETIQUETTES)                    */
/* ============================================================ */

.print-only {
    display: none !important;
}

@media print {
    /* 1. Masquer tout le contenu normal de la page */
    body > *:not(#print-zone) {
        display: none !important;
    }

    /* 2. Réinitialiser le corps (fond blanc, pas de marges) */
    body, html {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 3. Afficher uniquement la zone d'impression */
    #print-zone {
        display: block !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-width: 210mm !important; /* Calibrage page A4 */
        margin: 0 auto !important;
        padding: 10mm !important;
        box-sizing: border-box !important;
    }

    /* --- CHANTIER 2 : ÉTIQUETTE UNIQUE --- */
    .etiquette-qr {
        width: 50mm;
        margin: 0 auto;
        padding: 5px;
        border: 1px solid #000;
        border-radius: 4px;
        page-break-inside: avoid;
        font-family: monospace;
        text-align: center;
    }
    .etiquette-qr h2 { font-size: 14px !important; margin: 0 0 5px 0 !important; color: #000 !important; }
    .etiquette-qr .qr-container { display: flex !important; justify-content: center !important; margin-bottom: 5px !important; }
    .etiquette-qr p { font-size: 10px !important; margin: 0 !important; color: #000 !important; }

    /* --- CHANTIER 3 : PLANCHE INDUSTRIELLE (GRILLE 3 COLONNES) --- */
    .qr-grid-batch {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 15px !important; /* Espace entre les étiquettes */
        width: 100% !important;
    }
    
    .etiquette-batch {
        border: 1px dashed #64748b !important; /* Ligne de découpe au ciseau/massicot */
        border-radius: 8px !important;
        padding: 15px 10px !important;
        text-align: center !important;
        page-break-inside: avoid !important; /* Empêche l'étiquette d'être coupée entre 2 pages */
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .etiquette-batch h2 {
        font-size: 16px !important;
        font-weight: bold !important;
        margin: 0 0 10px 0 !important;
        font-family: sans-serif !important;
        color: #000 !important;
    }

    .etiquette-batch .qr-code-img {
        margin-bottom: 10px !important;
    }

    .etiquette-batch p {
        font-size: 12px !important;
        font-family: monospace !important;
        font-weight: bold !important;
        margin: 0 !important;
        color: #000 !important;
    }

    canvas, img {
        max-width: 100% !important;
        height: auto !important;
    }
}