/* ═══════════════════════════════════════════════
   HELIX RAPPORT PWA — Styles
   ═══════════════════════════════════════════════ */

:root {
  --petrol-dark:  #0B4F6C;
  --petrol-mid:   #1A7FA8;
  --petrol-light: #A8D8EA;
  --petrol-pale:  #E1F2F8;
  --petrol-bg:    #F0F9FF;
  --white:       #FFFFFF;
  --gray-100:    #F5F7FA;
  --gray-200:    #E9ECF0;
  --gray-400:    #9BA3AF;
  --gray-700:    #374151;
  --green:       #16A34A;
  --green-light: #DCFCE7;
  --orange:      #EA580C;
  --orange-light:#FEF3C7;
  --red:         #DC2626;
  --red-light:   #FEE2E2;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.10);
  --shadow-md:   0 4px 16px rgba(0,0,0,.12);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.18);
  --radius:      12px;
  --radius-sm:   8px;
  --radius-xs:   6px;
  --transition:  .18s ease;

  --header-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ─── Reset & base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: var(--gray-700);
  background: var(--gray-100);
  -webkit-font-smoothing: antialiased;
}
input, button, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }
.hidden { display: none !important; }

/* ─── Screens ─── */
.screen {
  position: fixed; inset: 0;
  display: none; flex-direction: column;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; }

/* ═══════════════════════ LOGIN ═══════════════════════ */
#screen-login {
  background: var(--petrol-dark);
  align-items: center; justify-content: center;
  padding: 24px 20px;
}
.login-container { width: 100%; max-width: 380px; }
.login-logo {
  text-align: center; margin-bottom: 32px;
  color: var(--white);
}
.logo-icon {
  width: 64px; height: 64px; border-radius: 20px;
  background: rgba(255,255,255,.15);
  border: 2px solid rgba(255,255,255,.3);
  font-size: 32px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  color: var(--white);
}
.login-logo h1 { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.login-logo p { font-size: 13px; opacity: .75; }

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
}

/* ─── Form base ─── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--petrol-dark);
  margin-bottom: 6px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--gray-700);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
}
.form-group input:focus {
  border-color: var(--petrol-mid);
  box-shadow: 0 0 0 3px rgba(46,117,182,.15);
}

.pin-input-wrapper { position: relative; }
.pin-input-wrapper input { padding-right: 44px; letter-spacing: .2em; }
.btn-toggle-pin {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 18px; line-height: 1;
  background: none; border: none; padding: 4px;
  color: var(--gray-400);
}

/* ─── Buttons ─── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px;
  background: var(--petrol-dark);
  color: var(--white);
  font-weight: 700; font-size: 15px;
  border-radius: var(--radius-sm);
  border: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(31,78,121,.3);
}
.btn-primary:hover { background: var(--petrol-mid); }
.btn-primary:active { transform: scale(.97); }
.btn-primary.btn-full { width: 100%; }
.btn-primary:disabled { opacity: .6; pointer-events: none; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  background: var(--petrol-pale);
  color: var(--petrol-dark);
  font-weight: 600; font-size: 14px;
  border-radius: var(--radius-sm);
  border: none;
  transition: background var(--transition);
}
.btn-secondary:hover { background: var(--petrol-light); }
.btn-secondary.btn-sm { padding: 8px 14px; font-size: 13px; }

.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 18px;
  color: var(--white);
  transition: background var(--transition);
}
.btn-icon:hover { background: rgba(255,255,255,.15); }

.error-msg {
  background: var(--red-light);
  color: var(--red);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  margin-top: 12px;
}

/* ═══════════════════════ HEADER ═══════════════════════ */
.app-header {
  height: var(--header-h);
  background: var(--petrol-dark);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top, 0px);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(255,255,255,.2);
  font-size: 18px; font-weight: 800; color: var(--white);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.header-title { font-weight: 700; font-size: 15px; color: var(--white); }
.header-sub { font-size: 12px; color: rgba(255,255,255,.7); margin-top: 1px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.header-rep {
  font-size: 12px; font-weight: 600; color: rgba(255,255,255,.85);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ─── Sync bar ─── */
.sync-bar {
  padding: 8px 16px;
  background: var(--green-light);
  color: var(--green);
  font-size: 13px; font-weight: 600;
  text-align: center;
  flex-shrink: 0;
}
.sync-bar.warning { background: var(--orange-light); color: var(--orange); }
.sync-bar.error { background: var(--red-light); color: var(--red); }

/* ═══════════════════════ MAIN CONTENT ═══════════════════════ */
.main-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(80px + var(--safe-bottom));
}

/* ─── Summary ─── */
.summary-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.summary-item { text-align: center; flex: 1; }
.summary-num {
  display: block;
  font-size: 28px; font-weight: 800;
  color: var(--petrol-dark);
  line-height: 1;
}
.summary-label {
  display: block;
  font-size: 11px; font-weight: 600;
  color: var(--gray-400);
  margin-top: 4px;
  text-transform: uppercase; letter-spacing: .05em;
}
.summary-sep { width: 1px; height: 36px; background: var(--gray-200); }

/* ─── Section header ─── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.section-header h2 {
  font-size: 15px; font-weight: 700;
  color: var(--petrol-dark);
  display: flex; align-items: center; gap: 8px;
}
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px;
  background: var(--petrol-mid);
  color: var(--white);
  font-size: 11px; font-weight: 700;
  border-radius: 11px;
  padding: 0 6px;
}

/* ─── Ventes list ─── */
.ventes-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

.vente-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--petrol-mid);
  position: relative;
  animation: slideIn .2s ease;
}
@keyframes slideIn { from { opacity:0; transform: translateY(-8px); } to { opacity:1; transform: translateY(0); } }

.vente-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 8px;
}
.vente-compte {
  font-weight: 700; font-size: 15px;
  color: var(--petrol-dark);
}
.vente-client { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.vente-actions { display: flex; gap: 6px; }
.btn-vente-action {
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.btn-edit { color: var(--petrol-mid); }
.btn-edit:hover { background: var(--petrol-pale); }
.btn-delete { color: var(--red); }
.btn-delete:hover { background: var(--red-light); }

.vente-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pill {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 700;
  background: var(--petrol-pale);
  color: var(--petrol-dark);
}
.pill.pill-acq { background: #DCFCE7; color: #166534; }
.pill.pill-mig { background: #FEF3C7; color: #92400E; }
.pill.pill-tv  { background: #EDE9FE; color: #5B21B6; }
.pill.pill-int { background: #DBEAFE; color: #1E40AF; }
.pill.pill-tmo { background: #FFE4E6; color: #9F1239; }

.vente-dates { font-size: 12px; color: var(--gray-400); }
.vente-services { font-size: 12px; color: var(--gray-700); margin-top: 4px; font-style: italic; }

/* ─── Btn ajouter ─── */
.btn-add {
  width: 100%;
  padding: 16px;
  border: 2px dashed var(--petrol-light);
  border-radius: var(--radius);
  background: var(--petrol-bg);
  color: var(--petrol-mid);
  font-weight: 600; font-size: 15px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: all var(--transition);
}
.btn-add:hover { border-color: var(--petrol-mid); background: var(--petrol-pale); }
.btn-add-icon {
  width: 28px; height: 28px;
  background: var(--petrol-mid);
  color: var(--white);
  border-radius: 50%;
  font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* ═══════════════════════ MODAL ═══════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end;
  z-index: 1000;
  backdrop-filter: blur(2px);
  padding: 0;
}
.modal-overlay.active { display: flex; }

.modal-card {
  background: var(--white);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 600px; margin: 0 auto;
  max-height: 92vh;
  display: flex; flex-direction: column;
  animation: slideUp .25s ease;
  padding-bottom: var(--safe-bottom);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 17px; font-weight: 700; color: var(--petrol-dark); }
.modal-header .btn-icon { color: var(--gray-400); }
.modal-header .btn-icon:hover { background: var(--gray-100); }

.modal-body {
  flex: 1; overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
}

/* ─── Form layout ─── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .form-row { grid-template-columns: 1fr; } }

.required { color: var(--red); }
.hint { font-weight: 400; color: var(--gray-400); font-size: 11px; }

/* ─── Toggle pills ─── */
.toggle-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle-pill {
  display: flex; align-items: center; justify-content: center;
  padding: 8px 16px;
  border-radius: 24px;
  border: 2px solid var(--gray-200);
  background: var(--gray-100);
  font-weight: 700; font-size: 14px;
  color: var(--gray-400);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.toggle-pill input { display: none; }
.toggle-pill.checked { border-color: transparent; color: var(--white); }
.toggle-pill#pill-acq.checked { background: #16A34A; }
.toggle-pill#pill-mig.checked { background: #D97706; }
.toggle-pill#pill-tv.checked  { background: #7C3AED; }
.toggle-pill#pill-int.checked { background: #2563EB; }
.toggle-pill#pill-tmo.checked { background: #E11D48; }

/* ─── Select forfaits ─── */
.form-select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 15px; background: var(--white);
  color: var(--text); appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231F4E79' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px; cursor: pointer;
}
.form-select:focus { outline: none; border-color: var(--primary); }

/* ─── TMO numérique ─── */
.tmo-group { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 2px solid var(--border); border-radius: 20px; background: var(--white); }
.tmo-label { font-size: 14px; font-weight: 600; color: #9F1239; }
.tmo-input { width: 48px; border: none; outline: none; font-size: 16px; font-weight: 700; color: #9F1239; text-align: center; background: transparent; }

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%);
  min-width: 240px; max-width: 90vw;
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--gray-700);
  color: var(--white);
  font-size: 14px; font-weight: 500;
  text-align: center;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  animation: fadeInToast .2s ease;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes fadeInToast { from { opacity:0; transform: translateX(-50%) translateY(10px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--petrol-light); border-radius: 4px; }

/* ─── Empty state ─── */
.empty-state {
  text-align: center; padding: 32px 20px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── Password rules ─── */
.pw-rules {
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.pw-rule { font-size: 13px; font-weight: 500; color: var(--gray-400); transition: color var(--transition); }
.pw-rule.ok { color: var(--green); }

.btn-link {
  display: block; text-align: center; margin-top: 12px;
  font-size: 13px; color: var(--gray-400); text-decoration: underline;
  background: none; border: none; cursor: pointer; width: 100%;
}
.btn-link:hover { color: var(--petrol-mid); }

/* ─── Desktop ─── */
@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .modal-card { border-radius: var(--radius); max-height: 85vh; }
  .main-content { padding: 24px; max-width: 640px; margin: 0 auto; width: 100%; }
}

/* ── Proxy rep banner ── */
.proxy-banner {
  background: #FFF8E1;
  border: 1.5px solid #F59E0B;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.proxy-banner-label {
  font-size: 13px;
  font-weight: 600;
  color: #92400E;
  margin-bottom: 8px;
}
.proxy-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #D97706;
  border-radius: 7px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  appearance: auto;
}
.proxy-select:focus {
  outline: none;
  border-color: var(--petrol-dark);
  box-shadow: 0 0 0 2px rgba(11,79,108,.15);
}
.proxy-active-badge {
  display: inline-block;
  background: #F59E0B;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: 6px;
  vertical-align: middle;
}

