/* ============================================================
   DATATABLES & TABLEAUX
   (Source: New - Version avec filtres compacts)
   ============================================================ */
.dataTables_wrapper,
.konki-table-fit th {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.table.konki-table > tbody > tr > td {
    padding: 6px 6px !important;
}

/* Première colonne */
.platform-cell {
    width: 1% !important;
    white-space: nowrap;
    text-align: center;
}

/* Unique à Dev : Couleur spécifique pas de plateforme */
.no_platform_order {
    color: #afc5e1;
}

/* Unique à Dev : Cellule numéro de commande */
.ordernumber-cell {
    width: 1%;
    white-space: nowrap;
}

/* Hover lignes normales */
#orders_table.dataTable tbody tr:not(.shown):hover > * {
    background-color: rgba(0, 123, 255, 0.08) !important;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

#orders_table.dataTable tbody tr.shown > *,
#orders_table.dataTable tbody tr.shown:hover > * {
    background-color: rgba(0, 123, 255, 0) !important;
    cursor: default;
}

/* --- Barre d'outils DataTables Compacte (New) --- */
.orders-filters-row {
    margin-left: 0;
    margin-right: 0;
}

.order-filters .toggle_disputed {
    flex: 0 0 100%;
    max-width: 100%;
    justify-content: left;
}

/* Selecteur "Afficher X éléments" compact */
.dataTables_length select.form-control,
.dataTables_length select.form-control-sm {
    width: auto !important;
    min-width: 45px;
    display: inline-block !important;
    margin: 0 !important;
    padding-left: 6px !important;
    padding-right: 6px !important;
    text-indent: 0;
    text-align-last: center;
}

/* Champ de recherche compact */
.dataTables_filter input.form-control,
.dataTables_filter input.form-control-sm {
    width: 100px !important;
    padding: 3px 8px !important;
    height: 28px !important;
    font-size: 0.8rem !important;
    margin-left: 0 !important;
    border-radius: 50px !important;
}

.dt-toolbar-row {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
}

.dt-toolbar-row > [class*="col-"] {
    flex: 0 1 auto;
    max-width: none;
    padding-left: 12px;
    padding-right: 12px;
    margin-top: 0;
}

.dt-toolbar-row .dataTables_length,
.dt-toolbar-row .dataTables_filter {
    white-space: nowrap;
}

/* Alignement vertical */
.dt-toolbar-row .dataTables_length label,
.dt-toolbar-row .dataTables_filter label {
    display: flex !important;
    align-items: center !important;
    height: 28px;
    margin: 0;
    padding: 0; /* évite le gros padding partout */
    column-gap: 6px;
}

.dt-toolbar-row .dataTables_filter input {
    height: 28px !important;
    line-height: 28px !important;
    margin: 0 !important;
}

/* Décoller "Affichage de l'élément..." du bord de la box */
#orders_table_wrapper #orders_table_info {
    padding-left: 12px; /* ajuste 8 / 10 / 12 px selon ton goût */
}

/* Quand ça devient un peu étroit : texte au-dessus, pagination en dessous */
@media (max-width: 1400px) {
    /* ajuste le breakpoint si besoin */
    /* La dernière row (info + pagination) du wrapper */
    #orders_table_wrapper > .row:last-child > [class*="col-"] {
        flex: 0 0 100% !important; /* chaque colonne prend 100% */
        max-width: 100% !important; /* => elles passent l’une sous l’autre */
    }

    /* petit espace entre le texte et les numéros de page */
    #orders_table_info {
        margin-bottom: 4px;
    }
}

/* Nettoyage styles par défaut DataTables */
table.dataTable,
table.dataTable th,
table.dataTable td {
    border: none !important;
}

table.dataTable {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
}

table.dataTable.no-footer {
    border: none !important;
}

.dataTables_wrapper .dataTables_scrollHead table,
.dataTables_wrapper .dataTables_scrollBody table {
    border: none !important;
}

/* Zebra striping */
table.dataTable tbody tr:nth-child(odd) {
    background-color: #f8f9fa !important;
}

table.dataTable tbody tr:nth-child(even) {
    background-color: #ffffff !important;
}

/* Icônes de tri personnalisées */
table.dataTable thead .sorting::after,
table.dataTable thead .sorting_asc::after,
table.dataTable thead .sorting_desc::after,
table.dataTable thead .sorting::before,
table.dataTable thead .sorting_asc::before,
table.dataTable thead .sorting_desc::before {
    display: none !important;
    content: none !important;
}

table.dataTable thead .sorting {
    background-image: url(/static/assets/img/sort_icons/sort_both.png);
    background-repeat: no-repeat;
    background-position: center right;
}

table.dataTable thead .sorting_asc {
    background-image: url(/static/assets/img/sort_icons/sort_asc.png);
    background-repeat: no-repeat;
    background-position: center right;
}

table.dataTable thead .sorting_desc {
    background-image: url(/static/assets/img/sort_icons/sort_desc.png);
    background-repeat: no-repeat;
    background-position: center right;
}

/* Mobile : cacher la colonne Date, afficher date+heure sous la Réf */
@media (max-width: 767.98px) {

    /* 4e colonne = Date -> cachée */
    #orders_table th:nth-child(4),
    #orders_table td:nth-child(4) {
        display: none;
    }

    /* Date/heure sous la réf, en petit */
    #orders_table td:nth-child(2)[data-date]::after {
        content: attr(data-date);
        display: block;
        font-size: 0.8rem;
        color: #bbc0c4;
        margin-top: 2px;
        line-height: 1.1;
    }

    /* 5e colonne = Montant -> largeur fixe */
    #orders_table td:nth-child(5),
    #orders_table th:nth-child(5) {
        min-width: 70px !important;
        white-space: nowrap;
    }
}

#orders_table {
    table-layout: auto !important;
}

#orders_table td.amount-cell,
#orders_table th.amount-cell {
    display: table-cell !important;
}

@media (max-width: 768px) {

    #orders_table_wrapper .row:first-child {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center;
        justify-content: space-between;
    }

    #orders_table_wrapper .dataTables_length,
    #orders_table_wrapper .dataTables_filter {
        display: flex !important;
        align-items: center;
        white-space: nowrap !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Réduction du champ pour qu’il tienne */
    #orders_table_wrapper .dataTables_filter input {
        width: 130px !important;
        min-width: 130px !important;
        margin-left: 6px !important;
    }

    /* On neutralise les colonnes BS4 qui foutent tout en colonne */
    #orders_table_wrapper .row:first-child > div {
        flex: 0 0 auto !important;
        width: auto !important;
    }

    #orders_table th.status-cell,
    #orders_table td.status-cell {
        width: 70px !important;
        max-width: 70px !important;
        min-width: 70px !important;
        text-align: left;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ============================================================
   NAVBAR & HEADER
   (Source: New - Meilleure gestion flexbox et mobile)
   ============================================================ */
.navbar-custom-menu .navbar-nav > li > a {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 48px;
    min-width: 48px;
    padding: 0 10px;
    position: relative;
    transition: color .2s, background-color .2s;
}

.navbar-custom-menu .navbar-nav > li > a i {
    font-size: 1.4rem;
    color: #333;
    transition: color .2s;
}

.navbar-custom-menu .badge-pill {
    height: 32px;
    width: 32px;
    background: #2c3241;
    color: white;
    font-size: .85rem;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.navbar-custom-menu .navbar-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: .65rem;
    padding: 3px 5px;
    border-radius: 10px;
}

/* Hover Effects */
.navbar-custom-menu .user-menu > a:hover .badge-pill,
.navbar-custom-menu .order-menu > a:hover i,
.navbar-custom-menu .notifications-menu > a:hover i,
.navbar-custom-menu .connexions-menu > a:hover i {
    color: var(--bs-primary, #007bff);
}

.navbar-custom-menu .user-menu > a:hover .badge-pill {
    background-color: var(--bs-primary, #007bff);
}

.navbar-custom-menu .avatar {
    width: 24px;
    height: 24px;
    border-radius: 50% !important;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
}

/* Toolbar Restaurant Selector (New) */
.navbar .header-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.navbar .restaurant-selector,
.navbar .restaurant-selector .btn {
    display: flex;
    align-items: center;
    margin: 0;
}


.notification-item {
    display: block;
    padding: 0.5rem 0.75rem;
    width: 100%;
    text-decoration: none;
    color: inherit;
}

.notification-title {
    white-space: normal;
    word-break: break-word;
}


/* Responsive Navbar (New) */
/* Responsive Navbar (MAJ) : resto à gauche, icônes à droite */
@media (max-width: 767.98px) {
    .navbar-custom-menu {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        width: 100%;
        height: auto;
        padding-top: 0;
        padding-bottom: 0;
    }

    .navbar .header-toolbar {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 0.5rem;
    }

    /* Sélecteur resto collé à gauche */
    .navbar .restaurant-selector {
        margin: 0;
        margin-right: auto;
    }

    /* Icônes (globe, cloche, avatar) à droite */
    .navbar .header-icons {
        margin-left: auto;
    }

    /* Le bouton du sélecteur garde sa taille normale */
    .navbar .restaurant-selector .btn {
        height: 34px;
        display: inline-flex;
        align-items: center;
    }

    /* Dropdown du sélecteur de restaurant : aligné à gauche du bouton */
    .navbar .restaurant-selector .dropdown-menu {
        left: 0 !important;
        right: auto !important;
        transform: none; /* au cas où un translate serait appliqué */
        margin-top: 4px; /* petit espace sous le bouton */
    }

}


/* Unique à Dev : Icon Camera Control */
.icon-camera-control {
    display: inline-block;
    width: 1.4em;
    height: 1.4em;
    background-color: currentColor;
    mask: url('/static/assets/img/camera-control.svg') no-repeat center;
    -webkit-mask: url('/static/assets/img/camera-control.svg') no-repeat center;
    mask-size: contain;
    -webkit-mask-size: contain;
}

.navbar-nav > li > a:hover .icon-camera-control {
    color: var(--bs-primary, #007bff);
}

/* Dropdown Menus (Connexions/Notifications) */
.navbar-custom-menu .dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: auto;
    z-index: 1050;
    min-width: 220px;
    max-width: 300px;
    white-space: normal;
    display: none;
}

.navbar-custom-menu .dropdown.open .dropdown-menu,
.navbar-custom-menu .dropdown-menu.show {
    display: block;
}

/* Menu Connexions Items */

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

.status-dot.success {
    background-color: #16a34a;
}

.status-dot.danger {
    background-color: #ef4444;
}

.status-dot.warning {
    background-color: #f59e0b;
}

.status-dot.secondary {
    background-color: gray;
}

/* L'item prend toute la largeur */
.connexions-menu .dropdown-menu li.connection-entry {
    width: 100%;
    display: block;
}

/* Le lien couvre toute la largeur */
.connexions-menu .dropdown-menu .connexion-item {
    display: block;
    width: 100%;
    padding: 10px 15px;
    box-sizing: border-box;

    text-decoration: none;
    color: inherit;


    box-shadow: none !important;
}

/* Le contenu interne s’étire correctement */
.connexions-menu .dropdown-menu .connexion-item .d-flex {
    width: 100%;
}

/* Hover clean */
.connexions-menu .dropdown-menu .connexion-item:hover {
    background: #f5f5f5;
}

.connexions-menu .dropdown-menu .connexion-item .status-dot {
    align-self: center;
}

/* ============================================================
   VNC MODAL & IFRAME
   (Source: New & Dev identiques, priorité New)
   ============================================================ */
#kbVncModal .kb-dialog {
    max-width: none;
    width: var(--kb-w, 650px);
    min-height: 100vh;
    display: flex;
    align-items: center;
    margin: auto;
}

#kbVncModal .modal-content {
    width: 100%;
    max-height: 90vh;
}

#kbVncModal .modal-body {
    padding: 1rem;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#kbVncModal .kb-head-actions {
    display: flex;
    gap: .5rem;
    margin-left: auto;
    margin-right: .25rem;
}

.kb-phone {
    width: var(--kb-w, 650px);
    height: var(--kb-h, 1125px);
    aspect-ratio: 430/750;
    max-height: calc(90vh - var(--kb-chrome, 120px));
    background: #000;
    border: 1px solid #222;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .25);
}

.kb-phone iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
}

.kb-side .kv {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 6px 0;
    font-size: 13px;
}

.kb-side code {
    background: #f6f6f9;
    padding: 2px 6px;
    border-radius: 6px;
}

.kb-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 6px;
    display: inline-block;
}

.kb-ok {
    background: #16a34a;
}

.kb-warn {
    background: #f59e0b;
}

.kb-err {
    background: #ef4444;
}

/* ============================================================
   KPI BOX (Unique à New)
   ============================================================ */
.kpi-item {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding-left: .25rem;
}

.kpi-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 1rem;
}

.kpi-value {
    font-size: 22px;
    font-weight: 300;
}

.kpi-label {
    font-size: .75rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ============================================================
   ELEMENTS UNIQUES À DEV (Préservés)
   ============================================================ */

/* --- Dropzone / Upload --- */
.dz-default.dz-message {
    border: 2px dashed #b5c1d1 !important;
    border-radius: 8px;
    padding: 18px;
    background: transparent !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: background-color 0.3s ease;
}

.dz-default.dz-message:hover {
    background: transparent !important;
}

.dropzone {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

.upload-icon {
    font-size: 3.5rem;
    color: #9cb4d8;
    margin-bottom: 12px;
}

.upload-main-text {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}

.upload-sub-text {
    font-size: 0.9rem;
    color: #666;
    margin: 4px 0 0 0;
}

.upload-link {
    color: #337ab7;
    font-weight: 500;
    cursor: pointer;
    text-decoration: underline;
}

.upload-link:hover {
    color: #23527c;
}

/* --- Map / Leaflet --- */
.box.box-map {
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 10px;
    background: #fff;
    display: flex;
    flex-direction: column;
}

.box.box-map .box-header {
    flex: 0 0 auto;
    background: #fff;
    padding: 10px 15px;
    border-bottom: 1px solid #ddd;
    z-index: 2;
    position: relative;
}

.box.box-map .box-body-pane.box-map-body-pane {
    flex: 1 1 auto;
    position: relative;
    padding: 0;
    margin: 0;
    min-height: 400px;
}

.map-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 400px);
    overflow: hidden;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.leaflet-container {
    display: block;
    position: relative !important;
    width: 100%;
    height: calc(100vh - 400px);
    margin-top: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    z-index: 1;
}

.leaflet-top, .leaflet-bottom {
    z-index: 2;
}

/* --- Charts --- */
.chart-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 250px);
    max-height: 700px;
    overflow: hidden;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* --- Passwords --- */
.alert-password li.text-success {
    font-weight: 500;
}

.alert-password li.password-text-muted {
    font-style: italic;
    font-weight: 100;
}

/* ============================================================
   MOBILE & LAYOUT
   (Mixte : Bottom Nav de New + Grid de Dev)
   ============================================================ */

/* Bottom Nav (New) */
.konki-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1050;
    font-size: 11px;
}

.konki-bottom-nav .nav-item {
    flex: 1;
    text-align: center;
    padding: 4px 0;
    color: #777;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.konki-bottom-nav .nav-item i {
    font-size: 18px;
    margin-bottom: 2px;
}

.konki-bottom-nav .nav-item.active,
.konki-bottom-nav .nav-item:hover {
    color: #0d6efd;
}

/* Mobile Overrides (New + Dev) */
@media (max-width: 767.98px) {
    .content-wrapper, .main-footer {
        padding-bottom: 70px;
    }

    .main-sidebar, .push-btn {
        display: none !important;
    }

    body.sidebar-collapse .sidebar-footer {
        display: none !important;
    }
}

/* Grid System (Dev) */
.dashboard-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
}

@media (min-width: 992px) {
    .dashboard-grid > [class*="col-lg"] {
        display: flex;
        flex-direction: column;
    }

    .photo-upload-box {
        height: 100%;
    }

    .photo-upload-box .box-body {
        flex: 1;
    }
}

@media (max-width: 992px) {
    .dashboard-grid > [class^="col-"] {
        padding-left: 0px !important;
        padding-right: 0px !important;
    }

    .dashboard-grid {
        margin: 0 !important;
        padding: 0 !important;
    }

    .photo-upload-box .box-body {
        display: none;
    }

    .photo-upload-box.open .box-body {
        display: block;
    }

    .content .row, .col-sm-12, .col-md-12, .col-lg-12 {
        margin: 0 !important;
        padding: 0 !important;
    }

    .box {
        border-radius: 8px;
        margin-bottom: 15px;
    }
}

/* Toolbar DataTables : marge et padding valables même en mobile */
@media (max-width: 992px) {
    .content .row.dt-toolbar-row {
        margin-top: 20px !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

/* Version desktop (>= 992px) si tu veux garder la même chose partout */
@media (min-width: 992px) {
    .dt-toolbar-row {
        margin-top: 20px;
        padding: 0 12px;
    }
}

/* Mobile : blocs Commandes / KPIs / Photos en plein écran */
@media (max-width: 767.98px) {

    /* 1) Enlever le padding horizontal global */
    .content,
    .content-wrapper .container-full {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* 2) La row principale ne rajoute pas de marge */
    .content .dashboard-grid {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* 3) Chaque colonne de la dashboard-grid occupe 100% */
    .dashboard-grid > [class*="col-"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        padding-left: 0 !important; /* neutralise px-2 */
        padding-right: 0 !important;
    }

    /* 4) Les box prennent toute la largeur réelle */
    .dashboard-grid .box {
        border-radius: 0; /* optionnel, pour vrai “full width” */
        width: 100%;
    }
}
