/* ============================================================
   style.css — Notes de Frais / Vivo Energy Maroc  v2
   Design moderne, mobile-first, lisible en plein soleil
   ============================================================ */

:root {
  --rouge:      #e63329;
  --rouge-d:    #c0271e;
  --rouge-pale: #fdecea;
  --bleu:       #1F4E78;
  --bleu-pale:  #e8f0fa;
  --gris-bg:    #f0f2f5;
  --gris-card:  #ffffff;
  --gris-bd:    #e0e3e8;
  --gris-tx:    #6b7280;
  --gris-fonce: #374151;
  --vert:       #10b981;
  --blanc:      #ffffff;
  --ombre-sm:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --ombre:      0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --ombre-lg:   0 10px 25px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);
  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  20px;
  --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --transition: .18s cubic-bezier(.4,0,.2,1);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--gris-bg); color: var(--gris-fonce);
       min-height: 100vh; padding-bottom: 6rem; -webkit-font-smoothing: antialiased; }
a { color: var(--rouge); text-decoration: none; }

/* ============================================================
   PAGE CONNEXION
   ============================================================ */
body.page-login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(145deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-card {
  background: var(--blanc);
  border-radius: var(--radius-lg);
  box-shadow: var(--ombre-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--rouge), var(--rouge-d));
  border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 8px 20px rgba(230,51,41,.35);
  margin-bottom: .75rem;
}

.login-logo h1 { font-size: 1.4rem; font-weight: 700; color: var(--gris-fonce); }
.login-subtitle { font-size: .82rem; color: var(--gris-tx); margin-top: .2rem; }

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  background: var(--blanc);
  border-bottom: 1px solid var(--gris-bd);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--ombre-sm);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.navbar-brand-dot {
  width: 8px; height: 8px;
  background: var(--rouge);
  border-radius: 50%;
  flex-shrink: 0;
}

.navbar-brand-text {
  font-weight: 700;
  font-size: 1rem;
  color: var(--gris-fonce);
  letter-spacing: -.01em;
}

.navbar-actions { display: flex; gap: .25rem; align-items: center; }

.btn-icon {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  color: var(--gris-tx);
  transition: background var(--transition), color var(--transition);
  border: none; background: transparent; cursor: pointer;
  text-decoration: none;
}
.btn-icon:hover { background: var(--gris-bg); color: var(--gris-fonce); text-decoration: none; }

.btn-back {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .4rem .7rem;
  border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 600;
  color: var(--gris-tx);
  transition: background var(--transition);
}
.btn-back:hover { background: var(--gris-bg); text-decoration: none; }

/* ============================================================
   BANNIÈRE INFO
   ============================================================ */
.banner-info {
  background: linear-gradient(90deg, #fffbeb, #fef3c7);
  border-bottom: 1px solid #fbbf24;
  padding: .55rem 1rem;
  font-size: .79rem;
  color: #78350f;
  text-align: center;
  line-height: 1.4;
}

/* ============================================================
   NAVIGATION MOIS
   ============================================================ */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.25rem 1rem .75rem;
}

.month-label {
  font-size: 1.15rem;
  font-weight: 700;
  min-width: 170px;
  text-align: center;
  color: var(--gris-fonce);
}

.btn-nav {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  background: var(--blanc);
  border: 1.5px solid var(--gris-bd);
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--rouge);
  box-shadow: var(--ombre-sm);
  transition: all var(--transition);
  text-decoration: none;
}
.btn-nav:hover { background: var(--rouge); color: var(--blanc); border-color: var(--rouge); text-decoration: none; }

/* ============================================================
   CARTES DE RÉSUMÉ
   ============================================================ */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .6rem;
  padding: 0 .75rem .25rem;
}

.summary-card {
  background: var(--blanc);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--ombre-sm);
  border: 1px solid var(--gris-bd);
  transition: transform var(--transition), box-shadow var(--transition);
}
.summary-card:active { transform: scale(.98); }

.summary-card--total {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--rouge), var(--rouge-d));
  color: var(--blanc);
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(230,51,41,.3);
}

.summary-label {
  font-size: .72rem;
  color: var(--gris-tx);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  margin-bottom: .4rem;
}
.summary-card--total .summary-label { color: rgba(255,255,255,.75); }

.summary-amount {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gris-fonce);
}
.summary-card--total .summary-amount { font-size: 1.4rem; color: var(--blanc); }

.summary-icon {
  font-size: 1.2rem;
  margin-bottom: .3rem;
  display: block;
}

/* ============================================================
   ACTIONS EXPORT
   ============================================================ */
.export-actions {
  display: flex;
  gap: .5rem;
  padding: .75rem .75rem .5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.export-actions::-webkit-scrollbar { display: none; }

/* ============================================================
   LISTE DES SORTIES
   ============================================================ */
.entries-list { padding: 0 .75rem; display: flex; flex-direction: column; gap: .6rem; }

.entry-card {
  background: var(--blanc);
  border-radius: var(--radius);
  box-shadow: var(--ombre-sm);
  border: 1px solid var(--gris-bd);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.entry-card:hover { box-shadow: var(--ombre); }

.entry-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .85rem .85rem .5rem;
}

.entry-date-badge {
  background: var(--rouge-pale);
  color: var(--rouge);
  font-weight: 700;
  font-size: .82rem;
  padding: .25rem .5rem;
  border-radius: 6px;
  min-width: 38px;
  text-align: center;
  flex-shrink: 0;
}

.entry-dest {
  flex: 1;
  font-weight: 600;
  font-size: .9rem;
  color: var(--gris-fonce);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-total {
  font-weight: 700;
  font-size: .95rem;
  color: var(--bleu);
  white-space: nowrap;
}

.entry-actions { display: flex; gap: .25rem; }

.entry-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  padding: .35rem .85rem .6rem;
}

.entry-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  background: var(--gris-bg);
  border: 1px solid var(--gris-bd);
  border-radius: 20px;
  padding: .18rem .55rem;
  font-size: .75rem;
  color: var(--gris-tx);
  font-weight: 500;
}
.entry-chip--updated { color: #9ca3af; border-color: transparent; background: transparent; font-size: .7rem; }

.entry-note-line {
  padding: 0 .85rem .6rem;
  font-size: .78rem;
  color: var(--gris-tx);
  font-style: italic;
  display: flex;
  gap: .3rem;
  align-items: flex-start;
}

/* ============================================================
   PHOTOS VIGNETTES
   ============================================================ */
.entry-photos {
  display: flex;
  flex-wrap: nowrap;
  gap: .4rem;
  padding: .3rem .85rem .85rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.entry-photos::-webkit-scrollbar { display: none; }

.photo-thumb {
  position: relative;
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: 68px;
  height: 68px;
  flex-shrink: 0;
  border: 1.5px solid var(--gris-bd);
  background: var(--gris-bg);
  display: block;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-type {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
  color: var(--blanc);
  font-size: .6rem;
  font-weight: 600;
  text-align: center;
  padding: .2rem .2rem .2rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem; padding: 1.25rem;
}
.page-info { font-size: .88rem; color: var(--gris-tx); font-weight: 600; }

/* ============================================================
   FAB — Bouton flottant
   ============================================================ */
.fab {
  position: fixed;
  bottom: 1.25rem; right: 1.25rem;
  width: 58px; height: 58px;
  background: linear-gradient(135deg, var(--rouge), var(--rouge-d));
  color: var(--blanc);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 300; line-height: 1;
  box-shadow: 0 6px 20px rgba(230,51,41,.45);
  z-index: 200;
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
}
.fab:hover { transform: scale(1.06); box-shadow: 0 8px 28px rgba(230,51,41,.55); text-decoration: none; }
.fab:active { transform: scale(.95); }

/* ============================================================
   LIGHTBOX
   ============================================================ */
.lightbox {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 500;
  align-items: center; justify-content: center; flex-direction: column;
  padding: 1rem;
}
.lightbox.active { display: flex; }
.lightbox-inner { text-align: center; max-width: 95vw; }
.lightbox-inner img {
  max-width: 95vw;
  max-height: 82vh;
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  object-fit: contain;   /* ← garde le ratio, ne découpe pas */
  display: block;
  margin: 0 auto;
}
#lightbox-caption {
  color: rgba(255,255,255,.7);
  margin-top: .75rem;
  font-size: .88rem;
  text-transform: capitalize;
}
.lightbox-close {
  position: fixed; top: 1rem; right: 1rem;
  color: rgba(255,255,255,.6);
  font-size: 1.5rem;
  cursor: pointer;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(255,255,255,.1);
  transition: background var(--transition);
}
.lightbox-close:hover { background: rgba(255,255,255,.2); }

/* ============================================================
   BOUTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--rouge), var(--rouge-d));
  color: var(--blanc);
  box-shadow: 0 2px 8px rgba(230,51,41,.3);
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(230,51,41,.4); text-decoration: none; color: var(--blanc); }

.btn-secondary {
  background: var(--blanc);
  color: var(--rouge);
  border-color: var(--rouge);
}
.btn-secondary:hover { background: var(--rouge-pale); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--gris-tx);
  border-color: var(--gris-bd);
}
.btn-ghost:hover { background: var(--gris-bg); text-decoration: none; color: var(--gris-fonce); }

.btn-full { width: 100%; }

.btn-sm {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gris-bd);
  background: var(--blanc);
  cursor: pointer; font-size: .9rem;
  text-decoration: none; color: var(--gris-tx);
  transition: all var(--transition);
}
.btn-sm:hover { border-color: var(--gris-fonce); color: var(--gris-fonce); text-decoration: none; }
.btn-danger { border-color: #fca5a5; color: #ef4444; }
.btn-danger:hover { background: var(--rouge-pale); border-color: var(--rouge); color: var(--rouge); }

/* ============================================================
   FORMULAIRES
   ============================================================ */
.form-page { padding: .75rem; display: flex; flex-direction: column; gap: 0; }

.form-section {
  background: var(--blanc);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: .75rem;
  box-shadow: var(--ombre-sm);
  border: 1px solid var(--gris-bd);
}

.section-title {
  font-size: .92rem;
  font-weight: 700;
  margin-bottom: .9rem;
  color: var(--gris-fonce);
  display: flex;
  align-items: center;
  gap: .4rem;
}

.form-group { margin-bottom: .8rem; }
.form-group:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--gris-fonce);
}
label small { font-weight: 400; color: var(--gris-tx); }

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: .7rem .85rem;
  border: 1.5px solid var(--gris-bd);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  background: var(--blanc);
  color: var(--gris-fonce);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--rouge);
  box-shadow: 0 0 0 3px rgba(230,51,41,.1);
}
textarea { resize: vertical; min-height: 64px; }
input[type="number"] { font-size: 1.05rem; font-weight: 600; }

.radio-group { display: flex; flex-direction: column; gap: .55rem; }

.radio-label,
.checkbox-label {
  display: flex; align-items: center; gap: .55rem;
  font-weight: 400; cursor: pointer; font-size: .93rem;
  padding: .6rem .8rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gris-bd);
  transition: border-color var(--transition), background var(--transition);
}
.radio-label:hover, .checkbox-label:hover { border-color: var(--rouge); background: var(--rouge-pale); }

input[type="radio"],
input[type="checkbox"] {
  width: 18px; height: 18px; flex-shrink: 0;
  accent-color: var(--rouge);
}
.hint { font-size: .78rem; color: var(--gris-tx); margin-bottom: .5rem; line-height: 1.4; }

/* ---- Upload multi-photos ---- */
.upload-btn {
  width: 100%;
  border: 2px dashed var(--gris-bd);
  border-radius: var(--radius-sm);
  padding: .9rem;
  font-size: .92rem;
  color: var(--gris-tx);
  transition: border-color var(--transition), background var(--transition);
  margin-top: .5rem;
}
.upload-btn:hover { border-color: var(--rouge); background: var(--rouge-pale); color: var(--rouge); }

.upload-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: .5rem;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--gris-bg);
  border: 1.5px solid var(--gris-bd);
  border-radius: var(--radius-sm);
  padding: .5rem .6rem;
  animation: slideIn .2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.upload-thumb {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--gris-bd);
  background: var(--blanc);
  flex-shrink: 0;
}

.upload-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  min-width: 0;
}

.upload-item-name {
  font-size: .75rem;
  color: var(--gris-tx);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-type-sel {
  padding: .35rem .5rem;
  font-size: .84rem;
  border: 1.5px solid var(--gris-bd);
  border-radius: 6px;
  background: var(--blanc);
  color: var(--gris-fonce);
  width: 100%;
}

.upload-remove {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--gris-tx); font-size: .9rem;
  cursor: pointer; border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.upload-remove:hover { background: var(--rouge-pale); color: var(--rouge); }

/* Photos existantes (edit.php) */
.select-type { width: auto; padding: .4rem .65rem; font-size: .84rem; }

/* Photos existantes (edit.php) */
.existing-photos { display: flex; flex-wrap: wrap; gap: .75rem; }
.existing-photo { display: flex; flex-direction: column; gap: .35rem; align-items: flex-start; }
.existing-photo img {
  width: 100px; height: 80px;
  object-fit: contain;  /* ← ratio préservé */
  border-radius: var(--radius-sm); border: 1.5px solid var(--gris-bd);
  background: var(--gris-bg);
}

/* ---- Total en direct ---- */
.total-preview {
  background: linear-gradient(135deg, var(--bleu), #2563a8);
  color: var(--blanc);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: .75rem;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 4px 16px rgba(31,78,120,.3);
}
.total-label  { font-size: .88rem; font-weight: 600; opacity: .85; }
.total-amount { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; }

/* ---- Actions formulaire ---- */
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; padding: .25rem 0 1rem; }

/* ============================================================
   ALERTES
   ============================================================ */
.alert { padding: .85rem 1rem; border-radius: var(--radius-sm); margin: .75rem; font-size: .88rem; }
.alert-error   { background: var(--rouge-pale); color: #7f1d1d; border: 1.5px solid #fca5a5; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1.5px solid #6ee7b7; }
.alert p { margin: .2rem 0; }

/* ============================================================
   ÉTAT VIDE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--gris-tx);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }

/* ============================================================
   RESPONSIVE TABLETTE
   ============================================================ */
@media (min-width: 600px) {
  .summary-cards { grid-template-columns: repeat(3, 1fr); }
  .summary-card--total { grid-column: 1 / -1; }
  .photo-row { flex-direction: row; align-items: flex-start; }
  .file-input { flex: 1; }
  .form-page { max-width: 640px; margin: 0 auto; }
  .entries-list { max-width: 720px; margin: 0 auto; }
  .export-actions { justify-content: flex-end; }
}

@media (min-width: 900px) {
  .summary-cards { grid-template-columns: repeat(6, 1fr); max-width: 900px; margin: 0 auto; }
  .summary-card--total { grid-column: auto; }
}
