:root {
    --primary: #2563eb;
    --text: #1f2937;
    --bg: #f9fafb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
}

header {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 2rem;
}

nav a {
    color: var(--primary);
    text-decoration: none;
    margin-right: 1.5rem;
    font-weight: 500;
}

nav a:hover {
    text-decoration: underline;
}

main {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.hero {
    text-align: center;
    padding: 3rem 1rem;
}

footer {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
    font-size: 0.9rem;
}

/* Login form — sober, centered, minimal */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 1rem;
}

.login-form {
    width: 100%;
    max-width: 360px;
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.login-form h1 {
    margin: 0 0 1.25rem;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    color: #374151;
}

.form-group input {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s ease;
}

.form-group input:focus {
    border-color: var(--primary);
}

.field-error {
    display: block;
    color: #dc2626;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.btn-primary {
    width: 100%;
    padding: 0.7rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.flash-messages {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.flash-messages li {
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
}

.flash-info {
    background: #eff6ff;
    color: #1e40af;
}

/* Admin section */
.admin-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.admin-header h1 {
    margin: 0;
    font-size: 1.25rem;
}

.search-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    width: 320px;
    max-width: 100%;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.clients-filters {
    display: flex;
    gap: 1.5rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.clients-filters .form-group {
    margin-bottom: 0;
}

.clients-filters select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 180px;
}

.clients-filters select:focus {
    outline: none;
    border-color: var(--primary);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.data-table th {
    color: #6b7280;
    font-weight: 500;
}

.data-table .empty {
    text-align: center;
    color: #6b7280;
    padding: 2rem;
}

.table-responsive {
    overflow-x: auto;
}

.data-table tr.row-modifie {
    background: #f3f4f6;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.4rem;
}

.status-actif {
    background: #16a34a;
}

.status-inactif {
    background: #d1d5db;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-link.danger {
    color: #dc2626;
}

.inline-form {
    display: inline;
    margin-left: 0.75rem;
}

.btn-primary.small {
    width: auto;
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
}

.form-group.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group.checkbox input {
    width: auto;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.pagination-info {
    color: #6b7280;
    font-size: 0.9rem;
}

.pagination button[disabled] {
    color: #9ca3af;
    cursor: not-allowed;
    text-decoration: none;
}

/* Modal d'edition client */
.client-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 40;
}

.client-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 720px;
    max-height: 90vh;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    z-index: 50;
    overflow-y: auto;
    padding: 1.5rem;
}

@media (min-width: 769px) {
    .client-modal {
        width: 70%;
    }
}

.client-modal.hidden,
.client-modal-overlay.hidden {
    display: none;
}

.client-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    position: sticky;
    top: -1.5rem;
    background: white;
    padding: 1.5rem 0;
    margin-top: -1.5rem;
    z-index: 10;
}

.client-modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.site-row,
.document-row,
.pending-document-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.site-row {
    flex-direction: row;
    align-items: center;
}

.site-row input {
    flex: 1;
}

.document-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border-radius: 6px;
}

.pending-document-row {
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 6px;
}

.pending-document-row input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.pending-document-row input[type="file"] {
    max-width: 100%;
}

.pending-document-row .row-actions {
    display: flex;
    justify-content: flex-end;
}

.field-hint {
    font-size: 0.8rem;
    color: #6b7280;
    margin: 0.4rem 0 0;
}

.hidden {
    display: none;
}

/* Journal d'audit */
.audit-details-row td {
    background: #f9fafb;
    padding: 1rem;
}

/* Switch on/off */
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    margin-top: 0.35rem;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.switch-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.15s ease;
}

.switch input:checked + .switch-slider {
    background: var(--primary);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(18px);
}

/* Spinner sur un bouton en cours de traitement */
.btn-primary.is-loading {
    color: transparent;
    pointer-events: none;
    position: relative;
}

.btn-primary.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: white;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

@keyframes btn-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Toast de confirmation */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 0.75rem 1rem;
    opacity: 0;
    transform: translateX(16px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast-message {
    font-size: 0.9rem;
    color: var(--text);
}

.toast-check {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.toast-check-circle {
    stroke: #16a34a;
    stroke-width: 3;
    stroke-dasharray: 157;
    stroke-dashoffset: 157;
    animation: toast-circle 0.4s ease-out forwards;
}

.toast-check-mark {
    stroke: #16a34a;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 36;
    stroke-dashoffset: 36;
    animation: toast-check 0.3s 0.35s ease-out forwards;
}

@keyframes toast-circle {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes toast-check {
    to {
        stroke-dashoffset: 0;
    }
}

.toast-cross {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.toast-cross-circle {
    stroke: #dc2626;
    stroke-width: 3;
    stroke-dasharray: 157;
    stroke-dashoffset: 157;
    animation: toast-circle 0.4s ease-out forwards;
}

.toast-cross-mark {
    stroke: #dc2626;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: toast-check 0.3s 0.35s ease-out forwards;
}
