/* ===================================
   OPTIMUSCLE — Reusable Components
   =================================== */

/* HEADER */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 20px var(--accent-glow);
  position: relative;
  overflow: hidden;
}

.logo-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,.2) 100%);
}

.logo-icon svg { position: relative; z-index: 1; }

.logo-text {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  letter-spacing: 0.05em;
  line-height: 1;
}

.logo-text span { color: var(--accent); }

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.header-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .2s;
}

.header-btn:active {
  transform: scale(.92);
  background: var(--card-2);
}

/* User avatar */
.user-avatar,
.user-avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  transition: transform .2s;
}

.user-avatar { object-fit: cover; }

.user-avatar-placeholder {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  color: white;
}

.user-avatar:active,
.user-avatar-placeholder:active { transform: scale(.92); }

/* PAGES */
.page {
  display: none;
  padding: 0 0 24px;
  animation: fade .4s ease;
}
.page.active { display: block; }
.container { padding: 0 20px; }

/* BUTTONS */
.btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: all .2s;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: white;
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-primary::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left .5s;
}

.btn-primary:active { transform: scale(.98); }
.btn-primary:active::after { left: 100%; }
.btn-primary:disabled {
  opacity: .4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-row {
  display: flex;
  gap: 10px;
}

/* TABS */
nav.tabs {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 100;
}

.tab {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 8px 14px;
  font-family: inherit;
  transition: color .2s;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  position: relative;
}

.tab.active { color: var(--accent); }

.tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
  box-shadow: 0 0 8px var(--accent);
}

.tab svg { width: 22px; height: 22px; }

/* SWITCH */
.switch {
  position: relative;
  width: 44px;
  height: 24px;
}

.switch input { display: none; }

.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--bg-2);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  cursor: pointer;
  transition: .3s;
}

.switch .slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  top: 3px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: .3s;
}

.switch input:checked + .slider {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
  background: white;
}

.time-input {
  background: var(--bg-2);
  border: 1px solid var(--border-light);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color-scheme: dark;
}

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
  animation: fade .25s;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 24px 22px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  animation: pop .35s var(--ease-out);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  margin-bottom: 6px;
}

.modal p {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 18px;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  padding: 14px 22px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  box-shadow: 0 12px 32px var(--accent-glow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
  z-index: 200;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-10px);
}

/* EMPTY STATE */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* STATS CARDS */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 8px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.6;
}

.stat-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  color: white;
  line-height: 1;
}

.stat-label {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

/* SECTION TITLE */
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  margin-top: 24px;
}

.section-title h2 { margin: 0; }

/* PROFILE CARD */
.profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px 18px;
  margin-bottom: 16px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

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

.profile-row span:first-child {
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.profile-row span:last-child { font-weight: 700; }

/* ============================================
   FIX FLOW : Une seule page à la fois (strict)
   ============================================ */
.page:not(.active) {
  display: none !important;
  visibility: hidden !important;
}

.page.active {
  display: block !important;
  visibility: visible !important;
}

/* La page de login doit pouvoir être cachée */
#page-login.hidden,
#page-login[style*="display: none"] {
  display: none !important;
}
