/* =============================================================================
   ÔTAY BOX - DASHBOARD ADMINISTRATEUR & GABARIT DOCUMENTS A4
   Charte : Vert (#4b6c4f), Vert Clair (#8dac95), Ardoise (#424746)
   ============================================================================= */

:root {
    --brand-primary: #4b6c4f;
    --brand-primary-hover: #3c573f;
    --brand-light: #8dac95;
    --brand-accent: #424746;
    --brand-bg: #FAF8F5;
    --brand-surface: #FFFFFF;
    --brand-border: #E5E0D8;
    --brand-muted: #8C857E;
    --brand-text: #2F2A25;
    
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-subtle: 0 4px 15px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--brand-bg);
    color: var(--brand-text);
    min-height: 100vh;
    display: flex;
}

/* -----------------------------------------------------------------------------
   Layout Structure : Sidebar + Main Content
   ----------------------------------------------------------------------------- */
.admin-sidebar {
    width: var(--sidebar-width);
    background-color: #FFFFFF;
    border-right: 1px solid var(--brand-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--brand-border);
}

.sidebar-logo-img {
    height: 38px;
    width: auto;
    object-fit: contain;
}

.sidebar-brand-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--brand-primary);
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 1rem;
    color: var(--brand-accent);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.nav-item-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
    color: var(--brand-muted);
    transition: color 0.2s ease;
}

.nav-item-link:hover {
    background-color: rgba(141, 172, 149, 0.12);
    color: var(--brand-primary);
}

.nav-item-link:hover i {
    color: var(--brand-primary);
}

.nav-item-link.active {
    background-color: var(--brand-primary);
    color: #FFFFFF;
}

.nav-item-link.active i {
    color: #FFFFFF;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--brand-border);
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0.75rem;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--brand-light);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-details {
    overflow: hidden;
}

.user-role-label {
    font-size: 0.75rem;
    color: var(--brand-muted);
}

.user-email-val {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--brand-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* -----------------------------------------------------------------------------
   Main Admin Content Area
   ----------------------------------------------------------------------------- */
.admin-main-wrap {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-topbar {
    height: var(--header-height);
    background-color: #FFFFFF;
    border-bottom: 1px solid var(--brand-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-main-heading {
    font-family: 'Poppins', sans-serif;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--brand-text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-body-content {
    padding: 2rem;
    flex: 1;
}

/* -----------------------------------------------------------------------------
   Buttons & Form Controls
   ----------------------------------------------------------------------------- */
.btn-primary {
    background-color: var(--brand-primary);
    color: #FFFFFF;
    border: none;
    border-radius: 50px;
    padding: 0.65rem 1.4rem;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background-color: var(--brand-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(75, 108, 79, 0.25);
}

.btn-secondary {
    background-color: #FFFFFF;
    color: var(--brand-accent);
    border: 1px solid var(--brand-border);
    border-radius: 50px;
    padding: 0.6rem 1.2rem;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background-color: #F8F6F2;
    border-color: var(--brand-light);
    color: var(--brand-primary);
}

.btn-outline-danger {
    background-color: transparent;
    color: #c0392b;
    border: 1px solid #c0392b;
    border-radius: 50px;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-outline-danger:hover {
    background-color: #c0392b;
    color: #FFFFFF;
}

/* -----------------------------------------------------------------------------
   KPI Dashboard Cards
   ----------------------------------------------------------------------------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: #FFFFFF;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid var(--brand-border);
    box-shadow: var(--shadow-subtle);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.kpi-label {
    font-size: 0.85rem;
    color: var(--brand-muted);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.kpi-value {
    font-family: 'Poppins', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--brand-text);
}

.kpi-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.kpi-icon-green {
    background-color: rgba(75, 108, 79, 0.12);
    color: var(--brand-primary);
}

.kpi-icon-orange {
    background-color: rgba(230, 126, 34, 0.12);
    color: #d35400;
}

.kpi-icon-blue {
    background-color: rgba(52, 152, 219, 0.12);
    color: #2980b9;
}

.kpi-icon-slate {
    background-color: rgba(66, 71, 70, 0.12);
    color: var(--brand-accent);
}

/* -----------------------------------------------------------------------------
   Data Tables & Badges
   ----------------------------------------------------------------------------- */
.panel-card {
    background: #FFFFFF;
    border-radius: var(--radius-md);
    border: 1px solid var(--brand-border);
    box-shadow: var(--shadow-subtle);
    overflow: hidden;
    margin-bottom: 2rem;
}

.panel-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--brand-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.panel-card-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--brand-text);
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.data-table th {
    background-color: #FBF9F7;
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--brand-accent);
    border-bottom: 1px solid var(--brand-border);
    white-space: nowrap;
}

.data-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--brand-border);
    vertical-align: middle;
}

.data-table tr:hover {
    background-color: #FAF8F5;
}

/* Badges de Statuts Indépendants */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

/* 1. Statuts Commande */
.badge-order-nouvelle { background: #e8f4fd; color: #1976d2; }
.badge-order-aconfirmer { background: #fef5e7; color: #d35400; }
.badge-order-confirmee { background: #eafaf1; color: #27ae60; }
.badge-order-enpreparation { background: #f4ecf7; color: #8e44ad; }
.badge-order-expediee { background: #e8f8f5; color: #16a085; }
.badge-order-livree { background: #e8f5e9; color: #2e7d32; }
.badge-order-annulee { background: #fdebd0; color: #c0392b; }
.badge-order-retour { background: #fadbd8; color: #922b21; }

/* 2. Statuts Livraison */
.badge-deliv-nonpreparee { background: #f2f3f4; color: #7f8c8d; }
.badge-deliv-enpreparation { background: #fef9e7; color: #f39c12; }
.badge-deliv-remise { background: #ebf5fb; color: #2980b9; }
.badge-deliv-transit { background: #e8f8f5; color: #1abc9c; }
.badge-deliv-livree { background: #eafaf1; color: #27ae60; }
.badge-deliv-echec { background: #fdedec; color: #e74c3c; }
.badge-deliv-retour { background: #fcf3cf; color: #b7950b; }

/* 3. Statuts Paiement */
.badge-pay-attente { background: #fef5e7; color: #e67e22; }
.badge-pay-paye { background: #e8f8f5; color: #2ecc71; font-weight: 700; }
.badge-pay-echec { background: #fdedec; color: #e74c3c; }
.badge-pay-rembourse { background: #eaeded; color: #7f8c8d; }

/* Origine Badge */
.badge-origin-site { background: #eaf2e8; color: var(--brand-primary); }
.badge-origin-ileycom { background: #f5eef8; color: #8e44ad; font-weight: bold; }
.badge-origin-intl { background: #eaf2f8; color: #2980b9; }

/* -----------------------------------------------------------------------------
   Filtres et Barre d'actions
   ----------------------------------------------------------------------------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background-color: #FAF8F5;
    border-bottom: 1px solid var(--brand-border);
}

.search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 240px;
}

.search-input-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--brand-muted);
}

.search-input-wrap input {
    width: 100%;
    padding: 0.65rem 1rem 0.65rem 2.4rem;
    border: 1px solid var(--brand-border);
    border-radius: 50px;
    font-size: 0.9rem;
    outline: none;
    background-color: #FFFFFF;
}

.search-input-wrap input:focus {
    border-color: var(--brand-primary);
}

.filter-select {
    padding: 0.65rem 1.2rem;
    border: 1px solid var(--brand-border);
    border-radius: 50px;
    font-size: 0.85rem;
    background-color: #FFFFFF;
    color: var(--brand-text);
    outline: none;
    cursor: pointer;
}

.filter-select:focus {
    border-color: var(--brand-primary);
}

/* -----------------------------------------------------------------------------
   GABARIT DEVIS ET FACTURES A4 HAUTE FIDÉLITÉ (Modèle Clinique Ennasr)
   ----------------------------------------------------------------------------- */
.a4-preview-wrapper {
    background: #e2ded8;
    padding: 2rem;
    display: flex;
    justify-content: center;
    overflow-x: auto;
}

.a4-page {
    width: 210mm;
    min-height: 297mm;
    padding: 20mm;
    background: #FFFFFF;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    position: relative;
    color: #2F2A25;
}

.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.brand-logo-wrap .doc-logo {
    height: 65px;
    width: auto;
    object-fit: contain;
}

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

.doc-type-title {
    font-family: 'Poppins', sans-serif;
    font-size: 30px;
    font-weight: 700;
    color: #2F2A25;
    margin: 0;
    line-height: 1;
}

.doc-ref {
    font-size: 13px;
    font-weight: 600;
    color: #424746;
    margin-top: 6px;
}

.doc-date {
    font-size: 13px;
    color: #6e6862;
    margin-top: 3px;
}

.header-divider {
    height: 3px;
    background-color: var(--brand-primary);
    width: 100%;
    margin-bottom: 22px;
}

.parties-container {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 25px;
}

.party-box {
    flex: 1;
    padding: 16px 20px;
    border-radius: 6px;
    font-size: 13px;
}

.brand-party {
    background-color: #F3F6F3;
    border: 1px solid rgba(75, 108, 79, 0.15);
}

.brand-party .party-name {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 15px;
    color: var(--brand-primary);
    margin-bottom: 8px;
}

.party-contact-row {
    color: #424746;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.client-party {
    background-color: #FFFFFF;
    border: 1px solid #eef2ee;
}

.client-party .party-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--brand-muted);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.client-party .client-name {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 15px;
    color: #2F2A25;
    margin-bottom: 6px;
}

.delivery-mention-label {
    font-size: 11px;
    color: var(--brand-muted);
    margin-top: 6px;
}

.delivery-mention-val {
    font-size: 13px;
    color: #424746;
    font-weight: 500;
}

.section-banner-title {
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #2F2A25;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Tableau Devis / Facture */
.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
    font-size: 13px;
}

.doc-table thead th {
    background-color: var(--brand-primary);
    color: #FFFFFF;
    padding: 10px 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    font-size: 12px;
}

.doc-table th.col-desc, .doc-table td.col-desc { text-align: left; }
.doc-table th.col-qty, .doc-table td.col-qty { text-align: center; width: 60px; }
.doc-table th.col-unit, .doc-table td.col-unit { text-align: right; width: 120px; }
.doc-table th.col-total, .doc-table td.col-total { text-align: right; width: 130px; }

.doc-table tbody tr {
    border-bottom: 1px solid #eef0ee;
}

.doc-table tbody td {
    padding: 12px 14px;
    vertical-align: middle;
}

.item-title {
    font-weight: 600;
    color: #2F2A25;
}

.item-sub {
    font-size: 11px;
    color: #8C857E;
    margin-top: 3px;
}

.text-discount {
    color: #c0392b;
}

/* Encadré Totaux */
.totals-banner {
    background-color: #F3F6F3;
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #424746;
}

.totals-value-highlight {
    font-family: 'Poppins', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--brand-primary);
}

.main-total-row {
    border-top: 1px solid rgba(75, 108, 79, 0.2);
    padding-top: 8px;
    margin-top: 4px;
}

.totals-value-large {
    font-family: 'Poppins', sans-serif;
    font-size: 24px;
    font-weight: 800;
    color: var(--brand-primary);
}

/* Conditions */
.doc-conditions-section {
    margin-bottom: auto;
}

.conditions-title {
    font-family: 'Poppins', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: #2F2A25;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.conditions-list {
    list-style: none;
    font-size: 11px;
    line-height: 1.6;
    color: #555555;
}

.conditions-list li {
    margin-bottom: 3px;
}

/* Pied de page A4 */
.doc-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid #E5E0D8;
    font-size: 11px;
    color: #8C857E;
    margin-top: 20px;
}

/* -----------------------------------------------------------------------------
   Print Media Query
   ----------------------------------------------------------------------------- */
@media print {
    body {
        background: #FFFFFF;
    }
    .admin-sidebar, .admin-topbar, .btn-primary, .btn-secondary, .modal-backdrop {
        display: none !important;
    }
    .admin-main-wrap {
        margin-left: 0 !important;
    }
    .a4-preview-wrapper {
        padding: 0 !important;
        background: none !important;
    }
    .a4-page {
        box-shadow: none !important;
        padding: 15mm !important;
        width: 100% !important;
        height: 100% !important;
    }
}

/* Responsive Mobile */
@media (max-width: 992px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .admin-sidebar.open {
        transform: translateX(0);
    }
    .admin-main-wrap {
        margin-left: 0;
    }
}
