/* ========================================
   JDGRID - CSS STRUCTURELLE COMMUNE
   ========================================

   Ce fichier est charge INCONDITIONNELLEMENT pour tous les themes
   (Base, Theme 1, Theme 2) depuis crm/inc/template_start.php, juste
   AVANT le <link id="jdgrid-theme-css"> permutable par changeTheme().

   Il contient la geometrie / le comportement dont le JS depend :
   .jdviews-sidebar-views {display:none} est l'etat par defaut sur
   lequel JDGrid.js s'appuie pour basculer .jdside-views-expanded.
   Ces regles ne sont PAS decoratives : sans elles la sidebar
   "Categories & Vues" s'affiche totalement depliee et sans style.

   NE JAMAIS dupliquer ces regles dans JDGrid.css, JDGrid-theme1.css
   ou tout futur fichier de theme : c'est precisement cette
   duplication qui avait fait diverger JDGrid-theme1.css.

   Les couleurs employees ici sont des gris neutres, volontairement
   compatibles avec les 3 themes.
   ======================================== */

/* Sentinelle de detection : permet a JDGrid.js de savoir si ce fichier est
   effectivement charge par le CRM hote (template_start ou equivalent).
   Sans elle, le mode "barre de vues laterale" et son bouton de bascule sont
   desactives automatiquement (cas du dossier jdgrid/ copie-colle seul dans
   un CRM qui n'a pas le <link> vers ce fichier). */
:root { --jdgrid-sidebar-css: 1; }

/* ========================================
   VIEWS POSITION: SIDE MODE (views_position=1)
   ======================================== */

/* Flex wrapper for sidebar + main content */
.jdgrid-side-layout {
    display: flex;
    flex-direction: row;
}

.jdgrid-side-main {
    flex: 1;
    min-width: 0;
}

/* Ensure modals are not trapped inside the flex layout */
.jdgridbox .modal {
    position: fixed;
    z-index: 1050;
}
.jdgridbox .modal-backdrop {
    z-index: 1040;
}

/* Sidebar panel */
.jdviews-sidebar {
    width: 280px;
    min-width: 280px;
    max-height: calc(100vh - 100px);
    border-right: 2px solid #e8e8e8;
    background: #fafbfc;
    overflow-y: auto;
    overflow-x: hidden;
    transition: margin-left 0.25s ease, opacity 0.25s ease;
    z-index: 50;
}

.jdviews-sidebar.jdviews-sidebar-hidden {
    display: none;
}

/* Sidebar header */
.jdviews-sidebar-header {
    padding: 12px 14px;
    font-weight: 600;
    font-size: 13px;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e8e8e8;
    background: #f0f2f5;
}

.jdviews-sidebar-header .jdviews-sidebar-close {
    color: #999;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
}

.jdviews-sidebar-header .jdviews-sidebar-close:hover {
    color: #333;
    background: #ddd;
}

/* Sidebar actions (save view / add category) */
.jdviews-sidebar-actions {
    padding: 8px 10px;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    gap: 6px;
}

.jdviews-sidebar-actions .btn {
    font-size: 11px;
}

/* Category item */
.jdviews-sidebar-cat {
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    border-left: 3px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
    user-select: none;
}

.jdviews-sidebar-cat:hover {
    background: #eef1f5;
}

.jdviews-sidebar-cat.jdside-cat-active {
    background: #e8ecf1;
}

.jdviews-sidebar-cat .jdside-cat-chevron {
    transition: transform 0.2s;
    font-size: 11px;
    color: #999;
}

.jdviews-sidebar-cat.jdside-cat-expanded .jdside-cat-chevron {
    transform: rotate(90deg);
}

.jdviews-sidebar-cat .jdside-cat-icons {
    display: none;
    margin-left: 6px;
}

.jdviews-sidebar-cat:hover .jdside-cat-icons {
    display: inline-flex;
    gap: 4px;
}

.jdviews-sidebar-cat .jdside-cat-icons i {
    font-size: 12px;
    cursor: pointer;
}

/* Views list under a category */
.jdviews-sidebar-views {
    display: none;
    background: #f5f7f9;
}

.jdviews-sidebar-views.jdside-views-expanded {
    display: block;
}

.jdviews-sidebar-view {
    padding: 7px 14px 7px 28px;
    cursor: pointer;
    font-size: 12px;
    color: #555;
    border-left: 3px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
}

.jdviews-sidebar-view:hover {
    background: #e4eaf1;
}

.jdviews-sidebar-view.jdside-view-active {
    font-weight: 600;
    color: #fff;
}

.jdviews-sidebar-view .jdside-view-icons {
    display: none;
    margin-left: 6px;
}

.jdviews-sidebar-view:hover .jdside-view-icons {
    display: inline-flex;
    gap: 4px;
}

.jdviews-sidebar-view .jdside-view-icons i {
    font-size: 11px;
    cursor: pointer;
}

/* No views message */
.jdviews-sidebar-noviews {
    padding: 6px 14px 6px 28px;
    font-size: 11px;
    color: #aaa;
    font-style: italic;
}

/* Current view indicator (above grid in side mode) */
.jdviews-current-bar {
    padding: 8px 14px;
    background: #f5f5f5;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    gap: 8px;
}

.jdviews-current-toggle {
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: #333;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 4px;
    transition: background 0.15s;
}

.jdviews-current-toggle:hover {
    background: #e8ecf1;
    text-decoration: none;
    color: #333;
}

.jdviews-current-toggle .fa-bars {
    font-size: 13px;
    color: #888;
}

.jdviews-current-sep {
    margin: 0 2px;
    color: #bbb;
    font-weight: 300;
}

.jdviews-current-cat {
    font-weight: 600;
}

.jdviews-current-view {
    font-weight: 400;
    font-style: italic;
}

.jdviews-current-bar .jdgtoprightbtns {
    margin-left: auto;
}
/* ========================================
   MODAL "NOUVELLE VUE" (.nv-*)
   ======================================== */

/* Shell modal */
.nv-mc {
    border: none;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}

/* Header gradient */
.nv-hd {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #1e3a6e 0%, #2e6db4 100%);
    color: #fff;
    padding: 14px 18px;
    font-size: 15px;
    font-weight: 600;
}

.nv-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.65);
    cursor: pointer;
    font-size: 18px;
}

.nv-close:hover {
    color: #fff;
}

/* Body 2-colonnes */
.nv-bd {
    display: flex;
    min-height: 440px;
    max-height: 74vh;
}

.nv-left {
    width: 296px;
    flex-shrink: 0;
    border-right: 1px solid #dce3ec;
    background: #f5f7fb;
    overflow-y: auto;
}

.nv-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
}

/* Blocs de section */
.nv-blk {
    padding: 14px 16px;
    border-bottom: 1px solid #dce3ec;
}

.nv-blk:last-child {
    border-bottom: none;
}

.nv-blk-fill {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.nv-blk-ttl {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #2e6db4;
    margin-bottom: 10px;
}

/* Radio buttons affichage (fitcontent) */
.nv-display-modes {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.nv-display-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 10px;
    border: 2px solid #dce3ec;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #555;
}

.nv-display-item input[type="radio"] {
    display: none;
}

.nv-display-item:hover {
    border-color: #b0c4de;
    background: #f5f8fc;
}

.nv-display-item.nv-display-active {
    border-color: #2e6db4;
    background: #eaf2fb;
    color: #2e6db4;
}

/* Pills de filtres */
.nv-filterdesc {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.nv-filterdesc-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #eaf2fb;
    border: 1px solid #b8d4ef;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 11px;
    color: #2d5986;
}

.nv-filterdesc-sep {
    font-size: 10px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
}

/* Partage 2-colonnes */
.nv-share-2col {
    display: flex;
    gap: 14px;
}

.nv-share-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nv-share-list {
    max-height: 120px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    border: 1px solid #e0e7f0;
    border-radius: 4px;
    padding: 4px 6px;
    background: #fafbfd;
}

/* Panneau colonnes: 2 sous-panneaux */
.nv-cols-2panel {
    display: flex;
    flex: 1;
    min-height: 0;
    border-top: 1px solid #dce3ec;
}

.nv-cols-left-panel {
    flex: 1;
    border-right: 1px solid #dce3ec;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.nv-cols-right-panel {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.nv-cols-left-panel .nv-cols-scroll,
.nv-cols-right-panel .nv-cols-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

/* Groupes de champs */
.nv-field-group-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #aaa;
    padding: 4px 4px 2px;
    border-bottom: 1px solid #edf1f7;
}

/* Items checkbox */
.nv-col-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 12px;
    gap: 6px;
}

.nv-col-item:hover {
    background: #e6f0fb;
}

/* Items sortable (panneau droit) */
.nv-sort-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    margin-bottom: 3px;
    background: #fff;
    border: 1px solid #dce3ec;
    border-radius: 4px;
    list-style: none;
}

.nv-sort-item:hover {
    background: #f0f6ff;
    border-color: #b0cdf0;
}

.nv-sort-handle {
    cursor: move;
    color: #c0c8d8;
}

.nv-sort-label {
    flex: 1;
    font-size: 12px;
}

.nv-sort-remove {
    color: #c0c8d8;
    font-size: 12px;
}

.nv-sort-remove:hover {
    color: #e74c3c;
}

.nv-sort-placeholder {
    height: 30px;
    background: #e6f2ff;
    border: 2px dashed #90bde4;
    border-radius: 4px;
}

.nv-cols-selected {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Toolbar colonnes (Tout/Aucun/Recherche) */
.nv-cols-toolbar {
    padding: 8px;
    border-bottom: 1px solid #dce3ec;
    display: flex;
    gap: 6px;
    align-items: center;
}

.nv-cols-toolbar .btn {
    font-size: 10px;
    padding: 2px 8px;
}

.nv-col-search {
    flex: 1;
    font-size: 12px;
    padding: 3px 8px;
    border: 1px solid #dce3ec;
    border-radius: 4px;
    outline: none;
}

.nv-cols-right-header {
    padding: 8px;
    border-bottom: 1px solid #dce3ec;
    font-size: 11px;
    font-weight: 600;
    color: #666;
}

/* Footer */
.nv-ft {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid #dce3ec;
    background: #f5f7fb;
}


/* ========================================
   DATERANGEPICKER - RESPONSIVE MOBILE (ticket 29722)
   ======================================== */

@media (max-width: 768px) {
    .daterangepicker {
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: calc(100vw - 20px);
    }
    .daterangepicker .calendar { float: none !important; width: 100% !important; max-width: 100% !important; }
    .daterangepicker .ranges { float: none !important; width: 100% !important; }
}

