/* =========================================================
   1. BASE GÉNÉRALE
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    display: flex;
    background: #f4f6f9;
    font-family: Arial, sans-serif;
    color: #111827;
}

/* =========================================================
   2. SIDEBAR
   ========================================================= */

.sidebar {
    width: 240px;
    min-height: 100vh;
    background: linear-gradient(180deg, #111827, #1f2937);
    color: white;
    padding: 26px;
    flex-shrink: 0;
    transition: width 0.3s ease;
}

.logo-box {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.logo-icon {
    min-width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #8b5cf6, #ec4899, #f59e0b);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}

.logo-title {
    font-size: 26px;
    font-weight: 800;
}

.logo-subtitle {
    font-size: 18px;
    color: #d1d5db;
}

.toggle-sidebar {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: rgba(255,255,255,0.12);
    color: white;
    font-size: 18px;
    margin-bottom: 25px;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 14px;
    color: white;
    text-decoration: none;
    padding: 14px 12px;
    margin-bottom: 8px;
    border-radius: 12px;
    font-size: 18px;
}

.sidebar a:hover,
.sidebar a.active {
    background: rgba(255,255,255,0.16);
}

.sidebar a span {
    min-width: 26px;
    text-align: center;
    font-size: 22px;
}

/* Sidebar réduite */

.sidebar.collapsed {
    width: 78px;
    padding: 22px 10px;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed a strong {
    display: none;
}

.sidebar.collapsed a,
.sidebar.collapsed .logo-box {
    justify-content: center;
}

/* =========================================================
   3. CONTENU PRINCIPAL
   ========================================================= */

.content {
    flex: 1;
    width: 100%;
    min-width: 0;
    padding: 30px;
    min-height: 100vh;
}

.content h1 {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 38px;
    font-weight: 800;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    gap: 20px;
}

.page-header p {
    margin: 8px 0 0;
    color: #6b7280;
}

/* =========================================================
   4. CARTES
   ========================================================= */

.card,
.form-card,
.table-box {
    width: 100%;
    background: #ffffff;
    border-radius: 22px;
    padding: 28px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    margin-bottom: 24px;
}

.form-card {
    max-width: none;
}

/* =========================================================
   5. BOUTONS
   ========================================================= */

.btn,
.btn-primary,
.btn-secondary,
.btn-light,
.btn-ajouter,
.btn-retour {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 700;
    border: none;
    cursor: pointer;
    border-radius: 12px;
    font-size: 14px;
}

.btn,
.btn-light {
    padding: 10px 14px;
}

.btn-primary,
.btn-secondary,
.btn-ajouter {
    padding: 13px 20px;
}

.btn-primary,
.btn-ajouter {
    background: #0b1f4d;
    color: white !important;
}

.btn-primary:hover,
.btn-ajouter:hover {
    background: #163b82;
}

.btn-secondary,
.btn-light {
    background: #f1f5f9;
    color: #0f172a;
}

.btn-secondary:hover,
.btn-light:hover {
    background: #e2e8f0;
}

.btn-retour {
    color: #111827;
}

.btn-modifier,
.btn.modifier {
    background: #f59e0b;
    color: white;
}

.btn-imprimer,
.btn.voir {
    background: #2563eb;
    color: white;
}

.btn-pdf {
    background: #16a34a;
    color: white;
}

.btn-supprimer,
.btn.supprimer {
    background: #dc2626;
    color: white;
}

.actions,
.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.form-actions {
    justify-content: flex-end;
    margin-top: 30px;
}

/* =========================================================
   6. FORMULAIRES
   ========================================================= */

.form-card h2 {
    margin-top: 28px;
    margin-bottom: 16px;
    font-size: 20px;
}

.form-card h2:first-child {
    margin-top: 0;
}

.form-grid,
.client-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    max-width: none;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.form-group label,
.form-card label {
    display: block;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px;
}

.form-card label {
    margin-top: 16px;
}

.form-group input,
.form-group select,
.form-group textarea,
.form-card input,
.form-card select,
.form-card textarea,
.client-form input,
.client-form select,
.client-form textarea,
.filters input,
.filters select {
    width: 100%;
    max-width: 100%;
    padding: 13px 15px;
    border: 1px solid #dbe1ea;
    border-radius: 12px;
    font-size: 15px;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-card input:focus,
.form-card select:focus,
.form-card textarea:focus {
    border-color: #0b1f4d;
}

textarea {
    resize: vertical;
}

/* =========================================================
   7. FILTRES
   ========================================================= */

.filters {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 25px;
}

.filters input {
    flex: 1;
    min-width: 220px;
}

.filters-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.reset-link {
    color: #555;
    text-decoration: none;
    font-weight: 600;
}

/* =========================================================
   8. TABLEAUX
   ========================================================= */

.table-box {
    width: 100%;
    overflow-x: auto;
}

.table-box table {
    width: 100%;
    min-width: 1000px;
    border-collapse: collapse;
}

.table-box th {
    text-align: left;
    padding: 16px 14px;
    color: #475569;
    font-size: 13px;
    text-transform: uppercase;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.table-box td {
    padding: 18px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
    word-break: break-word;
}

.table-box tbody tr:hover {
    background: #f8fafc;
}

.empty {
    text-align: center;
    color: #6b7280;
    padding: 25px;
}

.text-right {
    text-align: right;
}

/* =========================================================
   9. STATISTIQUES
   ========================================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.06);
}

.stat-card span {
    display: block;
    color: #777;
    margin-bottom: 8px;
}

.stat-card strong {
    font-size: 28px;
}

/* =========================================================
   10. GALERIE ŒUVRES
   ========================================================= */

.gallery,
.oeuvres-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 22px;
}

.oeuvre-card {
    background: white;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0,0,0,0.07);
    transition: 0.2s ease;
}

.oeuvre-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

.oeuvre-image,
.image-link {
    display: block;
    height: 220px;
    overflow: hidden;
    background: #f3f4f6;
}

.oeuvre-image img,
.image-link img,
.oeuvre-card > img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f3f4f6;
    padding: 10px;
    transition: 0.3s ease;
}

.oeuvre-card:hover img {
    transform: scale(1.05);
}

.oeuvre-info,
.oeuvre-content {
    padding: 18px;
}

.oeuvre-info h3,
.oeuvre-content h3 {
    margin: 0 0 8px;
    font-size: 19px;
}

.oeuvre-meta {
    margin: 4px 0;
    color: #666;
}

.oeuvre-prix,
.prix {
    font-size: 20px;
    font-weight: bold;
    margin: 14px 0;
}

/* =========================================================
   11. BADGES ET STATUTS
   ========================================================= */

.badge,
.badge-statut,
.statut {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.badge-statut,
.statut {
    background: #e5e7eb;
    color: #374151;
}

.badge-gris {
    background: #e5e7eb;
    color: #374151;
}

.badge-bleu {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-vert,
.statut-disponible {
    background: #dcfce7;
    color: #166534;
}

.badge-rouge,
.statut-vendu {
    background: #fee2e2;
    color: #991b1b;
}

.badge-noir {
    background: #374151;
    color: white;
}

.statut-reserve {
    background: #fef3c7;
    color: #92400e;
}

.statut-association {
    background: #ede9fe;
    color: #5b21b6;
}

/* =========================================================
   12. ALERTES
   ========================================================= */

.alert-success {
    background: #d4edda;
    color: #155724;
    padding: 15px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 15px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
    max-width: 850px;
}

/* =========================================================
   13. FOOTER
   ========================================================= */

.footer {
    text-align: center;
    color: #777;
    padding: 30px;
    font-size: 13px;
}

/* =========================================================
   14. ACTIONS TABLEAU
   ========================================================= */

.actions-cell {
    width: 1%;
    white-space: nowrap;
}

.actions-table {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.btn-action-table {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.btn-table-voir,
.btn-table-paiement {
    background: #dbeafe;
    color: #1d4ed8;
}

.btn-table-modifier {
    background: #fef3c7;
    color: #b45309;
}

.btn-table-imprimer {
    background: #dcfce7;
    color: #15803d;
}

.btn-table-supprimer {
    background: #fee2e2;
    color: #dc2626;
}

.btn-action-table.btn-table-facturer {
    background: #bfdbfe !important;
    color: #1d4ed8 !important;
}

.btn-action-table.btn-table-facturer:hover {
    background: #93c5fd !important;
}

.btn-action-table.btn-table-ajouter {
    background: #60a5fa !important;
    color: #ffffff !important;
}

.btn-action-table.btn-table-ajouter:hover {
    background: #3b82f6 !important;
}

.btn-table-valider {
    background: #dcfce7;
    color: #15803d;
}

.btn-action-table:hover {
    transform: translateY(-1px);
    filter: brightness(95%);
    box-shadow: 0 4px 10px rgba(0,0,0,0.10);
}

/* =========================================================
   15. MON COMPTE
   ========================================================= */

.compte-form {
    max-width: 900px;
}

.compte-ligne {
    display: grid;
    grid-template-columns: 160px 1fr;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.compte-ligne label {
    font-weight: 700;
    color: #111827;
    margin: 0;
}

.compte-ligne input,
.compte-ligne select,
.compte-ligne textarea {
    width: 100%;
    max-width: 420px;
}

/* =========================================================
   16. IMPRESSION EXPO
   ========================================================= */

.btn-print {
    background: #2563eb;
    color: #fff;
    border: none;
}

.btn-print:hover {
    background: #1d4ed8;
    color: #fff;
}

.conditions {
    margin-top: auto;
    margin-bottom: 8px;
    font-size: 7px;
    color: #444;
}

.conditions h3 {
    margin: 0 0 4px;
    font-size: 8px;
}

.conditions ul {
    margin: 0;
    padding-left: 14px;
}

.conditions li {
    margin: 2px 0;
    line-height: 1.2;
}

.signature-box {
    margin-top: 25px;
    border: 1px solid #d8d8d8;
    border-radius: 6px;
    padding: 15px;
    background: #fcfcfc;
}

/* =========================================================
   17. RESPONSIVE
   ========================================================= */

@media screen and (max-width: 1100px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media screen and (max-width: 900px) {
    body {
        display: block;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
    }

    .sidebar.collapsed {
        width: 100%;
    }

    .content {
        width: 100%;
        padding: 25px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-grid,
    .client-form {
        max-width: 100%;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-form {
        flex-direction: column;
    }

    .compte-ligne {
        grid-template-columns: 1fr;
    }

    .compte-ligne input,
    .compte-ligne select,
    .compte-ligne textarea {
        max-width: 100%;
    }
}

@media screen and (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 18px;
    }

    .content h1 {
        font-size: 30px;
    }

    .form-actions {
        justify-content: stretch;
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary,
    .btn-ajouter {
        width: 100%;
    }
}

/* =========================================================
   18. IMPRESSION
   ========================================================= */

@media print {
    body {
        display: block;
        background: white;
    }

    .sidebar,
    .actions,
    .toggle-sidebar,
    .btn-retour,
    .btn-ajouter,
    .form-actions {
        display: none !important;
    }

    .content {
        width: 100%;
        padding: 0;
        background: white;
    }

    .card,
    .form-card,
    .table-box {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* =========================================================
   ADAPTATION TABLEAUX + BOUTONS
   ========================================================= */

/* Les tableaux prennent toute la largeur disponible */
.table-box,
.card {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

/* Tableau fluide */
table {
    width: 100%;
    border-collapse: collapse;
}

/* Évite que le tableau explose la page */
.table-box table {
    min-width: 850px;
}

/* Texte propre dans les cellules */
th,
td {
    vertical-align: top;
    word-break: break-word;
}

/* Colonne actions */
.actions-cell {
    width: auto;
    min-width: 180px;
}

/* Les boutons s’adaptent */
.actions,
.actions-table {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Boutons adaptables */
.btn,
.btn-primary,
.btn-secondary,
.btn-light,
.btn-ajouter,
.btn-retour,
.btn-action-table {
    max-width: 100%;
    white-space: normal;
    text-align: center;
}

/* Sur écran moyen */
@media screen and (max-width: 1200px) {
    .btn-action-table {
        padding: 9px 12px;
        font-size: 14px;
    }

    .table-box table {
        min-width: 750px;
    }
}

/* Sur petit écran */
@media screen and (max-width: 700px) {
    .table-box {
        padding: 15px;
    }

    .table-box table {
        min-width: 650px;
    }

    .actions,
    .actions-table {
        flex-direction: column;
        align-items: stretch;
    }

    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-light,
    .btn-ajouter,
    .btn-retour,
    .btn-action-table {
        width: 100%;
        justify-content: center;
    }
}

/* =========================================================
   TABLE CLIENTS RESPONSIVE
   ========================================================= */

.clients-table-box {
    width: 100%;
    overflow-x: hidden;
}

.clients-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

.clients-table th,
.clients-table td {
    padding: 14px 12px;
    vertical-align: middle;
    word-break: normal;
    overflow-wrap: anywhere;
}

.clients-table th {
    white-space: nowrap;
}

.clients-table .col-type {
    width: 8%;
}

.clients-table .col-nom {
    width: 15%;
}

.clients-table .col-societe {
    width: 17%;
}

.clients-table .col-email {
    width: 20%;
}

.clients-table .col-tel {
    width: 13%;
}

.clients-table .col-ville {
    width: 13%;
}

.clients-table .col-actions {
    width: 14%;
}

.clients-table .actions-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.clients-table .btn-action-table {
    width: 100%;
    padding: 9px 10px;
    font-size: 14px;
    white-space: nowrap;
}

/* Écran moyen */
@media screen and (max-width: 1200px) {
    .clients-table th,
    .clients-table td {
        padding: 12px 8px;
        font-size: 14px;
    }

    .clients-table .btn-action-table {
        font-size: 13px;
        padding: 8px;
    }
}

/* Petit écran : retour au scroll propre */
@media screen and (max-width: 900px) {
    .clients-table-box {
        overflow-x: auto;
    }

    .clients-table {
        min-width: 850px;
    }
}