/* =========================================
   0. POLICE & VARS
   ========================================= */
@font-face {
  font-family: 'Material Icons';
  font-style: normal;
  font-weight: 400;
  src: url('/lib/MaterialIcons-Regular.woff2') format('woff2');
}

.material-icons {
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  display: inline-block;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  word-wrap: normal;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:root {
    /* --- THÈME CLAIR (Mode Jour) --- */
    --bg-dark: #f0f4f8;          /* Fond principal clair */
    --surface-dark: #ffffff;      /* Surface blanche */
    --surface-card: #ffffff;      /* Carte blanche */
    --surface-glass: rgba(255, 255, 255, 0.95);
    
    --primary: #0da6f2; 
    --secondary: #4CAF50;
    --warning: #FF9800;
    --danger: #f27474;
    
    --text-white: #333333;        /* Texte principal deviendra sombre */
    --text-muted: #666666;        /* Texte secondaire gris */
    
    --border-color: rgba(0, 0, 0, 0.1); /* Bordures gris clair */
    
    --radius-xl: 16px;
    --radius-lg: 12px;
    --radius-full: 9999px;
    
    --shadow-card: 0 4px 6px rgba(0, 0, 0, 0.05); /* Ombres plus douces */
    --shadow-liquid: 0 0 15px rgba(13, 166, 242, 0.4);
    /* Variable spécifique pour la barre de navigation (Fond blanc/gris clair transparent) */
    --nav-bg: rgba(240, 244, 248, 0.95);
}

/* --- THÈME SOMBRE (Mode Nuit - Stich Original) --- */
body.dark-mode {
    --bg-dark: #101c22;
    --surface-dark: #192b34;
    --surface-card: #223c49;
    --surface-glass: rgba(24, 43, 52, 0.95);
    
    --text-white: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-card: 0 4px 6px rgba(0, 0, 0, 0.3);
    /* Variable spécifique pour la barre de navigation (Fond sombre transparent) */
    --nav-bg: rgba(16, 28, 34, 0.95); 
}

body {
    background-color: var(--bg-dark);
    color: var(--text-white);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease; /* Transition douce */
}

/* App Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

/* =========================================
   1. GAUGE SIDEBAR (Gauche)
   ========================================= */
.gauge-sidebar {
    width: 40px; /* Un peu plus large que 22% pour mobile */
    min-width: 40px;
    max-width: 80px;
    /*height: 100%;*/
    padding: 20px 10px 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    z-index: 10;
    flex-shrink: 0; /* Ne rétrécit jamais */
}

.gauge-container {
    width: 100%;
    height: 100%;
    background-color: var(--surface-dark);
    border-radius: 50px; /* Forme de pilule */
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

/* Marques de graduation */
.gauge-marks {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 40px 0;
    align-items: center;
    z-index: 20;
    pointer-events: none;
    opacity: 0.3;
}
.mark { background-color: white; height: 1px; }
.mark.big { width: 12px; }
.mark.small { width: 6px; }

/* Le Liquide animé */
.liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%; /* JS va changer ça */
    transition: height 1s ease-in-out, background 0.5s ease;
    border-radius: 0 0 50px 50px;
}

/* Couleurs dynamiques du liquide */
.liquid.blue { background: linear-gradient(180deg, #0da6f2 0%, #086fac 100%); box-shadow: 0 0 15px rgba(13, 166, 242, 0.4); }
.liquid.green { background: linear-gradient(180deg, #4CAF50 0%, #2E7D32 100%); box-shadow: 0 0 15px rgba(76, 175, 80, 0.4); }
.liquid.orange { background: linear-gradient(180deg, #FF9800 0%, #F57C00 100%); box-shadow: 0 0 15px rgba(255, 152, 0, 0.4); }
.liquid.red { background: linear-gradient(180deg, #f44336 0%, #c62828 100%); box-shadow: 0 0 15px rgba(244, 67, 54, 0.4); }

.liquid-top-blur {
    position: absolute;
    top: -5px; left: 0; right: 0;
    height: 10px;
    background: inherit;
    filter: blur(4px);
    opacity: 0.8;
}

/* Percentage Text */
.percentage-display {
    margin-top: 10px;
    font-weight: 800;
    font-size: 0.9em;
    color: var(--primary);
    letter-spacing: 1px;
}

/* =========================================
   2. MAIN CONTENT (Droite)
   ========================================= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 20px 100px 20px; /* Padding bottom pour la nav flottante */
    overflow-y: auto;
    position: relative;
}

/* Top Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
}
.header-label {
    font-size: 0.85em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}
.header-values {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.header-values h2 {
    font-size: 2em;
    font-weight: 800;
    margin: 0;
    line-height: 1;
}
.header-values span {
    color: var(--text-muted);
    font-weight: 500;
}
.glass-btn {
    background-color: var(--surface-card);
    border-radius: 50%;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    transition: background 0.2s;
}
.glass-btn:hover { background-color: rgba(255,255,255,0.1); color: white; }

/* View Sections */
.view-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Last Drink Card */
.glass-panel {
    background-color: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    box-shadow: var(--shadow-card);
    font-weight: 0.8em;
    font-style: italic;
}
.last-drink-icon-wrapper {
    width: 40px; height: 40px;
    /*background-color: rgba(13, 166, 242, 0.15);*/
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--primary);
}
.last-drink-info { flex: 1; }
.last-drink-info p { margin: 0; }
.last-drink-info .font-bold { font-size: 1.1em; margin-top: 2px; }
.label-xs { font-size: 0.75em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.time-badge { color: var(--primary); font-weight: 600; font-size: 0.9em; }

/* Drink Grid */
.drink-buttons-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}
.drink-btn {
    background-color: var(--surface-card);
    border: 1px solid transparent;
    border-radius: var(--radius-xl);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /*gap: 10px;*/
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    box-shadow: var(--shadow-card);
}
.drink-btn:hover {
    background-color: rgba(34, 60, 73, 0.9);
    border-color: rgba(255,255,255,0.1);
    transform: translateY(-2px);
}
.drink-btn:active { transform: scale(0.98); }

/* Icon Circle in Button */
.drink-icon-circle {
    width: 60px; height: 60px;
    background-color: var(--bg-dark);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    /*box-shadow: 0 4px 8px rgba(0,0,0,0.2);*/
    margin-bottom: 5px;
}
.drink-icon-circle .material-icons { font-size: 32px; }

/* Button Text */
.drink-name { font-weight: 700; font-size: 1.1em; color: var(--text-white); }
.drink-vol { font-weight: 500; font-size: 0.9em; } /* La couleur est mise en JS */

/* Badge count */
.badge-count {
    position: absolute;
    top: 5px; left: 5px;
    /*background: var(--bg-dark);*/
    color: var(--text-white);
    font-size: 0.8em;
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

/* =========================================
   3. FLOATING NAVIGATION (Bas)
   ========================================= */
.floating-nav {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 100%; /* S'aligne avec la main-content */
    padding: 0;
    z-index: 10000;
    /*pointer-events: none !important;  Laisse passer les clics autour */
}
.nav-glass-container {
    border-radius: 0; /* Plus de bords arrondis (barre droite) */
    border: none;
    border-top: 1px solid var(--border-color);
    background: var(--nav-bg); /* Fond plus opaque pour la lisibilité */
    padding: 10px 0; /* Hauteur standard */
    display: flex;
    justify-content: space-around; /* Espacement égal des boutons */
}
.nav-item {
    flex: 1;
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 8px 0;
    border-radius: 8px;
    transition: all 0.2s;
}
.nav-item:hover { color: var(--text-white); background-color: rgba(255,255,255,0.05); }
.nav-item.active { color: var(--primary); }
.nav-item.active .material-icons { transform: scale(1.1); }
.nav-item .nav-label { font-size: 0.7em; font-weight: 600; letter-spacing: 0.5px; }

/* =========================================
   4. HISTORY VIEW Styles
   ========================================= */
.history-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.history-list { display: flex; flex-direction: column; gap: 15px; width: 100%; }

.history-day {
    background-color: var(--surface-card);
    border-radius: var(--radius-lg);
    padding: 15px;
    border: 1px solid var(--border-color);
}

.history-day-header {
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; user-select: none;
}
.history-date { font-weight: 600; color: var(--text-muted); }
.total-day-value { font-weight: 700; color: var(--text-white); }
.toggle-icon { color: var(--text-muted); transition: transform 0.3s; }
.history-day.expanded .toggle-icon { transform: rotate(180deg); color: var(--primary); }

.day-entries { display: none; margin-top: 15px; border-top: 1px solid var(--border-color); padding-top: 10px; }
.history-day.expanded .day-entries { display: block; animation: fadeIn 0.2s; }

.history-entry {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 0;
    font-size: 0.9em;
    border-bottom: 1px solid var(--border-color);
}
.history-entry:last-child { border-bottom: none; }
/* Indicateur visuel couleur boisson */
.entry-info { display: flex; align-items: center; gap: 10px; color: var(--text-white); }
.entry-color-dot { width: 10px; height: 10px; border-radius: 50%; }

/* Graphique */

/* Graphique : Ajout des labels d'heures */
.graph-axis-label {
    position: absolute;
    bottom: -20px; /* Sous les barres */
    font-size: 0.7em;
    color: var(--text-muted);
    transform: translateX(-50%);
}
.daily-graph-wrapper {
    height: 100px; margin: 10px 0 30px 0; position: relative;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: flex-end;
}
.graph-bar {
    position: absolute; bottom: 0; width: 5px;
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
    /* Background color set by JS */
}

/* =========================================
   5. MODALS & FORMS
   ========================================= */
.modal {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(5px);
    z-index: 100;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal.active { opacity: 1; pointer-events: auto; }

.modal-content {
    background: var(--bg-dark);
    width: 90%; max-width: 400px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex; flex-direction: column;
    max-height: 85vh; height: 80%; margin-bottom: 50px;
}
.modal-content header {
    padding: 5px 20px; border-bottom: 1px solid var(--border-color); margin-bottom: 15px;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-body { 
    padding: 20px; overflow-y: auto; display: flex; 
    flex-direction: column; gap: 15px; height: 100%;
}

.modal-content.small-modal { /* Pour les modals de confirmation */
    align-self: center; /* Se place bien au milieu verticalement */
    transform: translateY(0) !important; /* Pas d'animation venant du bas pour celle-ci */
    
    /* C'est ici que ça se joue : */
    height: auto;       /* La hauteur s'adapte au texte à l'intérieur */
    max-height: 90vh;   /* Sécurité : ne dépasse jamais 90% de l'écran */
    overflow-y: auto;   /* Scroll uniquement si VRAIMENT le texte est géant */
    
    /* Un peu de marge interne pour respirer 
    padding-top: 10px;*/
    padding-bottom: 10px; 
    width: 90%;
}
.modal.active .modal-content.small-modal {
    transform: translateY(0);
}

.modal-content h2 {
    font-size: 1.2em;
    color: var(--primary-color);
}
.modal-content h3 {
    /*font-size: 1.1em;*/
    color: var(--text-light);
    margin-top: 20px;
    /*margin-bottom: 10px;*/
    font-weight: 600;
}

/* =========================================
   6. SETTINGS MODAL STYLES
   ========================================= */

/* Le conteneur des options */
#settings-modal .modal-body {
    padding: 0 20px;
    gap: 0; /* On gère l'espacement via le padding des items */
}

/* Chaque ligne de paramètre */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0; /* Espace vertical confortable */
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    background: none;
    color: var(--text-white);
    font-size: 1em;
    text-align: left;
}

/* Enlever la bordure du dernier élément */
.setting-item:last-child {
    border-bottom: none;
}

/* Style spécifique pour le bouton "À propos" (flèche) */
.setting-item.action-btn {
    width: 100%;
    background: none;
    border: none;
    /*border-bottom: 1px solid var(--border-main);  Garde la ligne de séparation */
    cursor: pointer;
    font-family: inherit; /* Garde la police du site */
    text-align: left;
    color: var(--text-main); /* Couleur du texte normal */
    padding: 15px 0 25px 0; /* Un peu plus d'espace pour le doigt */
    transition: background-color 0.2s;
}
.setting-item.action-btn:active {
    background-color: rgba(255, 255, 255, 0.05);
}
.setting-item .material-icons {
    color: var(--text-muted);
}

/* Labels des paramètres */
.setting-item span:first-child {
    font-weight: 500;
    font-size: 1.05em;
}

/* Sélecteur de langue */
.lang-select {
    padding: 8px 12px;
    background-color: var(--bg-dark); /* Plus foncé que la carte */
    border: 1px solid var(--border-color);
    color: var(--text-white);
    border-radius: 8px;
    outline: none;
    width: auto; /* Ne prend pas toute la largeur */
}

/* --- SWITCH TOGGLE (Style iOS/Stich) --- */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}
.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #3f4a52; /* Gris foncé éteint */
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px; width: 20px;
    left: 4px; bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

/* État activé */
input:checked + .slider {
    background-color: var(--primary); /* Bleu Stich */
}
input:checked + .slider:before {
    transform: translateX(22px);
}
/* Inputs */
.input-group label { display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 0.9em; }
input[type="text"], input[type="number"], select {
    width: 82%; padding: 12px;
    background: var(--surface-card); border: 1px solid var(--border-color);
    color: var(--text-white); border-radius: 8px; font-size: 1em;
}
input:focus { border-color: var(--primary); outline: none; }

/* Color Picker */
.row-inputs { display: flex; gap: 15px; }
.half { flex: 1; }
.color-picker-wrapper {
    height: 45px; width: 100%;
    border-radius: 8px; overflow: hidden;
    border: 1px solid var(--border-color);
}
input[type="color"] {
    width: 100%; height: 100%; padding: 0; border: none; cursor: pointer;
    background: none;
}

/* Icon Combobox */
.custom-combobox-wrapper { position: relative; }
.input-icon-preview { position: absolute; left: 10px; top: 10px; color: var(--primary); }
#drink-icon-input { padding-left: 45px; }
.input-action-btn { position: absolute; right: 5px; top: 5px; color: var(--text-muted); background: none; border: none; }
.custom-dropdown {
    position: absolute; top: 100%; width: 100%;
    background: var(--surface-card); border: 1px solid var(--border-color);
    z-index: 200; list-style: none; padding: 0; margin: 5px 0 0 0;
    max-height: 300px; overflow-y: auto; border-radius: 8px;
}
.dropdown-item { 
    padding: 10px; cursor: pointer; display: flex; gap: 10px; 
    color: var(--text-white); border-bottom: 1px solid var(--border-color); 
}
.dropdown-item:hover { background: rgba(255,255,255,0.05); }

/* --- CONTRÔLES DE RÉORGANISATION (Options) --- */
.reorder-controls {
    display: flex;
    flex-direction: column; /* Flèches l'une sur l'autre */
    justify-content: center;
    margin-right: 15px; /* Espace avant l'icône de boisson */
}

.mini-btn {
    background: none;
    border: none;
    padding: 0;
    margin: -2px 0; /* Resserre les flèches verticalement */
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    display: flex; 
    align-items: center; 
    justify-content: center;
}

.mini-btn:hover {
    color: var(--primary);
    background-color: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.mini-btn:disabled {
    color: rgba(255,255,255,0.1); /* Grisé si non cliquable (premier/dernier) */
    cursor: default;
}
.mini-btn:disabled:hover {
    background-color: transparent;
}

.mini-btn .material-icons {
    font-size: 24px; /* Taille confortable */
}


/* Buttons Generic */
.add-btn {
    background: var(--primary); color: white; border: none; padding: 12px;
    border-radius: var(--radius-lg); font-weight: 700; width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    cursor: pointer; margin-top: 10px;
}
.btn { padding: 10px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; border: none; }
.secondary-btn { background: var(--surface-card); color: var(--text-white); border: 1px solid var(--border-color); }
.danger-btn { background: var(--danger); color: white; }
.icon-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; }
.icon-btn:hover { color: white; }
.icon-btn.danger { color: var(--danger); }

/* Switch Toggle */
.switch { position: relative; display: inline-block; width: 40px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #555; transition: .4s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* List Options */
.drink-options-list { overflow-y: auto; }
.drink-option-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px; border-bottom: 1px solid var(--border-color);
    color: white;
}
.hidden { display: none !important; }
.donation-actions { display: flex; gap: 10px; margin-top: 15px; }
.rate-btn { background: var(--primary); color: white; flex: 1; }
.donation-btn { background: linear-gradient(135deg, #FF9800, #F57C00); color: white; flex: 1; }

/* --- ADAPTATION PC --- */
@media (min-width: 501px) {
    body {
        /* Fond sombre pour l'extérieur de l'app sur ordi 
        background-color: #080f12; */
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        margin: 0;
    }

    .app-container {
        max-width: 500px;
        height: 90vh; /* Laisse un peu d'espace en haut/bas sur PC */
        border-radius: 10px; /* Effet bords arrondis téléphone */
        position: relative;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
        overflow: hidden;
        border: 1px solid var(--surface-card);
    }
    
    .modal-body { padding: 20px 20px 40px; }

    /* Ajustement de la nav bar car elle est en position fixed */
    .floating-nav {
        position: absolute; /* Devient relative au conteneur max-width */
        max-width: 500px;
        left: 0;
    }
}
/* --- STYLE DES BARRES DE DÉFILEMENT (PC & WebView) --- */

/* 1. Largeur de la barre */
::-webkit-scrollbar {
    width: 6px;
}

/* 2. Fond de la glissière (le rail) */
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

/* 3. La partie mobile (le "pouce") */
::-webkit-scrollbar-thumb {
    background-color: var(--surface-card);
    border-radius: 10px;
    border: 1px solid var(--bg-dark);
}

/* 4. Couleur au survol */
::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary);
}

/* Pour Firefox (limité mais propre) */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--surface-card) var(--bg-dark);
}
