/* =============================================================================
   Pay07 - Styles V2
   Design professionnel Studio B07 - complète Pico CSS.
   ============================================================================= */

:root {
    --pay07-primary: #E8792B;
    --pay07-primary-dark: #C96620;
    --pay07-primary-light: #FFF3EB;
    --pay07-secondary: #2B4C7E;
    --pay07-secondary-light: #EDF2F9;
    --pay07-success: #27AE60;
    --pay07-warning: #F39C12;
    --pay07-danger: #E74C3C;
    --pay07-info: #5B9BD5;
    --pay07-light: #F8F9FB;
    --pay07-muted: #7C8A97;
    --pay07-border: #E2E6EB;
    --pay07-text: #2D3436;
    --pay07-radius: 6px;
    --pay07-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --pay07-shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

[data-theme="light"],
:root:not([data-theme="dark"]) {
    --pico-primary: var(--pay07-primary);
    --pico-primary-hover: var(--pay07-primary-dark);
    --pico-primary-focus: rgba(232, 121, 43, 0.15);
}

body { background: var(--pay07-light); color: var(--pay07-text); }

/* === Navigation === */
nav {
    background: #fff;
    border-bottom: 1px solid var(--pay07-border);
    box-shadow: var(--pay07-shadow);
    padding: 0.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
nav .nav-brand { font-size: 1.3rem; font-weight: 700; color: var(--pay07-primary) !important; letter-spacing: -0.02em; }
nav a { font-size: 0.88rem; font-weight: 500; color: var(--pay07-text) !important; transition: color 0.15s; }
nav a:hover { color: var(--pay07-primary) !important; }
nav details[role="list"] summary,
nav details.dropdown summary { font-size: 0.88rem; }

/* === Layout === */
main.container { max-width: 1200px; padding-top: 1.5rem; padding-bottom: 3rem; }
h2 { color: var(--pay07-secondary); font-weight: 700; font-size: 1.55rem; margin-bottom: 0.5rem; }
h3 { color: var(--pay07-secondary); font-weight: 600; font-size: 1.12rem; margin-top: 1.6rem; margin-bottom: 0.7rem; }
hgroup p { color: var(--pay07-muted); font-size: 0.9rem; }

/* === Auth === */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--pay07-secondary-light) 0%, #fff 100%); }
.auth-card { max-width: 420px; margin: 0 auto; background: #fff; box-shadow: var(--pay07-shadow-md); border-radius: 10px; padding: 2rem; }
.auth-title { text-align: center; color: var(--pay07-primary); margin-bottom: 0.25rem; font-size: 1.5rem; }
.auth-subtitle { text-align: center; color: var(--pay07-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

/* === Flash messages === */
.flash { padding: 0.75rem 1.2rem; margin-bottom: 1rem; border-radius: var(--pay07-radius); position: relative; font-size: 0.88rem; border-left: 4px solid transparent; animation: flashIn 0.3s ease; }
@keyframes flashIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.flash-success { background: #EAFAF1; color: #1A7742; border-left-color: var(--pay07-success); }
.flash-error { background: #FDECEC; color: #922020; border-left-color: var(--pay07-danger); }
.flash-warning { background: #FFF8E7; color: #7A5E0B; border-left-color: var(--pay07-warning); }
.flash-info { background: #E9F4FB; color: #1A5276; border-left-color: var(--pay07-info); }
.flash-close { position: absolute; top: 0.5rem; right: 0.75rem; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: inherit; opacity: 0.5; padding: 0; line-height: 1; transition: opacity 0.15s; }
.flash-close:hover { opacity: 1; }

/* === Recherche === */
.search-bar { margin-bottom: 1.5rem; }
.search-bar input[type="search"] { margin-bottom: 0; background: #fff; border: 1px solid var(--pay07-border); border-radius: 8px; padding: 0.6rem 1rem; font-size: 0.9rem; transition: border-color 0.2s, box-shadow 0.2s; }
.search-bar input[type="search"]:focus { border-color: var(--pay07-primary); box-shadow: 0 0 0 3px rgba(232, 121, 43, 0.1); }

/* === Cards === */
article { background: #fff; border: 1px solid var(--pay07-border); border-radius: var(--pay07-radius); box-shadow: var(--pay07-shadow); padding: 1.2rem; margin-bottom: 1rem; }
article > header { padding-bottom: 0.7rem; margin-bottom: 0.7rem; border-bottom: 1px solid var(--pay07-border); }
article > header strong { color: var(--pay07-secondary); font-size: 1rem; }

/* === Tableaux === */
figure { margin: 0; }
table { font-size: 0.88rem; border-collapse: collapse; width: 100%; }
table thead th { background: var(--pay07-secondary-light); color: var(--pay07-secondary); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.6rem 0.7rem; border-bottom: 2px solid var(--pay07-border); white-space: nowrap; }
table tbody td { padding: 0.55rem 0.7rem; border-bottom: 1px solid #F0F2F5; vertical-align: middle; }
table tbody tr:hover { background: var(--pay07-primary-light); }
table tbody tr:last-child td { border-bottom: none; }
.table-actions { white-space: nowrap; }
.table-actions a, .table-actions button { font-size: 0.78rem; padding: 0.2rem 0.5rem; margin-right: 0.2rem; }

/* === Badges === */
.badge { display: inline-block; padding: 0.18rem 0.55rem; border-radius: 10px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.badge-brouillon { background: #EAECEE; color: #5D6D7E; }
.badge-envoyé, .badge-envoyee, .badge-émise { background: #E9F4FB; color: #1A5276; }
.badge-accepté { background: #EAFAF1; color: #1A7742; }
.badge-refusé { background: #FDECEC; color: #922020; }
.badge-expiré { background: #EAECEE; color: #5D6D7E; }
.badge-payée, .badge-payé { background: #EAFAF1; color: #1A7742; }
.badge-partiellement_payée { background: #FFF8E7; color: #7A5E0B; }
.badge-en_retard { background: #FDECEC; color: #922020; }
.badge-annulée { background: #EAECEE; color: #5D6D7E; }

/* === KPI === */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.8rem; margin-bottom: 1.8rem; }
.kpi-card { padding: 1rem; border-radius: var(--pay07-radius); background: #fff; border: 1px solid var(--pay07-border); box-shadow: var(--pay07-shadow); text-align: center; transition: box-shadow 0.2s, transform 0.15s; }
.kpi-card:hover { box-shadow: var(--pay07-shadow-md); transform: translateY(-1px); }
.kpi-value { font-size: 1.45rem; font-weight: 700; color: var(--pay07-secondary); margin-bottom: 0.15rem; line-height: 1.2; }
.kpi-label { font-size: 0.7rem; color: var(--pay07-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }

/* === Boutons === */
button, [role="button"], input[type="submit"] { border-radius: var(--pay07-radius); font-weight: 600; font-size: 0.88rem; transition: all 0.15s ease; }
button:not(.outline):not(.secondary):hover, [role="button"]:not(.outline):not(.secondary):hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(232, 121, 43, 0.25); }
.outline { border-width: 1.5px; }

/* === Formulaires === */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 768px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
input, select, textarea { border-radius: var(--pay07-radius); border: 1px solid var(--pay07-border); transition: border-color 0.2s, box-shadow 0.2s; }
input:focus, select:focus, textarea:focus { border-color: var(--pay07-primary); box-shadow: 0 0 0 3px rgba(232, 121, 43, 0.1); }
label { font-size: 0.88rem; font-weight: 500; color: var(--pay07-text); }
details summary { font-weight: 500; color: var(--pay07-secondary); }

/* === Lignes document === */
.doc-lines-table { background: #fff; }
.doc-lines-table th { background: var(--pay07-secondary); color: #fff; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.5rem; }
.doc-lines-table td { padding: 0.4rem; vertical-align: middle; }
.doc-lines-table input, .doc-lines-table select { margin-bottom: 0; font-size: 0.82rem; padding: 0.3rem 0.45rem; border-radius: 4px; }
.doc-lines-table input[readonly] { background: var(--pay07-secondary-light); font-weight: 600; color: var(--pay07-secondary); }
.doc-total-row { font-weight: 700; font-size: 1.1rem; }

/* === Utilitaires === */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--pay07-muted); }
.text-danger { color: var(--pay07-danger); }
.text-success { color: var(--pay07-success); }
.text-warning { color: var(--pay07-warning); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }

a { color: var(--pay07-primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--pay07-primary-dark); }
table a { font-weight: 500; }

/* === Responsive === */
@media (max-width: 768px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .kpi-value { font-size: 1.15rem; }
    h2 { font-size: 1.3rem; }
    .form-actions { flex-direction: column; }
    .form-actions a, .form-actions button { text-align: center; }
    nav ul { flex-wrap: wrap; gap: 0.25rem; }
    figure { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 600px; }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .kpi-card { padding: 0.7rem; }
    .kpi-value { font-size: 1rem; }
}

/* === Impression === */
@media print {
    nav, footer, .search-bar, .flash, .form-actions, .table-actions { display: none !important; }
    main { padding: 0; }
    body { background: #fff; }
    article { box-shadow: none; border: 1px solid #ddd; }
}
