/*
 * Neobotti Compta — overrides CSS.
 * Tailwind est chargé via CDN (cf. base.html). Ce fichier contient uniquement
 * les ajustements qui ne s'expriment pas bien en classes utilitaires :
 *   - scrollbar cohérente
 *   - transitions globales douces sur les focus
 *   - polish sur les éléments natifs
 */

:root {
    color-scheme: light;
}

html, body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar discrète (WebKit + Firefox) */
* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}
*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
*::-webkit-scrollbar-track {
    background: transparent;
}
*::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Date input : rendu plus cohérent cross-browser */
input[type="date"] {
    min-height: 2.5rem;
}
input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0.5;
    cursor: pointer;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Focus-visible : ring sobre sur éléments interactifs non déjà stylés */
:focus-visible {
    outline: 2px solid transparent;
    outline-offset: 2px;
}

/* HTMX : fade-in des fragments nouvellement injectés */
.htmx-added { opacity: 0; }
.htmx-settling { opacity: 1; transition: opacity 0.15s ease-out; }

/* Animation pour la zone de drop PDF quand elle reçoit le focus */
@keyframes pulse-subtle {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.01); }
}

/* ============================================================
   Cleanup design global — densité & cohérence (Mai 2026)
   ============================================================
   Approche : règles CSS globales qui s'appliquent à TOUS les
   templates de l'app (héritent de base.html → <main>), sans
   toucher aux templates eux-mêmes.
   ============================================================ */

/* Densification des TABLES (toutes les pages) */
main table {
    font-size: 13px;
    line-height: 1.45;
}
main table thead th {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
    font-size: 10.5px !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b !important;
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0;
}
main table tbody td {
    padding-top: 0.4rem !important;
    padding-bottom: 0.4rem !important;
}
main table tbody tr {
    border-bottom: 1px solid #f1f5f9;
}
main table tbody tr:hover {
    background: rgba(248, 250, 252, 0.7);
}

/* Densification des CARDS (toutes les pages) */
main .rounded-xl,
main .rounded-2xl {
    border-radius: 0.5rem; /* xl 12px → lg 8px */
}
main .shadow-card {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
}

/* Densité des sections : marge bottom réduite */
main section {
    margin-bottom: 1rem;
}
main section.mb-8 { margin-bottom: 1.25rem; }
main section.mb-6 { margin-bottom: 1rem; }

/* Headers de page : légèrement plus compacts */
main > h1, main > div > h1 {
    margin-bottom: 0.25rem;
}

/* Boutons primaires (plus subtils, hover plus prononcé) */
main button,
main a[class*="bg-emerald-600"],
main a[class*="bg-indigo-600"] {
    transition: all 0.15s ease;
}

/* Liens type fournisseur dans tableau : plus discret */
main table a {
    text-decoration: none;
}
main table a:hover {
    text-decoration: underline;
}

/* Inputs : focus ring plus net, padding cohérent */
input[type="text"], input[type="number"], input[type="date"],
input[type="email"], input[type="password"], select, textarea {
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #10b981 !important; /* emerald-500 */
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Boutons disabled : plus visibles */
button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Focus visible : ring plus subtil */
:focus-visible {
    outline-color: #10b981;
}

/* ============================================================
   Composants utilitaires (à utiliser explicitement)
   ============================================================ */

/* Tableaux de données : densité réduite, alignement chiffres natif */
table.t-data {
    font-size: 13px;
    line-height: 1.4;
}
table.t-data thead th {
    padding: 0.5rem 0.75rem;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b; /* slate-500 */
    background: #f8fafc; /* slate-50 */
    border-bottom: 1px solid #e2e8f0; /* slate-200 */
}
table.t-data tbody td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #f1f5f9; /* slate-100 */
}
table.t-data tbody tr:hover td {
    background: rgba(248, 250, 252, 0.7); /* slate-50/70 */
}
table.t-data .num {
    font-variant-numeric: tabular-nums;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    text-align: right;
}

/* Badges source unifiés (1 couleur par source partout dans l'app) */
.badge-src {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.125rem 0.4rem;
    border-radius: 4px;
    border: 1px solid;
}
.badge-src-bank      { background: #f0f9ff; color: #075985; border-color: #bae6fd; } /* sky */
.badge-src-visa      { background: #f5f3ff; color: #5b21b6; border-color: #ddd6fe; } /* violet */
.badge-src-paypal    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; } /* blue */
.badge-src-woo       { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; } /* emerald */
.badge-src-coda      { background: #ecfeff; color: #155e75; border-color: #a5f3fc; } /* cyan */
.badge-src-wa_import { background: #f1f5f9; color: #475569; border-color: #cbd5e1; } /* slate */
.badge-src-manuel    { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; } /* emerald */
.badge-src-peppol    { background: #eef2ff; color: #3730a3; border-color: #c7d2fe; } /* indigo */

/* Cards utilitaires (composant récurrent) */
.card {
    background: white;
    border: 1px solid #e2e8f0; /* slate-200 */
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
}
.card-tight {
    padding: 0.75rem 1rem;
}
.card-header {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b; /* slate-500 */
    margin-bottom: 0.5rem;
}

/* Boutons primaires/secondaires cohérents */
.btn-primary {
    display: inline-flex; align-items: center; gap: 0.4rem;
    background: #059669; color: white;
    padding: 0.4rem 0.85rem;
    border-radius: 0.5rem;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s;
}
.btn-primary:hover { background: #047857; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost {
    display: inline-flex; align-items: center; gap: 0.4rem;
    background: transparent; color: #475569;
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 13px;
    border: 1px solid #cbd5e1;
}
.btn-ghost:hover { background: #f8fafc; color: #0f172a; }

/* ----- Impression (récap TVA, justifs, etc.) ----------------------------- */
.print-only { display: none; }
@media print {
    /* Cache la chrome : sidebar, header sticky, footer, drawer, backdrop */
    #sidebar, #sidebar-backdrop, #drawer, #drawer-backdrop,
    header.sticky, header[class*="sticky"], footer { display: none !important; }
    /* Wrapper principal : retire le padding gauche du sidebar */
    body > div.lg\:pl-60 { padding-left: 0 !important; }
    main { max-width: none !important; padding: 0 !important; }
    /* Éléments marqués no-print (boutons, sélecteurs, liens détail…) */
    .no-print { display: none !important; }
    /* Éléments réservés à l'impression */
    .print-only { display: block !important; }
    /* Couleurs / fonds : forcer le rendu (sinon imprimante "fond blanc") */
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    /* Marges page raisonnables */
    @page { margin: 14mm 12mm; }
    body { background: white !important; }
    /* Évite les coupures laides au milieu d'une section ou d'un tableau */
    section, table { break-inside: avoid; page-break-inside: avoid; }
    h1, h2 { break-after: avoid; page-break-after: avoid; }
}
