/* ==========================================================
   GalaxyBreleco : surcouche responsive
   A charger APRES breleco.css (voir resources/views/layouts/app.blade.php).
   Toutes les regles sont dans des @media ou ciblent les mobiles :
   le rendu desktop reste identique.
   ========================================================== */

/* ---------- Base (tous écrans) ---------- */
img, svg, video { max-width: 100%; height: auto; }

/* Hauteur réelle de l'écran sur mobile (la barre d'adresse fausse 100vh) */
.app-shell { min-height: 100vh; min-height: 100dvh; }
.sidebar { height: 100vh; height: 100dvh; }

/* Le titre et le fil d'Ariane ne doivent jamais déborder de la barre haute */
.topbar-heading { min-width: 0; }
.breadcrumb { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---------- Tablette et petit écran (<= 860 px) ---------- */
@media (max-width: 860px) {
    /* Menu tiroir : fermé, il n'est ni visible ni atteignable au clavier */
    .sidebar { visibility: hidden; transition: transform .25s ease, visibility .25s ease; }
    .sidebar.is-open { visibility: visible; }

    /* Menu ouvert : la page derrière ne défile pas */
    body.menu-open { overflow: hidden; }

    /* Cartes statistiques : 2 colonnes, la 3e prend toute la largeur */
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-grid > .stat-card:last-child { grid-column: 1 / -1; }

    /* Barre de recherche pleine largeur, boutons compacts à côté */
    .filter-form { grid-template-columns: minmax(0, 1fr) auto auto; }
}

/* ---------- Mobile (<= 620 px) ---------- */
@media (max-width: 620px) {
    .content-wrap { padding: 20px 14px 40px; }
    .topbar-inner { padding: 0 14px; gap: 12px; }
    .topbar-heading h1 { font-size: 17px; }
    .topbar-heading p { font-size: 11px; }
    .sidebar-topline { min-height: 76px; padding: 0 18px; }

    /* Cartes et panneaux : moins de marges, texte plus lisible */
    .stat-grid { grid-template-columns: 1fr; gap: 12px; }
    .stat-card { min-height: 0; padding: 16px; }
    .stat-value { font-size: 26px; }
    .stat-label { font-size: 12px; }
    .panel-card, .form-card { padding: 16px; }
    .panel-title { font-size: 15px; }
    .panel-description, .form-card-header p, .form-help { font-size: 12px; }
    .form-label { font-size: 12px; }

    /* Tableaux : défilement horizontal fluide au doigt, cellules un peu plus serrées */
    .table-scroll { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 11px 12px; }

    /* Champs de formulaire : 16px évite le zoom automatique d'iOS au focus */
    .form-input, .form-select { min-height: 46px; font-size: 16px; }

    /* Cibles tactiles plus grandes (environ 44 px minimum) */
    .btn-primary, .btn-secondary, .btn-ghost { min-height: 44px; }
    .form-actions .btn-primary, .form-actions .btn-secondary { min-height: 46px; }
    .btn-danger { min-height: 40px; padding: 0 12px; }
    .icon-button { width: 44px; height: 44px; }
    .nav-link { min-height: 48px; font-size: 14px; }

    /* Bloc d'accueil */
    .dashboard-hero { padding: 24px 20px; }
    .dashboard-hero p { font-size: 13px; }
    .hero-actions .btn-primary { width: 100%; }

    /* Accès rapides */
    .quick-link { padding: 12px 8px; }
    .quick-link strong { font-size: 13px; }
    .quick-link small { font-size: 11px; }

    /* Filtres : recherche sur toute la largeur, boutons côte à côte */
    .filter-form { grid-template-columns: 1fr 1fr; }

    /* Pagination : retour à la ligne si beaucoup de pages, cibles plus grandes */
    nav.pagination { flex-wrap: wrap; justify-content: center; }
    .pagination-link, .pagination-nav { min-width: 40px; height: 40px; }

    /* Messages et fenêtres de confirmation */
    .flash { font-size: 13px; }
    .confirm-card { padding: 20px 18px; }
    .confirm-actions { flex-direction: column-reverse; align-items: stretch; }
    .confirm-actions .btn-secondary, .confirm-actions .btn-danger { width: 100%; }
    .loading-card { min-width: 0; width: calc(100% - 40px); }
}

/* ---------- Très petits écrans (<= 420 px) ---------- */
@media (max-width: 420px) {
    .topbar-heading h1 { font-size: 16px; }
    .page-intro h2 { font-size: 21px; }
    .dashboard-hero h2 { font-size: 22px; }
    .stat-card { gap: 10px; }
    .stat-icon { width: 38px; height: 38px; }
    .panel-heading { flex-direction: column; align-items: flex-start; }
}
