/* Design repris du prototype cliquable validé (design/technicien-app/Main.dc.html) :
   police Sora, tokens de couleur, cartes arrondies, barre d'onglets basse. */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&display=swap');

:root {
  --accent: #2f5fd1;
  --accent-dark: #24499f;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --text: #1c2233;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --success: #17a673;
  --warning: #d98c1c;
  --danger: #dc4c4c;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(20, 25, 45, 0.06), 0 8px 24px rgba(20, 25, 45, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.screen { display: none; flex-direction: column; flex: 1; min-height: 0; }
.screen.active { display: flex; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  gap: 12px;
}
.topbar h1 { font-size: 20px; font-weight: 700; margin: 0; }
.topbar .sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.icon-btn {
  border: none; background: var(--surface); width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
  color: var(--text); cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }

.content { flex: 1; overflow-y: auto; padding: 0 20px 90px; -webkit-overflow-scrolling: touch; }

.card {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px; cursor: pointer; border: 1px solid transparent;
}
.card:active { border-color: var(--accent); }
.card-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-title { font-weight: 700; font-size: 15px; margin: 0 0 4px; }
.card-meta { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.badge {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  background: #eef1fb; color: var(--accent);
}
.badge.warning { background: #fdf2e2; color: var(--warning); }
.badge.success { background: #e6f7f1; color: var(--success); }
.badge.danger { background: #fbe9e9; color: var(--danger); }

.tabs {
  position: sticky; top: 0; z-index: 2; display: flex; gap: 8px; padding: 0 20px 14px; background: var(--bg);
}
.tab-chip {
  border: none; background: var(--surface); padding: 8px 14px; border-radius: 999px; font-family: inherit;
  font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.tab-chip.active { background: var(--accent); color: #fff; }

.tabbar {
  position: sticky; bottom: 0; display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}
.tabbar button {
  flex: 1; border: none; background: none; display: flex; flex-direction: column; align-items: center;
  gap: 4px; font-family: inherit; font-size: 11px; font-weight: 600; color: var(--text-muted); cursor: pointer;
  padding: 4px;
}
.tabbar button.active { color: var(--accent); }
.tabbar svg { width: 22px; height: 22px; }
.tabbar .dot {
  position: absolute; margin-left: 14px; margin-top: -2px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--surface);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none;
  border-radius: var(--radius-md); padding: 14px 18px; font-family: inherit; font-weight: 700;
  font-size: 15px; cursor: pointer; width: 100%;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: #fbe9e9; color: var(--danger); }
.btn:disabled { opacity: 0.5; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px;
  font-family: inherit; font-size: 15px; background: var(--surface); color: var(--text);
}
.field textarea { min-height: 96px; resize: vertical; }

.login-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px; gap: 22px; }
.login-logo { width: 64px; height: 64px; border-radius: 18px; background: var(--accent); display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.login-logo svg { width: 32px; height: 32px; color: #fff; }
.login-title { text-align: center; font-size: 22px; font-weight: 800; margin: 0; }
.login-sub { text-align: center; color: var(--text-muted); font-size: 14px; margin-top: -12px; }
.error-msg { background: #fbe9e9; color: var(--danger); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; }
.hint-msg { color: var(--text-muted); font-size: 13px; text-align: center; }

.detail-header { padding: 4px 0 14px; }
.detail-section { margin-bottom: 18px; }
.detail-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 0 0 8px; }
.file-chip { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); text-decoration: none; color: var(--text); }
.file-chip svg { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; }

.sticky-footer { position: sticky; bottom: 0; background: var(--bg); padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 16px -12px rgba(0,0,0,0.15); }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.photo-thumb { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--border); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .remove { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,0.55); color: #fff; border: none; display: flex; align-items: center; justify-content: center; }
.photo-add { aspect-ratio: 1; border-radius: var(--radius-sm); border: 2px dashed var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-muted); background: var(--surface); }

.signature-pad-wrap { background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow); padding: 10px; }
.signature-pad-wrap canvas { width: 100%; height: 160px; touch-action: none; border-radius: var(--radius-sm); background: #fbfbfd; display: block; }
.signature-actions { display: flex; justify-content: flex-end; padding-top: 8px; }
.link-btn { border: none; background: none; color: var(--accent); font-family: inherit; font-weight: 600; font-size: 13px; cursor: pointer; }

.star-row { display: flex; gap: 6px; }
.star-row button { border: none; background: none; padding: 0; cursor: pointer; }
.star-row svg { width: 30px; height: 30px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #1c2233; color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow); z-index: 20;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.toast.show { opacity: 1; }

.empty-state { text-align: center; color: var(--text-muted); padding: 60px 20px; font-size: 14px; }

.offline-banner {
  background: var(--warning); color: #fff; text-align: center; font-size: 12px; font-weight: 600;
  padding: 6px; display: none;
}
.offline-banner.show { display: block; }

.spinner {
  width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.4);
  border-top-color: #fff; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.profile-row { display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; flex-shrink: 0; }
