/**
 * AMM-ERP - Feuille de style principale
 * Lubumbashi, RDC
 */

/* ============================================================
   VARIABLES CSS
   ============================================================ */
:root {
    --amm-primary:    #1a3c5e;
    --amm-secondary:  #2d6ea5;
    --amm-sidebar-bg: #1e2a3a;
    --amm-font:       'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============================================================
   BASE
   ============================================================ */
body {
    font-family: var(--amm-font);
    font-size: 0.9rem;
    color: #333;
    background-color: #f4f6f9;
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar {
    background: linear-gradient(180deg, #1e2a3a 0%, #2c3e50 100%);
    transition: width 0.3s ease;
}

#sidebar .nav-link {
    font-size: 0.85rem;
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

#sidebar .nav-link:hover,
#sidebar .nav-link.active {
    background-color: rgba(255,255,255,0.15);
}

/* ============================================================
   CARTES
   ============================================================ */
.card {
    border-radius: 10px;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.1) !important;
}

.card-header {
    border-radius: 10px 10px 0 0 !important;
    font-size: 0.9rem;
}

/* ============================================================
   TABLEAUX
   ============================================================ */
.table {
    font-size: 0.855rem;
}

.table th {
    font-weight: 600;
    letter-spacing: 0.02em;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.table td {
    vertical-align: middle;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3em 0.6em;
    border-radius: 6px;
}

/* ============================================================
   BOUTONS
   ============================================================ */
.btn {
    border-radius: 7px;
    font-size: 0.85rem;
    font-weight: 500;
}

.btn-xs {
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
}

/* ============================================================
   FORMULAIRES
   ============================================================ */
.form-control, .form-select {
    border-radius: 7px;
    font-size: 0.88rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--amm-secondary);
    box-shadow: 0 0 0 0.2rem rgba(45,110,165,0.2);
}

.form-label {
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
}

/* ============================================================
   BREADCRUMBS
   ============================================================ */
.breadcrumb {
    font-size: 0.8rem;
    background: none;
    padding: 0;
}

/* ============================================================
   ALERTES
   ============================================================ */
.alert {
    border-radius: 8px;
    font-size: 0.88rem;
}

/* ============================================================
   NOTIFICATIONS DROPDOWN
   ============================================================ */
.dropdown-menu.shadow {
    border: 0;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15) !important;
}

/* ============================================================
   PAGE DE LOGIN
   ============================================================ */
.login-card {
    animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   STATUTS DES COURRIERS (couleurs en ligne)
   ============================================================ */
.statut-overdue { border-left: 4px solid #dc3545; }
.statut-urgent  { border-left: 4px solid #ffc107; }

/* ============================================================
   ZONE DE DRag & DROP pour les fichiers
   ============================================================ */
.drop-zone-active {
    background-color: rgba(45,110,165,0.1) !important;
    border-color: var(--amm-secondary) !important;
}

/* ============================================================
   SCROLLBAR PERSONNALISÉE (sidebar)
   ============================================================ */
.app-sidebar::-webkit-scrollbar {
    width: 4px;
}
.app-sidebar::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
}
.app-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .app-sidebar-desktop {
        display: none !important;
    }

    main {
        width: 100% !important;
    }

    .app-search-form {
        margin-top: 0.75rem;
        margin-bottom: 0.5rem;
    }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

/* Spin pour les actions AJAX en cours */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner-tiny {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* ============================================================
   PRO UI THEME OVERRIDES
   ============================================================ */
:root {
    --pro-bg: #f3f6fb;
    --pro-panel: #ffffff;
    --pro-ink: #1a2a3a;
    --pro-muted: #627487;
    --pro-primary: #16395b;
    --pro-accent: #2b6aa6;
    --pro-line: #d8e1ec;
    --pro-shadow: 0 14px 36px rgba(17, 40, 68, 0.1);
    --pro-radius: 10px;
    --pro-gap: 0.75rem;
}

body.app-body {
    font-family: 'Manrope', sans-serif;
    color: var(--pro-ink);
    background:
        radial-gradient(circle at 0% 0%, rgba(22, 57, 91, 0.08) 0%, transparent 32%),
        linear-gradient(180deg, #f6f9fd 0%, var(--pro-bg) 100%);
}

.app-main {
    background: transparent;
}

.app-topbar {
    background: linear-gradient(95deg, #0f2f4f 0%, #1a4f7c 65%, #26649a 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 8px 22px rgba(12, 39, 68, 0.24);
}

.app-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    margin-right: 0.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.app-brand-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.app-topbar .navbar-brand {
    color: #f4f8fd;
    letter-spacing: 0.01em;
}

.app-topbar-toggler {
    border-color: rgba(255, 255, 255, 0.25);
}

.app-search-group .form-control {
    background: rgba(255, 255, 255, 0.96);
    border: 0;
}

.app-search-group .btn {
    color: #12385c;
    background: #edf5fd;
    border: 0;
}

.app-topbar-icon-btn,
.app-profile-btn {
    color: #eaf2fb;
    text-decoration: none;
}

.app-topbar-icon-btn:hover,
.app-profile-btn:hover {
    color: #ffffff;
}

.app-role-badge {
    background: #f3c46b;
    color: #273341;
    font-weight: 700;
}

.app-notif-dropdown {
    border-radius: 12px;
    border: 1px solid var(--pro-line);
}

.app-sidebar {
    background: linear-gradient(185deg, #16283d 0%, #1e3249 100%) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    width: 270px;
    min-height: calc(100vh - 56px);
    overflow-y: auto;
}

.app-sidebar-desktop {
    position: sticky;
    top: 56px;
}

.app-sidebar-mobile {
    min-height: 100%;
    width: 100%;
    border-right: 0;
}

.app-sidebar-offcanvas {
    background: linear-gradient(185deg, #16283d 0%, #1e3249 100%);
    color: #eef4fb;
    max-width: 320px;
}

.app-sidebar-offcanvas .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.app-sidebar-topcard {
    padding: 0.9rem;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar-topcard-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #8ea5bc;
    margin-bottom: 0.25rem;
}

.app-sidebar-topcard-title {
    color: #ffffff;
    font-weight: 700;
    line-height: 1.2;
}

.app-sidebar-topcard-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    margin-top: 0.55rem;
}

.app-sidebar-topcard-service {
    color: #bdd0e2;
    font-size: 0.76rem;
}

.app-sidebar-quick {
    padding: 0.85rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar-quick-link {
    justify-content: flex-start;
    text-align: left;
    border-color: rgba(255,255,255,0.18);
    color: #eaf2fb;
    background: rgba(255,255,255,0.03);
}

.app-sidebar-quick-link:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.22);
}

.app-sidebar-stack {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.app-sidebar-group {
    padding: 0.35rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.app-sidebar-section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 0;
    background: transparent;
    color: #f1f6fb;
    padding: 0.4rem 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
}

.app-sidebar-section-toggle:hover {
    color: #ffffff;
}

.app-sidebar-chevron {
    transition: transform 0.2s ease;
    font-size: 0.8rem;
}

.app-sidebar-section-toggle:not(.collapsed) .app-sidebar-chevron {
    transform: rotate(180deg);
}

.app-sidebar-section-body {
    padding: 0.15rem 0;
}

.app-sidebar-section-title {
    display: block;
    text-transform: uppercase;
    color: #8ea5bc;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.09em;
}

.app-sidebar-link {
    display: flex;
    align-items: center;
    color: #d9e5f2 !important;
    font-size: 0.84rem;
    padding: 0.52rem 0.72rem !important;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.app-sidebar-link:hover {
    background: rgba(255, 255, 255, 0.09) !important;
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateX(1px);
}

.app-sidebar-link.active {
    background: linear-gradient(95deg, rgba(43, 106, 166, 0.65), rgba(58, 128, 194, 0.55)) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 8px 20px rgba(13, 32, 53, 0.35);
}

.app-sidebar-count {
    background: #f25f5c;
    color: #ffffff;
    min-width: 1.65rem;
    text-align: center;
    border-radius: 999px;
}

.app-sidebar-divider {
    border-color: rgba(255, 255, 255, 0.14);
}

.app-sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    color: #90a8bf;
}

.container-fluid > .d-flex.justify-content-between.align-items-center.mb-4 h2 {
    font-family: 'Merriweather', serif;
    letter-spacing: 0.01em;
}

.card {
    border: 1px solid var(--pro-line);
    background: var(--pro-panel);
    box-shadow: var(--pro-shadow);
    border-radius: 14px;
}

.card:hover {
    box-shadow: 0 16px 34px rgba(17, 40, 68, 0.13) !important;
}

.card-header {
    border-bottom: 1px solid #e9eff6;
    background: linear-gradient(180deg, #f9fbfe 0%, #f4f8fc 100%);
    color: var(--pro-ink);
    font-weight: 700;
}

.table thead th {
    background: #eff4fa;
    color: #384b5d;
    border-bottom: 1px solid #d7e1ed;
}

.table tbody tr:hover {
    background: #f7fbff;
}

.btn {
    border-radius: var(--pro-radius);
    font-weight: 600;
    min-height: 36px;
    padding: 0.45rem 0.85rem;
    letter-spacing: 0.01em;
}

.btn-sm {
    min-height: 30px;
    padding: 0.28rem 0.62rem;
}

.btn-primary,
.btn-success {
    box-shadow: 0 8px 16px rgba(23, 56, 88, 0.18);
}

.form-control,
.form-select {
    border-color: #cfd9e6;
    background: #ffffff;
}

.form-control:focus,
.form-select:focus {
    border-color: #84a9cf;
    box-shadow: 0 0 0 0.2rem rgba(43, 106, 166, 0.15);
}

.alert {
    border-width: 1px;
}

.badge {
    border-radius: 7px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.3rem 0.55rem;
    letter-spacing: 0.01em;
}

.btn-group-sm > .btn {
    min-height: 30px;
}

.table td,
.table th {
    padding-top: 0.72rem;
    padding-bottom: 0.72rem;
}

.card-body {
    padding: 1rem;
}

.card-footer {
    padding: 0.72rem 1rem;
}

.app-main > .container-fluid {
    padding-left: 0.2rem;
    padding-right: 0.2rem;
}

.app-status-legend {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0.55rem;
}

/* Mode compact (densite elevee) */
body.density-compact .app-main {
    padding: 0.9rem !important;
}

body.density-compact .page-hero,
body.density-compact .dashboard-hero {
    padding: 0.72rem 0.8rem;
}

body.density-compact .card-body {
    padding: 0.72rem;
}

body.density-compact .card-header {
    padding-top: 0.52rem;
    padding-bottom: 0.52rem;
}

body.density-compact .table td,
body.density-compact .table th {
    padding-top: 0.46rem;
    padding-bottom: 0.46rem;
    font-size: 0.82rem;
}

body.density-compact .btn {
    min-height: 31px;
    padding: 0.3rem 0.66rem;
    font-size: 0.79rem;
}

body.density-compact .badge {
    font-size: 0.68rem;
    padding: 0.22rem 0.45rem;
}

body.density-compact .form-control,
body.density-compact .form-select {
    min-height: 32px;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
    font-size: 0.82rem;
}

body.density-compact .list-group-item {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.app-footer {
    background: #15283c;
    color: #95a7ba;
    padding: 0.48rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.dashboard-hero {
    background: linear-gradient(115deg, #ffffff 0%, #f2f8ff 100%);
    border: 1px solid #d8e4f0;
    border-radius: 14px;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}

.dashboard-hero .hero-meta {
    color: #617487;
    font-size: 0.82rem;
}

.kpi-card {
    border: 1px solid #d8e4f0;
    border-radius: 14px;
    background: linear-gradient(160deg, #ffffff 0%, #f7fbff 100%);
    box-shadow: 0 12px 24px rgba(18, 48, 78, 0.08);
}

.kpi-card .kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.1;
}

.kpi-card .kpi-label {
    color: #65778a;
    font-size: 0.8rem;
    font-weight: 600;
}

.kpi-clickable {
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.kpi-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(18, 48, 78, 0.14) !important;
}

.kpi-clickable:active {
    transform: translateY(0);
}

/* ============================================================
   MODAL DÉTAIL DASHBOARD — Design Pro
   ============================================================ */

#dashboardDetailModal .modal-content {
    border-radius: 16px !important;
    overflow: hidden;
    box-shadow: 0 32px 64px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.08);
}

#dashboardDetailModal .modal-dialog {
    margin-top: 4rem;
}

#dashboardDetailModal .modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(0,0,0,.07);
    transition: background .25s ease;
}

#dashboardDetailModal .modal-body {
    padding: 0;
    overflow-y: auto;
    max-height: 58vh;
}

#dashboardDetailModal .modal-footer {
    background: #f8fafc;
    border-top: 1px solid #e9ecef;
    padding: .875rem 1.5rem;
}

#dashboardDetailModal .table {
    margin: 0;
}

#dashboardDetailModal .table thead th {
    white-space: nowrap;
}

#dashboardDetailModal .table tbody tr {
    border-bottom: 1px solid rgba(0,0,0,.04);
    transition: background-color .12s ease;
}

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

#dashboardDetailModal .dsd-row-link:hover {
    background-color: rgba(13,110,253,.04);
}

#dashboardDetailModal .dsd-icon-wrap {
    transition: background .25s ease;
}

/* Badges urgence / statut dans les modales détail */
.dsd-badge {
    display: inline-block;
    padding: .2em .65em;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
    vertical-align: middle;
}

.dsd-badge-dot {
    display: inline-flex;
    align-items: center;
}


.section-card {
    border: 1px solid #d8e4f0;
    border-radius: 14px;
    overflow: hidden;
}

.page-hero {
    background: linear-gradient(120deg, #ffffff 0%, #f4f9ff 100%);
    border: 1px solid #d8e4f0;
    border-radius: 14px;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}

.page-hero h2 {
    margin-bottom: 0.1rem;
}

.filter-card {
    border: 1px solid #d8e4f0;
    border-radius: 14px;
    background: #fbfdff;
}

.form-card {
    border: 1px solid #d8e4f0;
    border-radius: 14px;
    background: #ffffff;
}

.summary-card {
    border: 1px solid #d8e4f0;
    border-radius: 14px;
    background: linear-gradient(160deg, #ffffff 0%, #f7fbff 100%);
}

.table-dark {
    --bs-table-bg: #24384e;
    --bs-table-border-color: #304960;
}

.pro-drop-zone {
    border-style: dashed !important;
    border-color: #c2d2e4 !important;
    background: linear-gradient(180deg, #f9fcff 0%, #f3f8fe 100%);
    border-radius: 12px;
}
