/* facturiks — UI web */

/* ============================================================
   Page de login
   ============================================================ */

.login-body {
    background: #fafaf9;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-container {
    width: 100%;
    max-width: 380px;
}

.login-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 36px 32px 28px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.login-brand {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.login-hint {
    font-size: 13px;
    color: #6b7280;
    text-align: center;
    margin-bottom: 24px;
}

.login-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}

.login-field {
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.login-field label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.login-field input {
    padding: 9px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: #1a1a1a;
}

.login-field input:focus {
    outline: none;
    border-color: #1f2937;
    box-shadow: 0 0 0 3px rgba(31, 41, 55, 0.08);
}

.login-submit {
    width: 100%;
    margin-top: 6px;
    padding: 10px;
    font-size: 14px;
    font-weight: 500;
}

:root {
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --text-dim: #9ca3af;
    --bg: #fafaf9;
    --bg-elevated: #ffffff;
    --border: #e5e7eb;
    --border-strong: #1a1a1a;
    --accent: #1f2937;
    --accent-hover: #374151;
    --success: #16a34a;
    --warning: #ea580c;
    --facturx: #7c3aed;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

.mono {
    font-family: "JetBrains Mono", "IBM Plex Mono", "Menlo", "Consolas", monospace;
    font-size: 0.92em;
}

.right { text-align: right; }

/* Nav */
.nav {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.01em;
}

.nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
}

.nav-links a:hover { color: var(--text); }

.nav-logout {
    color: var(--text-dim) !important;
    font-size: 16px;
    line-height: 1;
    padding: 4px 8px;
    text-decoration: none;
}
.nav-logout:hover { color: var(--text) !important; }

.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Page header */
.page-header {
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 4px;
}

/* Stats */
.stats {
    display: flex;
    gap: 32px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
}

.stat-value {
    font-family: "JetBrains Mono", monospace;
    font-size: 18px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover { border-color: var(--border-strong); }

.btn-primary,
.btn-primary:visited {
    background: var(--accent);
    color: #fff !important;  /* force le blanc pour battre les règles `.nav-links a` */
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff !important;
}

/* Table factures */
.invoices-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.invoices-table thead th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    background: #fafaf9;
}

.invoices-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.invoices-table tbody tr:last-child td { border-bottom: none; }
.invoices-table tbody tr:hover { background: #fafaf9; }

.invoices-table .actions {
    display: flex;
    gap: 10px;
}

.invoices-table .actions a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
}

.invoices-table .actions a:hover { color: var(--text); text-decoration: underline; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    background: #f3f4f6;
    color: var(--text-muted);
}

.badge-particulier { background: #f3f4f6; color: #6b7280; }
.badge-entreprise_fr { background: #fef3c7; color: #92400e; }
.badge-entreprise_ue { background: #dbeafe; color: #1e40af; }
.badge-entreprise_hors_ue { background: #ede9fe; color: #5b21b6; }
.badge-facturx { background: #ede9fe; color: var(--facturx); }
.badge-classic { background: #f3f4f6; color: #6b7280; }
.badge-brouillon { background: #f3f4f6; color: #6b7280; }
.badge-emise { background: #dbeafe; color: #1e40af; }
.badge-payee { background: #dcfce7; color: #166534; }
.badge-annulee { background: #fee2e2; color: #991b1b; }

/* Empty */
.empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty p {
    margin-bottom: 16px;
}

/* Forms */
.form {
    max-width: 720px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 28px;
}

.form-section {
    margin-bottom: 28px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section h2 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 16px;
}

.form-section h3 {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin: 20px 0 12px;
}

.form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.form label > span {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.form input[type="text"],
.form input[type="email"],
.form input[type="date"],
.form textarea,
.form select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-elevated);
    color: var(--text);
}

.form input:focus,
.form textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form textarea {
    resize: vertical;
    font-family: inherit;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
}

.grid-span-2 { grid-column: 1 / -1; }

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-label {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 0 !important;
}

.radio-label:has(input:checked) {
    border-color: var(--accent);
    background: #f9fafb;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Detail page */
.detail-actions {
    display: flex;
    gap: 10px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-block {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.detail-block:has(table) {
    grid-column: 1 / -1;
}

.totals-block {
    grid-column: 2;
}

.detail-block h2 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    font-weight: 500;
    margin-bottom: 14px;
}

.kv-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.kv-row:last-child { border-bottom: none; }

.kv-row.grand {
    font-weight: 700;
    font-size: 16px;
    margin-top: 4px;
    padding-top: 10px;
    border-top: 2px solid var(--border-strong);
}

.kv-label {
    color: var(--text-muted);
    min-width: 110px;
    flex-shrink: 0;
}

/* Pleine largeur dans la grille de détail */
.detail-block.full-width {
    grid-column: 1 / -1;
}

/* Inputs inline dans les kv-rows pour la page d'édition */
.kv-row select,
.kv-row input[type="text"],
.kv-row input[type="email"],
.kv-row input[type="date"],
.kv-input-wrap input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-elevated);
    color: var(--text);
}

.kv-row select { cursor: pointer; }

/* Champs date plus compacts (DD/MM/YYYY + icône calendrier suffisent) */
.kv-row input[type="date"] {
    flex: 0 0 auto;
    width: 160px;
}

.kv-row input:focus,
.kv-row select:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px rgba(31, 41, 55, 0.08);
}

.kv-input-wrap {
    flex: 1;
    position: relative;
}

.kv-input-wrap input {
    width: 100%;
    max-width: none !important;
}

/* Tableau de prestation éditable */
.lines-mini.editable {
    table-layout: fixed;
    width: 100%;
}

.lines-mini.editable th:nth-child(1),
.lines-mini.editable td:nth-child(1) { width: auto; }                 /* Description */
.lines-mini.editable th:nth-child(2),
.lines-mini.editable td:nth-child(2) { width: 60px; }                 /* Qté */
.lines-mini.editable th:nth-child(3),
.lines-mini.editable td:nth-child(3) { width: 90px; }                 /* Unité */
.lines-mini.editable th:nth-child(4),
.lines-mini.editable td:nth-child(4) { width: 110px; }                /* PU HT */
.lines-mini.editable th:nth-child(5),
.lines-mini.editable td:nth-child(5) { width: 80px; }                 /* TVA */

.lines-mini.editable input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-elevated);
}

.lines-mini.editable input:focus {
    border-color: var(--accent);
    outline: none;
}

.lines-mini.editable input.right {
    text-align: right;
}

.lines-mini.editable td {
    padding: 6px 4px;
}

/* Textareas dans les blocs */
.detail-block textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-elevated);
    color: var(--text);
    resize: vertical;
}

.detail-block textarea:focus {
    border-color: var(--accent);
    outline: none;
}

/* Footer danger (suppression) */
.danger-footer {
    border-top-color: #fecaca !important;
}

.text-link.danger {
    color: #991b1b;
}

.text-link.danger:hover {
    color: #7f1d1d;
}

/* Lines mini table */
.lines-mini {
    width: 100%;
    border-collapse: collapse;
}

.lines-mini thead th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    font-weight: 500;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.lines-mini thead th.right { text-align: right; }

.lines-mini tbody td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.lines-mini tbody tr:last-child td { border-bottom: none; }

/* Breadcrumb / alerts */
.breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }

.alert {
    border: 1px solid;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.55;
    max-width: 720px;
}
.alert-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #78350f;
}
.alert-danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #7f1d1d;
}

.help-text {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.55;
    margin-top: 6px;
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    margin-top: 4px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.autocomplete-item:last-child { border-bottom: none; }

.autocomplete-item:hover,
.autocomplete-item.autocomplete-highlighted {
    background: #f3f4f6;
}

.autocomplete-name {
    font-weight: 500;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 2px;
}

/* Footer page (actions utilitaires de maintenance) */
.page-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.text-link {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: underline;
    text-decoration-color: var(--border);
    text-underline-offset: 3px;
    cursor: pointer;
}

.text-link:hover {
    color: var(--text);
    text-decoration-color: var(--text);
}

.text-muted-small {
    font-size: 12px;
    color: var(--text-dim);
}

/* Bloc Données structurées Factur-X */
.facturx-block {
    grid-column: 1 / -1;
    background: #faf5ff;
    border-color: #ddd6fe;
}

.facturx-h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--facturx);
    text-transform: none !important;
    letter-spacing: normal !important;
    margin-top: 18px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e9d5ff;
}

.facturx-h3:first-of-type { margin-top: 8px; }

.raw-xml-details {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #e9d5ff;
}

.raw-xml-details summary {
    cursor: pointer;
    color: var(--facturx);
    font-size: 13px;
    font-weight: 500;
    user-select: none;
}

.raw-xml-details summary:hover {
    text-decoration: underline;
}

.raw-xml {
    margin-top: 10px;
    padding: 14px;
    background: #1a1a1a;
    color: #e5e7eb;
    border-radius: 6px;
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
}

.autocomplete-meta {
    font-size: 11px;
    color: var(--text-muted);
}
