/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:   #2563eb;
  --primary-h: #1d4ed8;
  --success:   #16a34a;
  --success-h: #15803d;
  --danger:    #dc2626;
  --bg:        #f8fafc;
  --card:      #ffffff;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --muted:     #64748b;
  --radius:    12px;
  --shadow:    0 2px 8px rgba(0,0,0,.08);
  --header-h:  54px;
  --steps-h:   52px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 0 1rem;
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
}

.app-header .logo-icon { font-size: 1.3rem; }
.app-title { font-weight: 700; font-size: 1.1rem; flex: 1; text-align: center; }

.logout-btn {
  font-size: .8rem;
  color: rgba(255,255,255,.85);
  text-decoration: none;
  border: 1px solid rgba(255,255,255,.4);
  padding: .25rem .6rem;
  border-radius: 6px;
}

/* ── Steps bar ── */
.steps-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  height: var(--steps-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: var(--header-h); left: 0; right: 0;
  z-index: 9;
  padding: 0 2rem;
}

.step {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .3s, color .3s;
}

.step.active {
  background: var(--primary);
  color: #fff;
}

.step.done {
  background: var(--success);
  color: #fff;
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  transition: background .3s;
}

.step-line.done { background: var(--success); }

/* ── Step pages ── */
.step-page {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: calc(var(--header-h) + var(--steps-h));
  left: 0; right: 0; bottom: 0;
  padding: 1.5rem 1rem;
  overflow-y: auto;
}

.step-page.active { display: flex; }

.step-title {
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: .35rem;
}

.step-subtitle {
  color: var(--muted);
  font-size: .95rem;
  text-align: center;
  margin-bottom: 2rem;
}

/* ── Étape 1 : boutons ── */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 380px;
}

.btn-action {
  padding: 1.3rem 1.2rem;
  font-size: 1.1rem;
  border-radius: var(--radius);
  width: 100%;
}

.btn-icon { font-size: 1.5rem; margin-right: .25rem; }

/* ── Select + bouton ajout catégorie ── */
select {
  flex: 1;
  padding: .75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text);
  background: var(--card);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
}

select:focus { outline: none; border-color: var(--primary); }

.select-row {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.btn-add-cat {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  background: transparent;
  color: var(--primary);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Modal preview ticket ── */
.modal-fullscreen .modal-preview-box {
  width: 100%;
  height: 100%;
  max-width: 100%;
  background: #111;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

.modal-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: #1e293b;
  flex-shrink: 0;
}

.modal-preview-title {
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
}

.btn-close {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover { background: rgba(255,255,255,.25); }

.modal-preview-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: .5rem;
}

.modal-preview-body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.modal-preview-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Modal nouvelle catégorie ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  padding: 1.5rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: .6rem;
}

.modal-actions .btn { flex: 1; }

/* ── Étape 2 : spinner ── */
.spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.spinner {
  width: 56px;
  height: 56px;
  border: 5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Étape 3 : formulaire ── */
#step-3 {
  justify-content: flex-start;
  padding-top: 1.5rem;
}

.form-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  margin-bottom: 1rem;
}

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-preview-inline {
  padding: .2rem .6rem;
  font-size: .78rem;
  font-weight: 500;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  transition: background .15s;
}

.btn-preview-inline:hover { background: var(--border); }

.form-actions {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  width: 100%;
  max-width: 480px;
}

/* ── Étape 4 : confirmation ── */
.confirm-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.confirm-icon { font-size: 4rem; }
.confirm-title { font-size: 1.4rem; font-weight: 700; }
.confirm-sub { color: var(--muted); font-size: .95rem; margin-bottom: .5rem; }

/* ── Buttons ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .9rem 1.2rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover { background: var(--primary-h); }

.btn-secondary { background: #f1f5f9; color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }

.btn-success   { background: var(--success);   color: #fff; }
.btn-success:hover { background: var(--success-h); }

.btn-ghost { background: transparent; color: var(--muted); font-weight: 500; }
.btn-ghost:hover { color: var(--text); }

.btn-full { width: 100%; }

/* ── Form fields ── */
.field { display: flex; flex-direction: column; gap: .35rem; }

label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

input[type="text"],
input[type="password"],
input[type="date"] {
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  transition: border-color .15s;
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Alerts ── */
.alert {
  padding: .8rem 1rem;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  width: 100%;
  max-width: 480px;
  margin-top: .5rem;
}

.alert-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

/* ── Login ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  overflow: auto;
}

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

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

.login-logo-img { width: 72px; height: 72px; border-radius: 16px; margin-bottom: .5rem; }

.login-logo h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: .4rem;
}

.logo-icon { font-size: 2.5rem; }

.login-form { display: flex; flex-direction: column; gap: 1rem; }

/* ── Burger button ── */
.burger-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: .4rem .3rem;
  margin-left: auto;
  -webkit-tap-highlight-color: transparent;
}

.burger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
}

/* ── Menu slide-in ── */
.menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
}

.menu-overlay.open { display: block; }

.menu-panel {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 260px;
  background: var(--card);
  box-shadow: 4px 0 16px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .25s ease;
}

.menu-overlay.open .menu-panel { transform: translateX(0); }

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
}

.menu-logo { font-size: .95rem; font-weight: 700; }
.menu-logo-img { width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0; }

.btn-close-menu {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: .85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-menu:hover { background: rgba(255,255,255,.28); }

.menu-list {
  list-style: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: .5rem 0;
}

.menu-list-bottom { margin-top: auto; }

.menu-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: 1rem 1.25rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}

.menu-item:hover { background: var(--bg); }

.menu-item-icon { font-size: 1.2rem; }

.menu-item-logout {
  color: var(--danger);
  border-top: 1px solid var(--border);
}

/* ── Vue récap (fenêtre principale, remplace les étapes) ── */
#view-recap {
  display: none;
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  background: var(--bg);
  padding: 1rem;
  z-index: 5;
}

#view-recap.active { display: block; }

.steps-bar.hidden { display: none; }

/* ── Onglets récap ── */
.recap-tabs {
  display: flex;
  gap: .35rem;
  background: var(--card);
  border-radius: var(--radius);
  padding: .3rem;
  box-shadow: var(--shadow);
  margin-bottom: .75rem;
}

.recap-tab {
  flex: 1;
  padding: .5rem .25rem;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}

.recap-tab.active {
  background: var(--primary);
  color: #fff;
}

.recap-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 3rem 0;
  width: 100%;
}

.recap-error, .recap-empty {
  color: var(--muted);
  text-align: center;
  padding: 2rem 1rem;
  font-size: .95rem;
}

.recap-error { color: var(--danger); }

/* Total card */
.recap-total-card {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  margin-bottom: .75rem;
}

.recap-total-amount {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.recap-total-sub {
  font-size: .9rem;
  opacity: .85;
  margin-top: .3rem;
}

/* Section card */
.recap-section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: .75rem;
}

.recap-section-title {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .9rem;
}

.recap-month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .9rem;
}

.recap-month-header .recap-section-title { margin-bottom: 0; }

.recap-month-total {
  font-size: .85rem;
  font-weight: 700;
  color: var(--primary);
}

/* Catégories */
.recap-cat-list { display: flex; flex-direction: column; gap: .8rem; }

.recap-cat-row { display: flex; flex-direction: column; gap: .3rem; }

.recap-cat-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.recap-cat-name { font-size: .95rem; font-weight: 500; }
.recap-cat-amount { font-size: .9rem; font-weight: 700; color: var(--primary); }

.recap-bar-bg {
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.recap-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
}

/* Tickets */
.recap-tickets { display: flex; flex-direction: column; }

.recap-ticket-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem 0;
  border-bottom: 1px solid var(--border);
}

.recap-ticket-row:last-child { border-bottom: none; }

.recap-ticket-info {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  flex: 1;
  min-width: 0;
}

.recap-ticket-magasin {
  font-size: .95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recap-ticket-meta {
  font-size: .78rem;
  color: var(--muted);
}

.recap-ticket-right {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
  margin-left: .75rem;
}

.recap-ticket-amount {
  font-size: .95rem;
  font-weight: 700;
  white-space: nowrap;
}

.date-wrap {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.date-wrap input[type="text"] { flex: 1; }

.btn-calendar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
}

.btn-calendar {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-calendar:hover { background: var(--border); border-color: var(--primary); }

.btn-calendar-wrap input[type="date"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: -1;
}

.btn-ticket-preview {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: .85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}

.btn-ticket-preview:hover {
  background: var(--border);
  border-color: var(--primary);
}
