/* =========================================================
   TravelPro Ivory — Styles complémentaires à Tailwind
   ========================================================= */

:root {
    --c-primary: #2563eb;
    --c-primary-dark: #1d4ed8;
    --c-danger: #dc2626;
    --c-danger-dark: #b91c1c;
    --c-success: #16a34a;
    --c-success-dark: #15803d;
    --c-warning: #d97706;
    --c-info: #0891b2;
    --c-secondary: #6b7280;
}

/* ---- Reset / base ---- */
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    font-family:
        "Inter",
        system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        sans-serif;
    background-color: #f3f4f6;
    color: #111827;
    -webkit-font-smoothing: antialiased;
}
a {
    color: inherit;
    text-decoration: none;
}

/* ---- Boutons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    line-height: 1.25rem;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--c-primary);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--c-primary-dark);
}
.btn-danger {
    background: var(--c-danger);
    color: #fff;
}
.btn-danger:hover:not(:disabled) {
    background: var(--c-danger-dark);
}
.btn-success {
    background: var(--c-success);
    color: #fff;
}
.btn-success:hover:not(:disabled) {
    background: var(--c-success-dark);
}
.btn-outline {
    background: transparent;
    color: var(--c-primary);
    border-color: var(--c-primary);
}
.btn-outline:hover:not(:disabled) {
    background: #eff6ff;
}

/* ---- Cartes ---- */
.card {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.08),
        0 1px 2px rgba(0, 0, 0, 0.04);
    padding: 1.25rem;
    border: 1px solid #e5e7eb;
}

/* ---- Tableaux ---- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.table thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: #f9fafb;
    color: #4b5563;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}
.table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f3f4f6;
}
.table tbody tr:hover {
    background: #f9fafb;
}
.table tbody tr:last-child td {
    border-bottom: none;
}

/* ---- Badges de statut ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    line-height: 1.25rem;
}
.badge-success {
    background: #dcfce7;
    color: #166534;
}
.badge-warning {
    background: #fef3c7;
    color: #92400e;
}
.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}
.badge-info {
    background: #cffafe;
    color: #155e75;
}
.badge-secondary {
    background: #e5e7eb;
    color: #374151;
}

/* ---- Formulaires ---- */
.form-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: #111827;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.form-textarea {
    min-height: 6rem;
    resize: vertical;
}

/* ---- Correction globale des champs Tailwind (bordures visibles) ---- */
/* Tailwind CDN: border-gray-300 ne rend pas la bordure visible sans la classe border.
   On force les bordures avec !important pour écraser le reset de Tailwind. */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="search"],
input[type="url"],
select,
textarea {
    border-width: 1px !important;
    border-style: solid !important;
    border-color: #d1d5db !important;
    background-color: #fff !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: 0.5rem !important;
    font-size: 0.875rem !important;
    color: #111827 !important;
    line-height: 1.5rem !important;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="tel"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
    outline: none !important;
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
}
input::placeholder,
textarea::placeholder {
    color: #9ca3af !important;
}
/* Checkbox et boutons radio non affectés */
input[type="checkbox"],
input[type="radio"],
input[type="file"],
input[type="hidden"],
input[type="submit"],
input[type="button"] {
    border: none;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

/* ---- Animation fade-in ---- */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Impression ---- */
@media print {
    #sidebar,
    header button,
    .no-print,
    .btn {
        display: none !important;
    }
    body {
        background: #fff;
    }
    .card {
        box-shadow: none;
        border: none;
    }
    .table thead th {
        background: #fff !important;
    }
}

/* =========================================================
   MODE SOMBRE — activation via la classe .dark sur <html>
   (gerée par assets/js/theme.js + script anti-FOUC dans <head>)
   ========================================================= */
html.dark {
    color-scheme: dark;
}
html.dark body {
    background-color: #0f172a;
    color: #e2e8f0;
}

/* --- Fonds neutres (Tailwind) --- */
html.dark .bg-white {
    background-color: #1e293b !important;
}
html.dark .bg-gray-50,
html.dark .bg-gray-100 {
    background-color: #0f172a !important;
}
html.dark .bg-gray-200 {
    background-color: #1e293b !important;
}
/* Survol des fonds neutres */
html.dark .hover\:bg-gray-50:hover,
html.dark .hover\:bg-gray-100:hover,
html.dark .hover\:bg-gray-200:hover {
    background-color: #334155 !important;
}

/* --- Texte neutre (Tailwind) --- */
html.dark .text-gray-900 { color: #f8fafc !important; }
html.dark .text-gray-800 { color: #f1f5f9 !important; }
html.dark .text-gray-700 { color: #cbd5e1 !important; }
html.dark .text-gray-600 { color: #94a3b8 !important; }
html.dark .text-gray-500 { color: #94a3b8 !important; }
html.dark .text-gray-400 { color: #64748b !important; }
html.dark .placeholder-gray-400::placeholder { color: #64748b !important; }

/* --- Bordures neutres (Tailwind) --- */
html.dark .border-gray-100 { border-color: #1e293b !important; }
html.dark .border-gray-200 { border-color: #334155 !important; }
html.dark .border-gray-300 { border-color: #475569 !important; }
html.dark .divide-gray-100 > * + * { border-color: #1e293b !important; }

/* --- Composants custom (style.css) --- */
html.dark .card { background: #1e293b; border-color: #334155; }
html.dark .table thead th { background: #0f172a; color: #94a3b8; border-bottom-color: #334155; }
html.dark .table tbody td { border-bottom-color: #1e293b; }
html.dark .table tbody tr:hover { background: #334155; }
html.dark .form-label { color: #cbd5e1; }

/* --- Champs de formulaire (ecrase le bloc clair !important) --- */
html.dark input[type="text"],
html.dark input[type="email"],
html.dark input[type="password"],
html.dark input[type="number"],
html.dark input[type="date"],
html.dark input[type="tel"],
html.dark input[type="search"],
html.dark input[type="url"],
html.dark select,
html.dark textarea {
    background-color: #0f172a !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}
html.dark input::placeholder,
html.dark textarea::placeholder { color: #64748b !important; }
html.dark select option { background-color: #1e293b; color: #e2e8f0; }
/* Autofill : les navigateurs forcent un fond clair */
html.dark input:-webkit-autofill,
html.dark input:-webkit-autofill:hover,
html.dark input:-webkit-autofill:focus {
    -webkit-text-fill-color: #e2e8f0 !important;
    -webkit-box-shadow: 0 0 0 1000px #0f172a inset !important;
    caret-color: #e2e8f0;
}

/* --- Hover bouton outline --- */
html.dark .btn-outline:hover:not(:disabled) { background: rgba(37, 99, 235, 0.15); }

/* --- Badge logo lateral : toujours clair (le logo est fonce) --- */
.logo-badge { background-color: #ffffff; }

/* --- Logo sur cartes (pages d'auth) : passe en blanc en mode sombre --- */
html.dark .theme-aware-logo { filter: brightness(0) invert(1); }

/* --- Bouton de bascule de theme : permutation des icones --- */
.theme-toggle .theme-icon-sun { display: none; }
.theme-toggle .theme-icon-moon { display: inline; }
html.dark .theme-toggle .theme-icon-sun { display: inline; }
html.dark .theme-toggle .theme-icon-moon { display: none; }

/* --- Impression : force le mode clair --- */
@media print {
    html.dark,
    html.dark body { background: #fff !important; color: #000 !important; }
    html.dark .bg-white { background-color: #fff !important; }
    html.dark .text-gray-800,
    html.dark .text-gray-900 { color: #000 !important; }
    html.dark .card { background: #fff !important; border-color: #e5e7eb !important; }
    html.dark .theme-aware-logo { filter: none; }
}
