/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  body::before {
    animation: none;
  }

}

/* ========== TOUCH ENHANCEMENTS (all touch devices) ========== */
@media (hover: none) and (pointer: coarse) {
  /* Disable hover effects on touch — use active instead */
  .nav-item:hover {
    transform: none;
    background: transparent;
  }

  .nav-item:active {
    background: var(--hover-bg);
  }

  /* Remove tap highlight */
  * {
    -webkit-tap-highlight-color: transparent;
  }

  /* Faster tap response on buttons/links */
  a, button, .btn, .nav-item, .kpi-card, .card {
    touch-action: manipulation;
  }

  /* Bigger touch targets (min 44px recommended by Apple/Google) */
  .btn, button {
    min-height: 44px;
  }

  .nav-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Prevent text selection on interactive elements */
  .btn, button, .nav-item, .kpi-card {
    -webkit-user-select: none;
    user-select: none;
  }
}

/* ========== TABLET ========== */
@media (max-width: 1199px) {
  .sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .sidebar .nav-item span,
  .sidebar .nav-section-title,
  .sidebar .logo-text,
  .sidebar .logo-subtitle,
  .sidebar .sidebar-footer .version {
    display: none;
  }

  .sidebar-logo {
    justify-content: center;
    padding: var(--space-md);
  }

  .nav-item {
    justify-content: center;
    padding: var(--space-sm);
    margin: 2px var(--space-xs);
  }

  .nav-item i,
  .nav-item iconify-icon,
  .nav-item .nav-icon {
    font-size: var(--font-size-lg);
  }

  .nav-item:hover {
    transform: none;
  }

  .main-content {
    margin-left: var(--sidebar-collapsed-width);
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .header-search input {
    width: 180px;
  }

  .header-search input:focus {
    width: 220px;
  }
}

/* ========== MOBILE ========== */
@media (max-width: 768px) {
  /* === SAFE AREAS (iOS notch/gesture bar) === */
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  /* === SIDEBAR — hidden off-screen by default on mobile === */
  .sidebar {
    width: 280px !important;
    transform: translateX(-100%) !important;
    z-index: 200;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.3s;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    pointer-events: none;
    visibility: hidden;
  }

  .sidebar.open {
    transform: translateX(0) !important;
    pointer-events: auto;
    visibility: visible;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0s;
  }

  .sidebar .nav-item span,
  .sidebar .nav-section-title,
  .sidebar .logo-text,
  .sidebar .logo-subtitle,
  .sidebar .sidebar-footer .version {
    display: block;
  }

  .sidebar-logo {
    justify-content: flex-start;
    padding: var(--space-lg);
    padding-top: calc(var(--space-lg) + env(safe-area-inset-top));
  }

  .nav-item {
    justify-content: flex-start;
    padding: 12px var(--space-lg);
    margin: 2px var(--space-sm);
    min-height: 44px;
    font-size: var(--font-size-base);
  }

  /* Sidebar overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .sidebar-overlay.active {
    display: block;
    opacity: 1;
  }

  /* === MAIN CONTENT — full width, no sidebar margin === */
  .main-content {
    margin-left: 0 !important;
    min-height: 100dvh;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  /* === HEADER === */
  .header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 var(--space-md) !important;
    padding-top: env(safe-area-inset-top) !important;
    height: auto !important;
    min-height: 56px;
    overflow: visible;
  }

  .header-left {
    min-width: 0;
    flex-shrink: 1;
    overflow: hidden;
  }

  .header-breadcrumb {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--font-size-xs);
  }

  .header-right {
    flex-shrink: 0;
    gap: var(--space-xs) !important;
  }

  .header-toggle {
    display: flex !important;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    border-radius: var(--radius-sm);
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
    position: relative;
    z-index: 101;
  }

  .header-toggle:active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
  }

  .header-search {
    display: none;
  }

  .header-user-name {
    display: none;
  }

  .header-user {
    min-width: 44px;
    min-height: 44px;
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
  }

  .header-user-chevron {
    display: none;
  }

  /* Header actions spacing */
  .header-actions {
    gap: 4px;
  }

  .header-actions > * {
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* === PAGE CONTENT === */
  #page-content {
    padding: var(--space-md);
    padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom));
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .page-header h1 {
    font-size: var(--font-size-lg);
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }

  .page-actions .btn {
    font-size: var(--font-size-xs);
    padding: 8px 12px;
    white-space: nowrap;
  }

  /* Hide button text on mobile, keep icons */
  .hide-mobile-text {
    display: none;
  }

  /* Planning nav card */
  .planning-nav-card > div {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .planning-nav-card > div > div:first-child {
    justify-content: center;
  }
  .planning-nav-card > div > div:last-child {
    flex-direction: column !important;
  }
  .planning-nav-card input[type="text"] {
    width: 100% !important;
  }

  /* === GRIDS === */
  .grid-4, .grid-3 {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  /* === KPI CARDS === */
  .kpi-card {
    padding: var(--space-md);
  }

  .kpi-value {
    font-size: var(--font-size-xl);
  }

  .kpi-label {
    font-size: var(--font-size-xs);
  }

  /* === MODALS — Plein ecran sur mobile === */
  .modal {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
    background: var(--bg-primary);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .modal-lg {
    width: 100%;
    max-width: 100%;
  }

  .modal-body {
    max-height: calc(100dvh - 130px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-md);
  }

  .modal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: var(--space-md);
    padding-top: calc(var(--space-md) + env(safe-area-inset-top));
    background: var(--bg-primary);
  }

  .modal-footer {
    position: sticky;
    bottom: 0;
    padding: var(--space-md);
    padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
    flex-wrap: wrap;
    gap: 8px;
    background: var(--bg-primary);
  }

  .modal-footer .btn {
    font-size: var(--font-size-xs);
    padding: 8px 12px;
    white-space: nowrap;
  }

  /* === TABLES === */
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }

  .table-toolbar .btn {
    width: 100%;
    justify-content: center;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: var(--font-size-xs);
    min-width: 600px;
  }

  .data-table th,
  .data-table td {
    padding: 8px 10px;
    white-space: nowrap;
  }

  /* === TOASTS === */
  .toast {
    min-width: auto;
    max-width: calc(100vw - 32px);
  }

  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
    bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
  }

  /* === DETAIL PAGES === */
  .detail-header {
    flex-direction: column;
    text-align: center;
    gap: var(--space-md);
  }

  .detail-stats {
    justify-content: center;
    flex-wrap: wrap;
  }

  .detail-actions {
    flex-wrap: wrap;
    justify-content: center;
  }

  .detail-actions .btn {
    flex: 1;
    min-width: 120px;
  }

  /* === BUTTONS === */
  .btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: var(--font-size-sm);
  }

  .btn-sm {
    min-height: 36px;
    padding: 6px 12px;
  }

  /* === FORMS === */
  .form-control, select, input[type="text"], input[type="email"],
  input[type="password"], input[type="tel"], input[type="date"],
  input[type="number"], textarea {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: 10px 12px;
  }

  /* === CARDS === */
  .card {
    border-radius: var(--radius-md);
  }

  .card-header {
    padding: var(--space-md);
  }

  .card-body {
    padding: var(--space-md);
  }

  /* === LOGIN — Plein ecran mobile === */
  .login-overlay {
    align-items: flex-start;
    padding-top: var(--space-md);
    padding-bottom: var(--space-xl);
  }

  .login-container {
    width: 100%;
    max-width: 100%;
    padding: var(--space-md);
  }

  .login-card {
    border-radius: var(--radius-lg);
    padding: var(--space-lg) var(--space-md);
    width: 100%;
    max-width: 100%;
    margin-bottom: var(--space-xl);
  }

  .login-card h2 {
    font-size: var(--font-size-xl);
  }

  .login-card .btn {
    width: 100%;
    min-height: 48px;
    font-size: var(--font-size-base);
  }

  .login-card input {
    min-height: 48px;
    font-size: 16px;
  }

  /* === NOTIFICATIONS DROPDOWN === */
  .notif-dropdown {
    position: fixed;
    top: 64px;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    max-height: 60vh;
    z-index: 9999;
    background: var(--bg-secondary);
  }

  /* === USER DROPDOWN === */
  .header-user-dropdown {
    position: fixed;
    top: 64px;
    right: var(--space-sm);
    left: var(--space-sm);
    width: auto;
    min-width: 200px;
    z-index: 9999;
  }

  /* === ACCESS RESTRICTED === */
  .access-restricted {
    padding: var(--space-xl) var(--space-md);
  }

  .access-restricted i,
  .access-restricted iconify-icon {
    font-size: 48px;
  }

  /* Remove glassmorphism on mobile for performance */
  .sidebar,
  .header,
  .card,
  .kpi-card,
  .chart-card,
  .table-container,
  .modal,
  .toast,
  .notif-dropdown {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ========== MOBILE GLOBAL OVERRIDES ========== */
@media (max-width: 768px) {
  /* Force all inline-styled inputs/selects to respect viewport */
  .page-actions input[type="date"],
  .page-actions input[type="text"],
  .page-actions input[type="number"],
  .page-actions select,
  .table-toolbar input[type="date"],
  .table-toolbar input[type="text"],
  .table-toolbar input[type="number"],
  .table-toolbar select,
  .card-header input[type="date"],
  .card-header select {
    max-width: 100% !important;
    min-width: 0 !important;
    width: auto !important;
    flex: 1 1 auto;
  }

  /* Inline tables with min-width: wrap in scrollable container */
  table[style*="min-width"] {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Charts height reduce for mobile */
  .chart-card canvas {
    max-height: 220px !important;
  }

  /* Inline grids with fixed columns → stack */
  div[style*="grid-template-columns: 160px"],
  div[style*="grid-template-columns:160px"] {
    grid-template-columns: 1fr !important;
  }

  /* Flex containers in page-actions wrap */
  .page-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Filter selects/inputs full width */
  .page-actions > select,
  .page-actions > input,
  .page-actions > div {
    flex: 1 1 calc(50% - 4px);
    min-width: 0 !important;
  }

  /* Card headers with actions */
  .card-header {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* ========== SMALL MOBILE ========== */
@media (max-width: 480px) {
  #page-content {
    padding: var(--space-sm);
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom));
  }

  .page-header h1 {
    font-size: var(--font-size-base);
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
    font-size: var(--font-size-xs);
    padding: 8px 10px;
  }

  /* Page actions: grille 2 colonnes sur petit mobile */
  .page-actions {
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px;
  }
  .page-actions .btn {
    flex: 1 1 calc(50% - 3px);
    min-width: 0;
    justify-content: center;
    text-align: center;
  }

  /* Planning: barre navigation compacte */
  .planning-nav-card {
    padding: var(--space-sm) !important;
  }
  .planning-nav-card > div {
    flex-direction: column !important;
    gap: var(--space-sm) !important;
  }
  .planning-nav-card .tabs {
    width: 100%;
    justify-content: center;
  }
  .planning-nav-card .tab {
    flex: 1;
    justify-content: center;
    font-size: 12px !important;
    padding: 8px 6px !important;
  }
  .planning-nav-card input[type="text"] {
    width: 100% !important;
  }
  #planning-period-label {
    font-size: var(--font-size-sm) !important;
    min-width: 0 !important;
  }

  /* KPI cards en 2 colonnes serrees */
  .grid-4, .grid-3 {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .kpi-card {
    padding: var(--space-sm);
  }

  .kpi-value {
    font-size: var(--font-size-lg);
  }

  .kpi-label {
    font-size: 10px;
  }

  .kpi-card i,
  .kpi-card iconify-icon {
    font-size: var(--font-size-base);
  }

  /* Cards compactes */
  .card-header {
    padding: var(--space-sm) var(--space-md);
  }

  .card-body {
    padding: var(--space-sm) var(--space-md);
  }

  /* Table plus compacte */
  .data-table th,
  .data-table td {
    padding: 6px 8px;
    font-size: 11px;
  }

  .table-pagination {
    flex-direction: column;
    gap: var(--space-sm);
    text-align: center;
  }

  /* Charts container */
  .chart-card {
    padding: var(--space-sm);
  }

  .theme-toggle {
    width: 36px;
    height: 36px;
  }

  /* Modal plein ecran compact */
  .modal-header {
    padding: var(--space-sm) var(--space-md);
  }

  .modal-body {
    padding: var(--space-sm) var(--space-md);
  }

  .modal-footer {
    padding: var(--space-sm) var(--space-md);
  }

  /* Header compact */
  .header {
    height: 56px;
    min-height: 56px;
  }

  .header .breadcrumb {
    font-size: var(--font-size-xs);
  }

  /* Detail page compact */
  .detail-actions .btn {
    min-width: 100px;
    font-size: var(--font-size-xs);
  }
}

/* ========== LANDSCAPE MOBILE ========== */
@media (max-width: 768px) and (orientation: landscape) {
  .modal {
    flex-direction: row;
  }

  .modal-body {
    max-height: calc(100dvh - 60px);
  }

  .login-card {
    max-width: 500px;
    margin: 0 auto;
  }

  .grid-4, .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========== STANDALONE MODE (installed PWA) ========== */
@media (display-mode: standalone) {
  /* Extra top padding in standalone since no browser chrome */
  .header {
    padding-top: env(safe-area-inset-top);
  }

  .login-overlay {
    padding-top: env(safe-area-inset-top);
  }

  /* Bottom safe area for gesture bar */
  .modal-footer {
    padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
  }
}

/* ========== NATIVE APP / FORCED MOBILE (JS-driven) ========== */
/* These classes are set by JS on body — work even if media queries don't trigger */
body.pilote-mobile .sidebar,
body.pilote-native-app .sidebar {
  width: 280px !important;
  transform: translateX(-100%) !important;
  z-index: 200;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  pointer-events: none;
  visibility: hidden;
}

body.pilote-mobile .sidebar.open,
body.pilote-native-app .sidebar.open {
  transform: translateX(0) !important;
  pointer-events: auto;
  visibility: visible;
}

body.pilote-mobile .main-content,
body.pilote-native-app .main-content {
  margin-left: 0 !important;
  width: 100% !important;
}

body.pilote-mobile .header-toggle,
body.pilote-native-app .header-toggle {
  display: flex !important;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  position: relative;
  z-index: 101;
}

body.pilote-mobile .header-search,
body.pilote-native-app .header-search {
  flex: 1;
  min-width: 0;
}

body.pilote-mobile .header-search input,
body.pilote-native-app .header-search input {
  width: 100%;
  font-size: var(--font-size-xs);
}

body.pilote-mobile .header-user-name,
body.pilote-native-app .header-user-name {
  display: none;
}

body.pilote-mobile .header-user-chevron,
body.pilote-native-app .header-user-chevron {
  display: none;
}

body.pilote-mobile .header,
body.pilote-native-app .header {
  overflow: visible;
  z-index: 100;
}

body.pilote-mobile .sidebar-overlay,
body.pilote-native-app .sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
}

body.pilote-mobile .sidebar-overlay.active,
body.pilote-native-app .sidebar-overlay.active {
  display: block;
}

/* ========== BOTTOM NAVIGATION BAR (mobile only) ========== */

/* Hidden by default on desktop */
.bottom-nav {
  display: none;
}

/* Back button hidden by default (shown only on mobile with bottom nav) */
.breadcrumb-back {
  display: none;
}

@media (max-width: 768px) {
  .bottom-nav.bottom-nav-visible {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 150;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.12);
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(60px + env(safe-area-inset-bottom));
    align-items: flex-start;
    justify-content: space-around;
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 8px 0 4px;
    height: 60px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
  }

  .bottom-nav-item i,
  .bottom-nav-item iconify-icon,
  .bottom-nav-item .nav-icon {
    font-size: 22px;
    margin-bottom: 3px;
    transition: transform 0.15s ease, color 0.15s ease;
  }

  .bottom-nav-item span {
    font-size: 10px;
    line-height: 1.2;
    letter-spacing: 0.01em;
  }

  .bottom-nav-item.active {
    color: var(--pilote-blue);
  }

  .bottom-nav-item.active i,
  .bottom-nav-item.active iconify-icon,
  .bottom-nav-item.active .nav-icon {
    transform: scale(1.15);
  }

  /* Active indicator dot */
  .bottom-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--pilote-blue);
    border-radius: 50%;
  }

  /* Tap feedback */
  .bottom-nav-item:active,
  .bottom-nav-item.bottom-nav-tap {
    opacity: 0.7;
  }

  .bottom-nav-item:active i,
  .bottom-nav-item:active iconify-icon,
  .bottom-nav-item:active .nav-icon {
    transform: scale(0.9);
  }

  /* Adjust page content bottom padding for bottom nav */
  body.pilote-has-bottomnav #page-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }

  /* Adjust toast container above bottom nav */
  body.pilote-has-bottomnav .toast-container {
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }

  /* Hide sidebar toggle when bottom nav is active */
  body.pilote-has-bottomnav .header-toggle {
    display: none !important;
  }

  /* Breadcrumb can use full width */
  body.pilote-has-bottomnav .header-breadcrumb {
    padding-left: var(--space-sm);
  }

  /* Back button in breadcrumb for menu sub-pages */
  body.pilote-has-bottomnav .breadcrumb-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    margin-right: var(--space-xs);
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, color 0.15s ease;
  }

  body.pilote-has-bottomnav .breadcrumb-back:active {
    background: var(--bg-tertiary);
    color: var(--pilote-blue);
  }

  body.pilote-has-bottomnav .breadcrumb-back i,
  body.pilote-has-bottomnav .breadcrumb-back iconify-icon {
    font-size: 16px;
  }
}

/* Native app always shows bottom nav */
body.pilote-native-app .bottom-nav.bottom-nav-visible {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.12);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(60px + env(safe-area-inset-bottom));
  align-items: flex-start;
  justify-content: space-around;
}

body.pilote-native-app.pilote-has-bottomnav #page-content {
  padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important;
}

body.pilote-native-app.pilote-has-bottomnav .toast-container {
  bottom: calc(72px + env(safe-area-inset-bottom)) !important;
}

body.pilote-native-app.pilote-has-bottomnav .header-toggle {
  display: none !important;
}

/* ========== MENU PAGE ========== */

.menu-page {
  padding: 0;
}

.menu-page-header {
  margin-bottom: var(--space-lg);
}

.menu-page-header h1 {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
}

.menu-page-header h1 i,
.menu-page-header h1 iconify-icon {
  color: var(--pilote-blue);
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.menu-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.menu-grid-item:active {
  transform: scale(0.95);
  opacity: 0.8;
}

.menu-grid-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.menu-grid-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.3;
}

@media (max-width: 480px) {
  .menu-grid {
    gap: var(--space-sm);
  }

  .menu-grid-item {
    padding: var(--space-md) var(--space-xs);
  }

  .menu-grid-icon {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }

  .menu-grid-label {
    font-size: 10px;
  }
}

/* ========== PRINT ========== */
@media print {
  .sidebar,
  .header,
  .sidebar-overlay,
  .toast-container,
  #modal-overlay {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  #page-content {
    padding: 0;
  }

  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* ========== ADMIN TABLE RESPONSIVE ========== */
@media (max-width: 900px) {
  /* Allow horizontal scroll on page content for tables */
  #page-content {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Wrap table in scrollable container */
  .table-container,
  [id*="-table"],
  [id*="_table"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* KPI grids: 2 columns on tablet, 1 on small mobile */
  .cc-kpi-grid,
  [style*="grid-template-columns: 1fr 1fr 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Controle conduite tabs: scroll horizontally */
  .cc-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  .cc-tabs .cc-tab {
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Filter bar: wrap */
  .cc-filters,
  [style*="display:flex"][style*="gap"] > select,
  [style*="display:flex"][style*="gap"] > input[type="date"] {
    min-width: 120px;
  }

  /* Zone cards: single column */
  .cc-zone-cards {
    grid-template-columns: 1fr !important;
  }

  /* Page header responsive */
  .page-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start !important;
  }

  .page-header h1 {
    font-size: 1.3rem !important;
  }
}

@media (max-width: 480px) {
  /* KPI: single column on very small screens */
  .cc-kpi-grid,
  [style*="grid-template-columns: 1fr 1fr 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Classement config panel: stack */
  #classement-config-panel [style*="grid-template-columns:1fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Table actions: smaller icons */
  .btn-icon {
    padding: 4px !important;
    font-size: 14px !important;
  }

  /* Controle conduite: compact filter row */
  .cc-filter-row {
    flex-wrap: wrap;
  }

  .cc-filter-row select,
  .cc-filter-row input {
    flex: 1 1 45%;
    min-width: 0;
  }
}
