/* ============================================================
   responsive.css v2 - CorePro24
   A charger APRES shared.css sur toutes les pages.
   ============================================================ */

html, body { max-width: 100%; overflow-x: hidden; }
* { -webkit-text-size-adjust: 100%; }
input, select, textarea { font-size: 16px; }
img, canvas { max-width: 100%; }

/* ---------- tue auto-fit partout sous 768px ----------
   auto-fit/minmax force 2 colonnes minuscules sur mobile.
   remplace par des colonnes fluides qui s'adaptent a la largeur */
@media (max-width: 768px) {
    .kpi-line,
    .profile-details,
    .form-grid,
    .physio-grid,
    .stat-grid,
    .micro-grid,
    .calc-results,
    .modal-stats-grid,
    .calc-section,
    .central-grid,
    .charts-grid,
    .install-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)) !important;
    }
    /* Les grilles "2 colonnes" simples passent en 1 colonne */
    .main-container,
    .player-header,
    .right-col .card { grid-template-columns: 1fr !important; }
    .panel-full-width { grid-column: 1 / -1; }
    .right-col .card { position: static !important; top: auto !important; }
}

/* Sous 480px : meme les paires deviennent 1 colonne */
@media (max-width: 480px) {
    .kpi-line,
    .profile-details,
    .physio-grid,
    .stat-grid,
    .micro-grid,
    .calc-results,
    .modal-stats-grid,
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    .physio-grid .physio-item:nth-child(5) { grid-column: auto; }
}

/* ---------- NAV : menu burger (le menu disparaissait sous 900px) ---------- */
.nav-burger { display: none; flex-direction: column; justify-content: center; gap: 4px;
    width: 40px; height: 40px; background: transparent;
    border: 1px solid var(--border-color, #333); border-radius: 8px; cursor: pointer; padding: 8px; }
.nav-burger span { display: block; height: 2px; background: var(--text-color, #fff); border-radius: 2px; }
@media (max-width: 900px) {
    .global-nav { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
    .nav-logo { font-size: 1.25rem; }
    .nav-controls { order: 3; width: 100%; justify-content: space-between; flex-wrap: wrap; }
    .nav-menu { display: flex !important; order: 4; width: 100%; flex-direction: column;
        gap: 4px; max-height: 0; overflow: hidden; transition: max-height 0.25s ease; }
    .nav-menu.open { max-height: 340px; }
    .nav-item { width: 100%; text-align: center; padding: 12px; border-radius: 8px; }
    .nav-burger { display: inline-flex; }
}

@media (max-width: 768px) {
    .main-container { padding: 0 12px !important; margin-top: 16px; }
    .panel, .card, .calc-card, .pma-card, .zones-card, .api-conn-section, .security-section { padding: 16px; }
    .card h2, .panel h3 { font-size: 1.1rem; }
}

@media (max-width: 600px) {
    .card-fc-max { flex-direction: column; align-items: stretch; text-align: center; }
    .fc-content { justify-content: center; }
    .fc-actions { justify-content: center; }
    .fc-value { font-size: 2rem; }
}
@media (max-width: 768px) {
    .stats-table thead { display: none; }
    .stats-table, .stats-table tbody, .stats-table tr, .stats-table td { display: block; width: 100%; }
    .stats-table tr { margin-bottom: 12px; border: 1px solid var(--border-color, #333);
        border-radius: 8px; padding: 8px; background: var(--input-bg, #222); }
    .stats-table td { border: none; padding: 6px 4px; text-align: left; }
    .stats-table td::before { content: attr(data-label); display: block;
        font-size: 0.7rem; text-transform: uppercase; color: var(--secondary-text, #888); }
}


@media (max-width: 768px) {
    .calendar-grid { display: block !important; min-width: 0 !important; padding: 10px; }
    .weekday-header { display: none; }
    .day-cell { display: flex !important; flex-direction: column; min-height: 0 !important;
        margin-bottom: 8px; border: 1px solid var(--border-color, #333); }
    .day-cell.empty { display: none; }
    .day-number { margin-bottom: 6px; }
    .session-block { font-size: 0.8rem; padding: 8px; }
    .session-title { font-size: 0.8rem; }
    .time-grid { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 768px) {
    .meal-selector { flex-wrap: nowrap; overflow-x: auto; }
    .food-results { max-height: 240px; }
}

@media (max-width: 768px) {
    .admin-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    table { display: block; overflow-x: auto; white-space: nowrap; }
    th, td { padding: 8px; font-size: 0.85rem; }
}

@media (max-width: 480px) {
    .login-box { padding: 30px 20px; border-radius: 0; max-width: 100%; }
    .logo-large { font-size: 2.5rem; }
    .lang-switch { flex-wrap: wrap; }
}
.modal-content, .notif-dropdown { max-width: 94vw; }
@media (max-width: 600px) {
    .notif-dropdown { width: 90vw; right: -10px; }
    .modal-content { padding: 20px; }
}
@media (max-width: 768px) {
    .btn-icon, .delete-btn, .grey-btn, .btn-nav, .chart-btn, .rpe-btn { min-height: 44px; min-width: 44px; }
    .rpe-grid { grid-template-columns: repeat(5, 1fr) !important; gap: 10px; }
    .btn-submit, .action-btn, .calc-btn, .api-btn { padding: 14px; }
}


/* ============================================================
    debordements flexbox + nutrition
   ============================================================ */

/* FIX FLEXBOX UNIVERSEL : un "input flex" refuse de se reduire sans min-width:0.
   est la cause des boutons OK/fleches qui sortent du cadre */
input, select, textarea, .predict-input, .calc-input, .form-input,
.api-input, .login-input, .search-input, .pma-input-group input,
.zones-input-group input {
    min-width: 0;
}

@media (max-width: 768px) {
    .cal-header { flex-direction: column; align-items: stretch; gap: 12px; }
    .cal-title { order: -1; text-align: center; }
    .cal-controls { width: 100%; justify-content: space-between; }
    .current-month { min-width: 0 !important; flex: 1; font-size: 1rem; }

    .predict-input-group { flex-wrap: wrap; }
    .predict-input { flex: 1 1 100%; }
    .predict-btn { flex: 1 1 100%; }
}

@media (max-width: 768px) {
    .main-container { grid-template-columns: 1fr !important; }
    .stat-grid,
    .micro-grid { grid-template-columns: 1fr !important; }
    .right-col .card { position: static !important; top: auto !important; }

    .meal-selector { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .meal-label { flex: 0 0 auto; }

    .log-entry { flex-wrap: wrap; gap: 6px; }
    .log-info { flex: 1 1 100%; min-width: 0; }
    .log-name { overflow-wrap: anywhere; }
    .log-weight, .log-macros { flex: 0 0 auto; }
}