/* ===== RESET & BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #28a745;
    --primary-dark: #218838;
    --secondary: #17a2b8;
    --success: #28a745;
    --info: #17a2b8;
    --warning: #ffc107;
    --danger: #dc3545;
    --light: #f8f9fa;
    --dark: #343a40;
    --white: #fff;
    --shadow: 0 0.5rem 1rem rgba(0,0,0,.15);
    --shadow-sm: 0 0.125rem 0.25rem rgba(0,0,0,.075);
    --border-radius: 0.5rem;
    --border-radius-sm: 0.375rem;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --header-height: 80px;
}

html { scroll-behavior: smooth; }
body { font-family: var(--font-family); background-color: #f5f7fa; color: var(--dark); line-height: 1.6; }
.app-container { min-height: 100vh; display: flex; flex-direction: column; }

/* ===== HEADER ===== */
header.sticky-top {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white); padding: 0.75rem 1rem;
    box-shadow: var(--shadow); z-index: 1050; position: sticky; top: 0;
}
.header-content {
    display: flex; justify-content: space-between; align-items: center;
    max-width: 1200px; margin: 0 auto; flex-wrap: wrap; gap: 1rem;
}
.logo h1 { font-size: 1.5rem; font-weight: 600; margin-bottom: 0; }
.logo .subtitle { font-size: 0.875rem; opacity: 0.9; }

.quick-menu { display: flex; gap: 0.5rem; }
.quick-menu .btn {
    background: rgba(255,255,255,.25) !important; border: none !important;
    color: var(--white) !important; padding: 0.5rem 0.75rem !important;
    font-size: 1.25rem !important; border-radius: var(--border-radius-sm) !important;
    transition: all 0.3s ease;
}
.quick-menu .btn:hover { background: rgba(255,255,255,.4) !important; transform: translateY(-2px) !important; }

/* ===== NAVIGATION ===== */
nav.navbar.sticky-top-nav {
    box-shadow: var(--shadow-sm); padding: 0.5rem 0;
    position: sticky; top: var(--header-height); z-index: 1040;
    background: var(--white) !important;
}
.navbar .container-fluid { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* Bouton hamburger — visible sur fond blanc */
.navbar-toggler {
    background: var(--light);
    border: 1px solid #ced4da;
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 0.75rem;
    color: var(--dark);
    font-size: 1.25rem;
    transition: all 0.3s ease;
    z-index: 1051;
    position: relative;
}
.navbar-toggler:hover { background: #e2e6ea; }
.navbar-toggler:focus { box-shadow: none; outline: 2px solid var(--primary); }

.navbar-nav {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; width: 100%;
}
.navbar-nav .nav-item { flex: 1 0 auto; min-width: 120px; }
.navbar-nav .nav-link {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 0.5rem; color: var(--dark); font-size: 0.875rem;
    border-radius: var(--border-radius-sm); transition: all 0.3s ease; white-space: nowrap;
}
.navbar-nav .nav-link i         { font-size: 1.25rem; margin-bottom: 0.25rem; }
.navbar-nav .nav-link .nav-text { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; }
.navbar-nav .nav-link:hover     { background: var(--light); color: var(--primary); }
.navbar-nav .nav-link.active    { background: var(--primary); color: var(--white); }
.navbar-nav .nav-link.active i,
.navbar-nav .nav-link.active .nav-text { color: var(--white); }

@media (max-width: 768px) {
    .navbar-expand-md .navbar-collapse.show {
        display: grid; grid-template-columns: repeat(2,1fr); gap: 0.5rem;
        position: absolute; top: 100%; left: 0; right: 0;
        background: var(--white); box-shadow: var(--shadow); padding: 1rem;
        border-radius: 0 0 var(--border-radius) var(--border-radius); z-index: 1030;
    }
    .navbar-expand-md .navbar-nav  { width: 100%; flex-direction: row; flex-wrap: wrap; }
    .navbar-expand-md .nav-item    { flex: 0 0 50%; max-width: 50%; }
    .navbar-expand-md .nav-link    { padding: 0.75rem 0.5rem; justify-content: flex-start; gap: 0.5rem; width: 100%; text-align: left; }
    .navbar-expand-md .nav-link i  { font-size: 1.1rem; margin-bottom: 0; min-width: 24px; text-align: center; }
    .navbar-expand-md .nav-link span.nav-text { display: block; font-size: 0.875rem; text-transform: none; letter-spacing: normal; line-height: 1.2; }
    nav.navbar.sticky-top-nav { top: var(--header-height); }
    .header-content { flex-direction: column; gap: 0.5rem; }
    .logo { text-align: center; }
    .logo h1 { font-size: 1.25rem; }
}
@media (max-width: 480px) {
    header { padding: 0.5rem 1rem; }
    .logo h1 { font-size: 1.25rem; }
    .logo .subtitle { font-size: 0.75rem; }
    .navbar-nav .nav-item { flex: 0 0 50%; max-width: 50%; }
}

/* ===== MAIN ===== */
main { flex: 1; padding: 1.5rem; max-width: 1200px; margin: 0 auto; width: 100%; }
@media (max-width: 768px) { main { padding: 1rem; } }

.page-title { font-size: 1.5rem; margin-bottom: 1.5rem; color: var(--dark); display: flex; align-items: center; gap: 0.75rem; }
.page-title i { color: var(--primary); }
@media (max-width: 768px) { .page-title { font-size: 1.25rem; } }

/* ===== CARDS ===== */
.card { background: var(--white); border-radius: var(--border-radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem; }
.card-title { font-size: 1.25rem; margin-bottom: 1rem; color: var(--dark); border-bottom: 2px solid var(--primary); padding-bottom: 0.5rem; display: flex; align-items: center; gap: 0.5rem; }
@media (max-width: 480px) { .card { padding: 1rem; } }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--dark); }
.form-control { width: 100%; padding: 0.75rem; border: 1px solid #ced4da; border-radius: var(--border-radius-sm); font-size: 1rem; transition: border-color 0.3s ease; }
.form-control:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 0.2rem rgba(40,167,69,.25); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
@media (max-width: 768px) { .form-row { grid-template-columns: 1fr; } }

/* ===== BUTTONS ===== */
.btn { padding: 0.75rem 1.5rem; border: none; border-radius: var(--border-radius-sm); font-size: 1rem; cursor: pointer; transition: all 0.3s ease; display: inline-flex; align-items: center; gap: 0.5rem; }
.btn:focus, .btn:active { outline: none; }
.btn-primary   { background: var(--primary);   color: var(--white); }
.btn-primary:hover   { background: var(--primary-dark); transform: translateY(-2px); }
.btn-secondary { background: var(--secondary); color: var(--white); }
.btn-secondary:hover { background: #138496; }
.btn-success   { background: var(--success);   color: var(--white); }
.btn-danger    { background: var(--danger);    color: var(--white); }
.btn-info      { background: var(--info);      color: var(--white); }
.btn-sm        { padding: 0.5rem 1rem; font-size: 0.875rem; }
.btn-outline-primary   { background: transparent; border: 1px solid var(--primary);   color: var(--primary); }
.btn-outline-primary:hover   { background: var(--primary);   color: var(--white); }
.btn-outline-secondary { background: transparent; border: 1px solid var(--secondary); color: var(--secondary); }
.btn-outline-secondary:hover { background: var(--secondary); color: var(--white); }
.btn-outline-info      { background: transparent; border: 1px solid var(--info);      color: var(--info); }
.btn-outline-info:hover      { background: var(--info);      color: var(--white); }
@media (max-width: 480px) { .btn { padding: 0.625rem 1.25rem; font-size: 0.875rem; } }

/* ===== TABLES ===== */
.table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.table th, .table td { padding: 0.75rem; text-align: left; border-bottom: 1px solid #dee2e6; }
.table th { background: var(--light); font-weight: 600; color: var(--dark); }
.table tr:hover { background: rgba(0,0,0,.05); }

/* ===== CALENDRIER ===== */
.calendar { display: grid; grid-template-columns: repeat(7,1fr); gap: 0.5rem; margin-top: 1rem; }
.calendar-header { display: grid; grid-template-columns: repeat(7,1fr); gap: 0.5rem; margin-bottom: 0.5rem; }
.calendar-header div { text-align: center; font-weight: 600; padding: 0.5rem; background: var(--primary); color: var(--white); border-radius: var(--border-radius-sm); }
.calendar-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border: 1px solid #dee2e6; border-radius: var(--border-radius-sm); cursor: pointer; transition: all 0.3s ease; background: var(--white); font-size: 0.875rem; }
.calendar-day:hover:not(.empty):not(.selected) { background: var(--light); border-color: var(--primary); }
.calendar-day.today    { font-weight: bold; background: rgba(40,167,69,.1); }
.calendar-day.selected { background: var(--primary); color: var(--white); border-color: var(--primary); }
.calendar-day.empty    { visibility: hidden; }
.calendar-day.has-data { position: relative; }
.calendar-day.has-data::after { content: ''; display: block; width: 6px; height: 6px; background: var(--primary); border-radius: 50%; position: absolute; bottom: 4px; }
.calendar-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.calendar-nav h3 { font-size: 1.1rem; color: var(--dark); margin: 0; }

/* ===== REPAS ===== */
.meal-input { border: 1px solid #ced4da; border-radius: var(--border-radius); padding: 1rem; margin-bottom: 1rem; background: var(--white); }
.meal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid #dee2e6; }
.meal-header h4 { font-size: 1rem; color: var(--dark); margin: 0; }
.food-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0; border-bottom: 1px solid #f0f0f0; }
.food-item:last-child { border-bottom: none; }
.food-item input, .food-item select { flex: 1; padding: 0.5rem; border: 1px solid #ced4da; border-radius: var(--border-radius-sm); font-size: 0.875rem; }
.food-item input[type="number"] { width: 80px; }
.food-item input[type="text"]   { flex: 2; }
.food-item .remove-btn { background: var(--danger); color: var(--white); border: none; padding: 0.5rem; border-radius: var(--border-radius-sm); cursor: pointer; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; font-size: 0.875rem; }
.add-food-btn { display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem; background: var(--light); border: 1px dashed #ced4da; border-radius: var(--border-radius); cursor: pointer; margin-top: 1rem; color: var(--secondary); transition: all 0.3s ease; justify-content: center; }
.add-food-btn:hover { background: var(--primary); color: var(--white); border-color: var(--primary); }
@media (max-width: 480px) { .food-item { flex-direction: column; gap: 0.5rem; } .food-item input, .food-item select { width: 100%; } }

/* ===== GRAPHIQUES ===== */
.chart-wrapper { position: relative; height: 300px; }

/* ===== EXPORT ===== */
.export-options { display: flex; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.export-card { background: var(--white); border-radius: var(--border-radius); padding: 1.5rem; box-shadow: var(--shadow); text-align: center; flex: 1; min-width: 200px; display: flex; flex-direction: column; align-items: center; }
.export-card i  { font-size: 2.5rem; color: var(--primary); margin-bottom: 1rem; }
.export-card h4 { margin-bottom: 0.5rem; color: var(--dark); }
.export-card p  { color: #6c757d; font-size: 0.9rem; margin-bottom: 1rem; }

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }  .mt-2 { margin-top: 1rem; }  .mt-3 { margin-top: 1.5rem; }  .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }
.d-flex { display: flex; } .flex-wrap { flex-wrap: wrap; } .fw-bold { font-weight: bold; }

/* ===== TOAST ===== */
.toast { position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%); background: var(--dark); color: var(--white); padding: 1rem 2rem; border-radius: var(--border-radius); box-shadow: 0 4px 12px rgba(0,0,0,.3); z-index: 1100; animation: slideIn 0.3s ease-out; }
@keyframes slideIn { from { transform: translateX(-50%) translateY(100%); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger);  }

/* ===== PWA ===== */
@media (display-mode: standalone) {
    body   { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
    header { padding-top: calc(0.75rem + env(safe-area-inset-top)); }
    nav.navbar { top: calc(var(--header-height) + env(safe-area-inset-top)); }
}
@supports (-webkit-touch-callout: none) { .btn:active { transform: scale(0.98); } }
@media (hover: none) { .form-control:focus, .nav-link:focus { outline: 2px solid var(--primary); outline-offset: 2px; } }
