/* ============================================================
   Sodex ERP — Styles personnalisés
   ============================================================ */

/* -- Variables de design -- */
:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1a1d23;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
    --sidebar-active-bg: rgba(13, 110, 253, 0.25);
    --sidebar-active-border: #0d6efd;
    --sidebar-text: rgba(255, 255, 255, 0.85);
    --brand-primary: #0d6efd;
    --surface-bg: #f5f6fa;
    --card-shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
    --card-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.1);
    --transition-speed: 0.2s;
}

/* -- Layout général -- */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--surface-bg);
    min-height: 100vh;
    margin: 0;
    color: #212529;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    position: sticky;
    top: 0;
    height: 100vh;
    background-color: var(--sidebar-bg) !important;
    transition: transform var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-logo-img {
    filter: brightness(0) invert(1);
    flex-shrink: 0;
}

.sidebar-version {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.05em;
}

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.3);
    padding: 0 0.75rem;
    display: block;
    margin: 0.5rem 0 0.25rem;
}

/* Liens de navigation */
.sidebar-link {
    border-radius: 0.5rem;
    padding: 0.625rem 0.875rem;
    margin-bottom: 0.125rem;
    color: var(--sidebar-text) !important;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.sidebar-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: #fff !important;
}

.sidebar-link.active {
    background-color: var(--sidebar-active-bg);
    color: #fff !important;
    border-left: 3px solid var(--sidebar-active-border);
    padding-left: calc(0.875rem - 3px);
}

/* Footer de la sidebar */
.sidebar-footer {
    background-color: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding: 0.875rem 1rem;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #6610f2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-role-badge {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.03em;
}

.user-menu-link:hover .sidebar-avatar {
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.4);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */

#main-content {
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: var(--card-shadow);
    border-radius: 0.625rem;
    background-color: #fff;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.875rem 1.25rem;
    border-radius: 0.625rem 0.625rem 0 0 !important;
    color: #344054;
}

.card-body {
    padding: 1.25rem;
}

/* ============================================================
   TABLES / DATATABLES
   ============================================================ */

.table thead th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    border-bottom: 1px solid #e9ecef;
    padding: 0.875rem 1rem;
    background-color: #f8f9fa;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    font-size: 0.9rem;
    border-bottom: 1px solid #f0f0f0;
}

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

.table-hover tbody tr:hover {
    background-color: #f8f9ff;
}

/* Aligner le premier th avec le padding de la card */
.card .table thead th:first-child,
.card .table tbody td:first-child {
    padding-left: 1.25rem;
}

.card .table thead th:last-child,
.card .table tbody td:last-child {
    padding-right: 1.25rem;
}

/* DataTables toolbar */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 0.375rem;
    border: 1px solid #dee2e6;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: 0.375rem;
    border: 1px solid #dee2e6;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 0.375rem !important;
    font-size: 0.875rem;
}

/* ============================================================
   KEBAB MENU / DROPDOWN ACTIONS
   ============================================================ */

.dropdown-menu {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.06);
    padding: 0.375rem;
    min-width: 160px;
    font-size: 0.875rem;
}

.dropdown-item {
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    transition: background-color 0.15s ease;
    font-size: 0.875rem;
}

.dropdown-item:hover {
    background-color: #f0f4ff;
}

.dropdown-item.text-danger:hover {
    background-color: #fff0f0;
}

.dropdown-item.text-warning:hover {
    background-color: #fffbf0;
}

.dropdown-item.text-success:hover {
    background-color: #f0fff4;
}

.dropdown-divider {
    margin: 0.25rem 0;
    border-color: rgba(0, 0, 0, 0.06);
}

/* Bouton kebab */
.btn-outline-secondary.border-0:hover {
    background-color: #f0f0f0;
    color: #495057;
}

/* ============================================================
   AVATARS CLIENTS
   ============================================================ */

.customer-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6610f2, #0d6efd);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ============================================================
   BADGES DE STATUT
   ============================================================ */

.badge {
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* ============================================================
   FORMULAIRES
   ============================================================ */

.form-control,
.form-select {
    border-color: #dee2e6;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.form-control:focus,
.form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.12);
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
}

.input-group-text {
    border-color: #dee2e6;
}

/* ============================================================
   PAGE LOGIN
   ============================================================ */

.auth-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8ecf7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

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

.login-card {
    border-radius: 0.875rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

/* ============================================================
   PAGES ERREUR / ACCÈS REFUSÉ
   ============================================================ */

.error-page-container {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
}

.error-page-card {
    text-align: center;
    max-width: 480px;
}

.error-icon-wrap {
    font-size: 5rem;
    line-height: 1;
    display: block;
}

/* ============================================================
   PAGE PROFIL
   ============================================================ */

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #6610f2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(13, 110, 253, 0.3);
}

/* ============================================================
   PAGE DÉTAILS
   ============================================================ */

.detail-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    display: block;
    margin-bottom: 0.25rem;
}

.detail-value {
    font-size: 0.9rem;
    color: #212529;
    margin-bottom: 0;
}

/* ============================================================
   BREADCRUMBS
   ============================================================ */

.breadcrumb {
    font-size: 0.8rem;
}

.breadcrumb-item a {
    color: #6c757d;
}

.breadcrumb-item a:hover {
    color: var(--brand-primary);
}

/* ============================================================
   FOOTER
   ============================================================ */

.footer {
    background-color: #fff;
    padding: 0.875rem 0;
    font-size: 0.8rem;
    color: #adb5bd;
}

/* ============================================================
   UTILITAIRES SPÉCIFIQUES AU PROJET
   ============================================================ */

/* Tables DataTables — largeur pleine colonne requise par le plugin */
.table-full-width {
    width: 100%;
}

/* Colonne d'actions dans les tables (kebab menu) */
.col-actions {
    width: 60px;
}

/* Lignes de table navigables au clic */
.row-clickable {
    cursor: pointer;
}

/* Pastille de statut (point coloré dans les badges) */
.badge-dot {
    font-size: 0.5rem;
    vertical-align: center;
}

/* Texte préformaté (notes, champs multi-lignes) */
.text-pre-wrap {
    white-space: pre-wrap;
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        z-index: 1050;
        transform: translateX(-100%);
        height: 100%;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.45);
        z-index: 1040;
        display: none;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .login-page {
        padding: 1.5rem 1rem;
        align-items: flex-start;
        padding-top: 3rem;
    }

    .container-fluid.p-4 {
        padding: 1rem !important;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
}
