/* MarioBertulli App - Custom styles */

/* Champs date affichés en jj/mm/aaaa (la valeur soumise reste AAAA-MM-JJ) */
.eu-date-wrap {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    max-width: 100%;
}
.eu-date-wrap.is-full {
    display: block;
    width: 100%;
}
.eu-date-wrap input.eu-date-text {
    box-sizing: border-box;
    width: 11rem;
    max-width: 100%;
    padding-right: 2.25rem;
}
.eu-date-wrap.is-full input.eu-date-text {
    width: 100%;
}
.eu-date-wrap input.eu-date-native {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 0;
    width: 2.25rem;
    min-width: 0;
    max-width: 2.25rem;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}
.eu-date-wrap .eu-date-btn {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
}
.eu-date-wrap .eu-date-btn:hover {
    color: #111827;
}
.eu-date-wrap .eu-date-btn:disabled {
    cursor: default;
    color: #d1d5db;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* KPI Cards */
.kpi-card {
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}
.kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

/* Table sorting indicator */
th[data-sortable] {
    cursor: pointer;
    user-select: none;
}
th[data-sortable]:hover {
    background-color: #f3f4f6;
}
th[data-sort="asc"]::after {
    content: ' \25B2';
    font-size: 0.65em;
}
th[data-sort="desc"]::after {
    content: ' \25BC';
    font-size: 0.65em;
}

/* Date picker styling */
input[type="date"] {
    color-scheme: light;
}

/* ---- Tooltip (infobulle au survol du texte) ---- */
/* Parent element: help cursor + position anchor */
:has(> .tip-icon) {
    position: relative;
    cursor: help;
}
/* Sortable th keeps pointer cursor */
th[data-sortable]:has(> .tip-icon) {
    cursor: pointer;
}

/* The trigger span is invisible — takes no space */
.tip-icon {
    font-size: 0;
    line-height: 0;
    pointer-events: none;
    display: inline;
}

/* Tooltip bubble — positioned relative to parent */
.tip-icon::after {
    content: '\24D8\00a0\00a0' attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 400;
    font-family: 'Rubik', sans-serif;
    line-height: 1.5;
    white-space: normal;
    width: max-content;
    max-width: 300px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 50;
    text-transform: none;
    letter-spacing: normal;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Arrow */
.tip-icon::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #111827;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 51;
}

/* Show tooltip on parent hover */
:has(> .tip-icon):hover > .tip-icon::after,
:has(> .tip-icon):hover > .tip-icon::before {
    opacity: 1;
}

/* Edge alignment for first / last table columns */
th:first-child:has(> .tip-icon) > .tip-icon::after,
td:first-child:has(> .tip-icon) > .tip-icon::after {
    left: 0;
    transform: none;
}
th:first-child:has(> .tip-icon) > .tip-icon::before,
td:first-child:has(> .tip-icon) > .tip-icon::before {
    left: 12px;
    transform: none;
}
th:last-child:has(> .tip-icon) > .tip-icon::after,
td:last-child:has(> .tip-icon) > .tip-icon::after {
    left: auto;
    right: 0;
    transform: none;
}
th:last-child:has(> .tip-icon) > .tip-icon::before,
td:last-child:has(> .tip-icon) > .tip-icon::before {
    left: auto;
    right: 12px;
    transform: none;
}

/* ---- Sidebar principale réduite (mini-colonne) ---- */
@media (min-width: 1024px) {
  html.sidebar-collapsed #sidebar {
    width: 4.5rem;
  }
  html.sidebar-collapsed .main-content-wrap {
    margin-left: 4.5rem !important;
  }
  html.sidebar-collapsed .sidebar-brand {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    justify-content: center;
    flex-direction: column;
    height: auto;
    min-height: 4rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    gap: 0.35rem;
  }
  html.sidebar-collapsed .sidebar-brand-full { display: none; }
  html.sidebar-collapsed .sidebar-brand-mini { display: inline !important; font-size: 0.85rem; }
  html.sidebar-collapsed .sidebar-brand-link { text-align: center; }
  html.sidebar-collapsed #sidebar-collapse .sidebar-collapse-ico { display: none; }
  html.sidebar-collapsed #sidebar-collapse .sidebar-expand-ico { display: block !important; }

  html.sidebar-collapsed .sidebar-user {
    padding: 0.75rem 0.35rem;
    display: flex;
    justify-content: center;
  }
  html.sidebar-collapsed .sidebar-user .flex { justify-content: center; gap: 0; }
  html.sidebar-collapsed .sidebar-user-text { display: none; }
  html.sidebar-collapsed .sidebar-user img,
  html.sidebar-collapsed .sidebar-user .rounded-full {
    width: 2.25rem;
    height: 2.25rem;
  }

  html.sidebar-collapsed #sidebar nav {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }
  html.sidebar-collapsed #sidebar nav > p {
    display: none;
  }
  /* En-têtes de section : masqués, sous-menus forcés ouverts */
  html.sidebar-collapsed #sidebar nav > button {
    display: none !important;
  }
  html.sidebar-collapsed #sidebar nav > div[id$="-menu"] {
    display: block !important;
  }

  html.sidebar-collapsed #sidebar nav a {
    justify-content: center;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    font-size: 0;
    line-height: 0;
    position: relative;
  }
  html.sidebar-collapsed #sidebar nav a svg {
    margin-right: 0 !important;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
  }
  html.sidebar-collapsed #sidebar nav a img {
    margin-right: 0 !important;
  }
  html.sidebar-collapsed #sidebar nav a > span:not([id$="-badge"]):not(.sidebar-keep) {
    display: none;
  }
  html.sidebar-collapsed #mario-unread-badge:not(.hidden) {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 9px;
    line-height: 1.1rem;
    min-width: 1.1rem;
    height: 1.1rem;
    margin: 0 !important;
  }

  html.sidebar-collapsed #commerce-site-switch-wrap {
    margin-bottom: 0.75rem;
  }
  html.sidebar-collapsed #commerce-site-switch-btn {
    justify-content: center;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }
  html.sidebar-collapsed #commerce-site-switch-btn > span,
  html.sidebar-collapsed #commerce-site-switch-btn > svg:last-child {
    display: none;
  }
  html.sidebar-collapsed #commerce-site-switch-btn img {
    margin-right: 0 !important;
  }
  html.sidebar-collapsed #commerce-site-switch-menu {
    left: 100%;
    right: auto;
    top: 0;
    margin-top: 0;
    margin-left: 0.35rem;
    min-width: 12rem;
  }

  html.sidebar-collapsed #sidebar > .border-t {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }
  html.sidebar-collapsed #sidebar > .border-t a {
    justify-content: center;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    font-size: 0;
    line-height: 0;
  }
  html.sidebar-collapsed #sidebar > .border-t a svg {
    margin-right: 0 !important;
  }
}

/* Animation largeur menu : uniquement sur clic (pas au chargement) */
@media (min-width: 1024px) {
  #sidebar.sidebar-width-anim {
    transition: width 0.2s ease, transform 0.2s ease;
  }
  .main-content-wrap.sidebar-width-anim {
    transition: margin-left 0.2s ease;
  }
}
