/* ============================================================
   IPC France Literie — Neumorphic Dark CSS
   Palette : brun foncé + chartreuse
   ============================================================ */

/* ---- Tokens ---- */
:root {
  --bg:           #1e1510;
  --bg-card:      #231a13;
  --bg-raised:    #2a1f17;
  --bg-input:     #1a1109;
  --shadow-dark:  #120c07;
  --shadow-light: #312418;
  --accent:       #C8D400;
  --accent-dark:  #9ea900;
  --accent-hover: #d9e600;
  --text-main:    #F0E8D8;
  --text-muted:   #a08060;
  --text-dim:     #6a5040;
  --border:       rgba(255,255,255,0.06);
  --danger:       #e05050;
  --success:      #5db85d;
  --radius:       14px;
  --radius-sm:    8px;
  --radius-lg:    20px;
  --transition:   0.2s ease;

  /* Neumorphic shadows */
  --nm-inset:  inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
  --nm-raised: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
  --nm-card:   6px 6px 16px var(--shadow-dark), -6px -6px 16px var(--shadow-light);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100dvh;
  overscroll-behavior: none;
}

/* ---- Screens ---- */
.screen { display: none; }
.screen.active, .screen:not(.hidden) { display: block; }
.hidden { display: none !important; }

/* ============================================================
   LOGIN
   ============================================================ */
#loginScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--nm-card);
  padding: 40px 32px 32px;
  border: 1px solid var(--border);
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.login-logo svg { width: 140px; height: auto; }

.login-title {
  text-align: center;
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  margin-bottom: 32px;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
}
.login-footer a {
  color: var(--text-dim);
  font-size: 0.72rem;
  text-decoration: none;
}
.login-footer a:hover { color: var(--text-muted); }

/* ============================================================
   APP LAYOUT
   ============================================================ */
#appScreen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
#appScreen.hidden { display: none !important; }

/* ---- Header ---- */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow-dark);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-brand svg { width: 70px; height: auto; }
.header-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.15em;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.header-magasin {
  background: var(--bg-raised);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.75rem;
  color: var(--accent);
  border: 1px solid var(--accent-dark);
}

/* ---- Tab bar ---- */
.tab-bar {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn svg { width: 18px; height: 18px; }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-btn:hover:not(.active) { color: var(--text-muted); }

/* ---- Tab content ---- */
.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.tab-content.hidden { display: none !important; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--nm-card);
  border: 1px solid var(--border);
  padding: 20px 16px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-bottom: 18px;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-header-row .card-title { margin-bottom: 0; }

/* ============================================================
   FORMS
   ============================================================ */
.form-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  letter-spacing: 0.04em;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input[type="text"],
input[type="tel"],
input[type="date"],
input[type="number"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--nm-inset);
  color: var(--text-main);
  font-size: 0.9rem;
  padding: 10px 12px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-dark);
  box-shadow: var(--nm-inset), 0 0 0 2px rgba(200,212,0,0.15);
}
select option { background: var(--bg-card); color: var(--text-main); }
textarea { resize: vertical; min-height: 72px; }

/* intl-tel-input overrides */
.iti { width: 100%; }
.iti__selected-flag { background: var(--bg-input) !important; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.iti__country-list { background: var(--bg-card); border-color: var(--border); color: var(--text-main); }
.iti__country.iti__highlight { background: var(--bg-raised); }

/* ---- Profil buttons ---- */
.profil-btns {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.profil-btn {
  flex: 1;
  padding: 10px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  box-shadow: var(--nm-raised);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.profil-btn.active {
  background: var(--accent);
  color: #1e1510;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(200,212,0,0.3);
}

/* ---- Toggle rows ---- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 10px 12px;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.toggle-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
}
.toggle-btns {
  display: flex;
  gap: 6px;
}
.toggle-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.toggle-btn.active {
  background: var(--accent);
  color: #1e1510;
  border-color: var(--accent);
}

.sub-section {
  padding: 12px;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 20px;
  background: var(--accent);
  color: #1e1510;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(200,212,0,0.25);
  transition: all var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary svg { width: 18px; height: 18px; }
.btn-full { width: 100%; margin-top: 20px; }

.btn-secondary {
  padding: 10px 20px;
  background: var(--bg-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover { color: var(--text-main); border-color: var(--text-dim); }

.btn-danger {
  padding: 10px 20px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-danger:hover { background: #c03030; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}
.btn-icon svg { width: 20px; height: 20px; }
.btn-icon:hover { color: var(--accent); }

.btn-sm {
  padding: 7px 14px;
  background: var(--accent);
  color: #1e1510;
  border: none;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-sm:hover { background: var(--accent-hover); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert-error {
  background: rgba(224,80,80,0.12);
  border: 1px solid rgba(224,80,80,0.4);
  color: #f08080;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.82rem;
  margin-top: 10px;
}
.alert-success {
  background: rgba(93,184,93,0.12);
  border: 1px solid rgba(93,184,93,0.4);
  color: #80d880;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.82rem;
  margin-top: 10px;
  text-align: center;
}

/* ============================================================
   IPC LIST
   ============================================================ */
.loading-msg, .empty-msg {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 24px 0;
}

.filters-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}
.filter-select {
  flex: 1;
  min-width: 130px;
  padding: 8px 10px;
  font-size: 0.82rem;
}

.ipc-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ipc-item {
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ipc-item-left { flex: 1; min-width: 0; }

.ipc-item-date {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.ipc-item-client {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ipc-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ipc-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.badge-promeneur { background: rgba(106,80,64,0.4); color: var(--text-dim); }
.badge-prospect  { background: rgba(200,212,0,0.15); color: var(--accent); border: 1px solid rgba(200,212,0,0.3); }
.badge-client    { background: rgba(200,212,0,0.25); color: var(--accent); border: 1px solid rgba(200,212,0,0.5); }
.badge-devis     { background: rgba(93,184,93,0.15); color: #80d880; }

.ipc-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}
.btn-edit, .btn-delete {
  padding: 5px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.btn-edit { background: rgba(200,212,0,0.1); color: var(--accent); }
.btn-edit:hover { background: rgba(200,212,0,0.25); }
.btn-delete { background: rgba(224,80,80,0.1); color: var(--danger); }
.btn-delete:hover { background: rgba(224,80,80,0.25); }
.btn-edit svg, .btn-delete svg { width: 15px; height: 15px; }

/* ============================================================
   KPI STATS GRID
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.kpi-card {
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--nm-raised);
  padding: 14px 12px;
  text-align: center;
}
.kpi-card.accent {
  border-color: rgba(200,212,0,0.3);
  box-shadow: var(--nm-raised), 0 0 12px rgba(200,212,0,0.1);
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
  margin-bottom: 5px;
}
.kpi-card.accent .kpi-value { color: var(--accent); }

.kpi-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 20px; }
}

.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--border);
  box-shadow: var(--nm-card);
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
}
@media (min-width: 600px) {
  .modal-box { border-radius: var(--radius-lg); }
}
.modal-box-sm { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { color: var(--text-main); }

.modal-body {
  padding: 18px 20px;
}
.modal-body p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg-raised); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============================================================
   RESPONSIVE — iPad optimisé
   ============================================================ */
@media (min-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .login-card { padding: 48px 40px 36px; }
  .card { padding: 24px 20px; }
  .tab-content { padding: 20px; }
}

@media (min-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  #tabSaisie .card { max-width: 680px; margin: 0 auto; }
}
