/* =============================================
   GARAGE PRO v3.0 - Design System
   Style: Apple / Samsung One UI
   ============================================= */

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

:root {
  --c-bg:        #f2f2f7;
  --c-surface:   #ffffff;
  --c-surface2:  #f9f9fb;
  --c-border:    #e4e4e8;
  --c-text:      #1c1c1e;
  --c-text2:     #6c6c70;
  --c-text3:     #aeaeb2;
  --c-blue:      #007aff;
  --c-blue-dark: #0060df;
  --c-green:     #34c759;
  --c-orange:    #ff9500;
  --c-red:       #ff3b30;
  --c-gold:      #c9a84c;

  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  20px;

  --sh-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --sh-md: 0 4px 16px rgba(0,0,0,.10);
  --sh-lg: 0 12px 40px rgba(0,0,0,.14);

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--c-blue); text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

/* --- LAYOUT --- */
.app-wrap {
  min-height: 100vh;
  padding-top: 60px; /* header height */
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

.page-body {
  padding: 24px 16px;
  max-width: 1100px;
  margin: 0 auto;
}

/* --- HEADER --- */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--c-border);
  z-index: 900;
  display: flex;
  align-items: center;
}

.header-inner {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: -0.5px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.header-logo .logo-icon {
  width: 30px;
  height: 30px;
  background: var(--c-text);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* --- GLOBAL SEARCH --- */
.header-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.search-field {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  background: var(--c-bg);
  border: 1.5px solid var(--c-border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--c-text);
  transition: border-color .2s, box-shadow .2s, background .2s;
  outline: none;
}

.search-field::placeholder { color: var(--c-text3); }

.search-field:focus {
  background: var(--c-surface);
  border-color: var(--c-blue);
  box-shadow: 0 0 0 3px rgba(0,122,255,.12);
}

.search-ico {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-text3);
  pointer-events: none;
}

/* DROPDOWN AUTOSUGGEST */
.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  overflow: hidden;
  z-index: 1000;
}
.search-dropdown.open { display: block; }

.sd-group-label {
  padding: 8px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--c-text3);
}

.sd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .15s;
}
.sd-item:hover { background: var(--c-bg); }

.sd-item-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--c-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sd-item-text { min-width: 0; }
.sd-item-title { font-size: 14px; font-weight: 500; color: var(--c-text); }
.sd-item-sub { font-size: 12px; color: var(--c-text2); }

.sd-empty {
  padding: 20px;
  text-align: center;
  color: var(--c-text3);
  font-size: 14px;
}

.sd-loading {
  padding: 20px;
  text-align: center;
  color: var(--c-text3);
  font-size: 14px;
}

/* HEADER RIGHT */
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-user {
  font-size: 13px;
  color: var(--c-text2);
  display: none;
}
@media(min-width:640px){ .header-user { display: block; } }

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text2);
  transition: all .2s;
}
.btn-logout:hover { background: var(--c-bg); color: var(--c-red); border-color: var(--c-red); }

/* --- NAV TABS --- */
.nav-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--c-surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  box-shadow: var(--sh-sm);
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-tab {
  flex: 1;
  min-width: max-content;
  padding: 8px 16px;
  border-radius: var(--r-md);
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text2);
  text-align: center;
  transition: all .2s;
  text-decoration: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.nav-tab.active, .nav-tab:hover {
  background: var(--c-blue);
  color: #fff;
}

/* --- PAGE HEADER --- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: var(--c-text);
}

.page-subtitle {
  font-size: 14px;
  color: var(--c-text2);
  margin-top: 2px;
}

/* --- STATS ROW --- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media(min-width:640px){ .stats-row { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--sh-sm);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--c-text2);
  font-weight: 500;
}

.stat-icon {
  font-size: 20px;
  margin-bottom: 8px;
}

/* --- CARDS GRID 2-COL --- */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media(min-width:480px){ .cards-grid { grid-template-columns: repeat(2, 1fr); } }
@media(min-width:900px){ .cards-grid { grid-template-columns: repeat(2, 1fr); } }

/* VEHICLE CARD */
.v-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--sh-sm);
  transition: box-shadow .25s, transform .25s;
  display: flex;
  flex-direction: column;
}
.v-card:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }

.v-card-img {
  aspect-ratio: 16/9;
  background: var(--c-bg);
  overflow: hidden;
  position: relative;
}
.v-card-img img { width: 100%; height: 100%; object-fit: cover; }
.v-card-img-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px;
  color: var(--c-border);
}

.v-card-badge {
  position: absolute;
  top: 10px; right: 10px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(10px);
}
.badge-en-cours  { background: rgba(255,149,0,.9);  color: #fff; }
.badge-termine   { background: rgba(52,199,89,.9);  color: #fff; }
.badge-attente   { background: rgba(108,108,112,.7); color: #fff; }

.v-card-body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.v-card-immat { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.v-card-model { font-size: 13px; color: var(--c-text2); }

.v-card-actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 14px;
}

/* --- CLIENT CARD --- */
.client-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: 16px;
  box-shadow: var(--sh-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow .25s, transform .25s;
}
.client-card:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }

.client-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.client-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--c-bg);
  border: 1.5px solid var(--c-border);
  overflow: hidden;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.client-avatar img { width: 100%; height: 100%; object-fit: cover; }

.client-info { min-width: 0; }
.client-name { font-size: 15px; font-weight: 600; }
.client-email { font-size: 12px; color: var(--c-text2); }

.client-badge {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--c-bg);
  color: var(--c-text2);
  white-space: nowrap;
}
.client-badge.premium { background: rgba(201,168,76,.15); color: var(--c-gold); }

.client-stats {
  display: flex;
  gap: 16px;
}
.client-stat { font-size: 12px; color: var(--c-text2); }
.client-stat strong { color: var(--c-text); }

.client-card-actions { display: flex; gap: 8px; }

/* --- BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
  text-decoration: none;
}

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

.btn-success   { background: var(--c-green); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }

.btn-danger    { background: rgba(255,59,48,.1); color: var(--c-red); border: 1.5px solid rgba(255,59,48,.2); }
.btn-danger:hover { background: var(--c-red); color: #fff; }

.btn-ghost     { background: var(--c-bg); color: var(--c-text); border: 1.5px solid var(--c-border); }
.btn-ghost:hover { background: var(--c-border); }

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: var(--r-sm); }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: var(--r-sm); }
.btn-full { width: 100%; }

/* --- FORMS --- */
.form-section { margin-bottom: 24px; }
.form-section-title { font-size: 13px; font-weight: 700; color: var(--c-text2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; }

.form-grid { display: grid; gap: 14px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
@media(max-width:480px){ .form-grid-2 { grid-template-columns: 1fr; } }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--c-text); }
.form-label .req { color: var(--c-red); }

.form-control {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  background: var(--c-bg);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  font-size: 15px;
  color: var(--c-text);
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.form-control::placeholder { color: var(--c-text3); }
.form-control:focus {
  background: var(--c-surface);
  border-color: var(--c-blue);
  box-shadow: 0 0 0 3px rgba(0,122,255,.12);
}
textarea.form-control { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
select.form-control { appearance: none; -webkit-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 fill='%236c6c70' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }

/* PIECE SELECTOR */
.pieces-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.piece-row {
  display: grid;
  grid-template-columns: 1fr 80px 34px;
  gap: 8px;
  align-items: center;
}

/* ALERT STOCK */
.stock-alert {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--c-red);
  background: rgba(255,59,48,.08);
  padding: 2px 8px;
  border-radius: 20px;
}

/* --- MODAL --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
}
@media(min-width:640px){ .modal-overlay { align-items: center; } }
.modal-overlay.open { display: flex; }

.modal-sheet {
  background: var(--c-surface);
  width: 100%;
  max-width: 520px;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  max-height: 95vh;
  overflow-y: auto;
  animation: slideUp .3s cubic-bezier(.25,.46,.45,.94);
}
@media(min-width:640px){
  .modal-sheet { border-radius: var(--r-xl); animation: scaleIn .25s cubic-bezier(.25,.46,.45,.94); }
}

@keyframes slideUp   { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes scaleIn   { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-handle {
  width: 36px; height: 4px;
  background: var(--c-border);
  border-radius: 2px;
  margin: 10px auto 0;
  display: block;
}
@media(min-width:640px){ .modal-handle { display: none; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--c-border);
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--c-bg);
  border: none;
  font-size: 16px;
  color: var(--c-text2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--c-border); display: flex; gap: 10px; }

/* --- TABLE --- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--c-border); box-shadow: var(--sh-sm); }
.gp-table { width: 100%; border-collapse: collapse; background: var(--c-surface); }
.gp-table thead { background: var(--c-bg); }
.gp-table th { padding: 12px 14px; text-align: left; font-size: 12px; font-weight: 700; color: var(--c-text2); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--c-border); white-space: nowrap; }
.gp-table td { padding: 12px 14px; border-bottom: 1px solid var(--c-border); font-size: 14px; vertical-align: middle; }
.gp-table tbody tr:last-child td { border-bottom: none; }
.gp-table tbody tr:hover { background: var(--c-bg); }
.gp-table td.low-stock { color: var(--c-red); font-weight: 600; }

/* --- SECTION CARD --- */
.section-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  margin-bottom: 16px;
}
.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
}
.section-card-title { font-size: 16px; font-weight: 700; }
.section-card-body { padding: 20px; }

/* --- TIMELINE INTERVENTIONS --- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 14px; padding-bottom: 20px; position: relative; }
.tl-item::before { content: ''; position: absolute; left: 15px; top: 32px; bottom: 0; width: 2px; background: var(--c-border); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 32px; height: 32px; border-radius: 50%; background: var(--c-blue); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; color: #fff; z-index: 1; }
.tl-content { flex: 1; background: var(--c-bg); border-radius: var(--r-md); padding: 12px 14px; min-width: 0; }
.tl-date { font-size: 11px; color: var(--c-text3); margin-bottom: 4px; }
.tl-desc { font-size: 14px; color: var(--c-text); margin-bottom: 6px; }
.tl-meta { font-size: 12px; color: var(--c-text2); display: flex; gap: 12px; flex-wrap: wrap; }
.tl-photos { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.tl-photo { width: 64px; height: 48px; border-radius: 6px; overflow: hidden; cursor: pointer; }
.tl-photo img { width: 100%; height: 100%; object-fit: cover; }

/* --- FILTERS BAR --- */
.filters-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filters-bar .form-control { height: 36px; font-size: 13px; max-width: 180px; }
.filter-search { flex: 1; min-width: 200px; max-width: 100% !important; }

/* --- EMPTY STATE --- */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--c-text3);
}
.empty-icon { font-size: 52px; margin-bottom: 12px; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--c-text2); margin-bottom: 6px; }
.empty-sub { font-size: 14px; }

/* --- NOTIFICATION TOAST --- */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { padding: 12px 20px; border-radius: 50px; background: var(--c-text); color: #fff; font-size: 14px; font-weight: 500; box-shadow: var(--sh-lg); opacity: 0; animation: toastIn .3s forwards, toastOut .3s 2.5s forwards; pointer-events: all; }
.toast.toast-success { background: var(--c-green); }
.toast.toast-error   { background: var(--c-red); }
@keyframes toastIn  { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; } }

/* --- BADGE --- */
.badge { display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-blue   { background: rgba(0,122,255,.1);   color: var(--c-blue);   }
.badge-green  { background: rgba(52,199,89,.1);   color: var(--c-green);  }
.badge-orange { background: rgba(255,149,0,.1);   color: var(--c-orange); }
.badge-red    { background: rgba(255,59,48,.1);   color: var(--c-red);    }
.badge-gray   { background: var(--c-bg);           color: var(--c-text2);  }

/* --- PAGINATION --- */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.pagination .page-numbers { padding: 8px 14px; border-radius: var(--r-md); background: var(--c-surface); border: 1px solid var(--c-border); font-size: 14px; font-weight: 500; color: var(--c-text2); text-decoration: none; }
.pagination .current, .pagination .page-numbers:hover { background: var(--c-blue); color: #fff; border-color: var(--c-blue); }

/* --- LOGIN PAGE --- */
.login-page {
  min-height: 100vh;
  background: var(--c-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--sh-lg);
}

.login-logo-wrap {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo-icon {
  width: 64px; height: 64px;
  background: var(--c-text);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto 12px;
}
.login-app-name { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.login-tagline { font-size: 13px; color: var(--c-text2); margin-top: 4px; }

.login-error {
  background: rgba(255,59,48,.08);
  border: 1px solid rgba(255,59,48,.2);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--c-red);
  margin-bottom: 16px;
}

/* --- RESPONSIVE TWEAKS --- */
@media(max-width:640px) {
  .page-title { font-size: 22px; }
  .header-search { flex: none; position: absolute; left: 0; right: 0; top: 60px; padding: 8px 12px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--c-border); display: none; }
  .header-search.mobile-open { display: block; }
  .btn-search-toggle { display: flex; }
  .stat-value { font-size: 26px; }
  .modal-sheet { max-height: 90vh; }
}

.btn-search-toggle {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  background: var(--c-bg);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 16px;
}
@media(max-width:640px){ .btn-search-toggle { display: flex; } }
@media(min-width:641px){ .header-search { display: block !important; } }

/* --- WHATSAPP BUTTON --- */
.btn-whatsapp {
  background: #25d366;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: filter .2s;
  text-decoration: none;
}
.btn-whatsapp:hover { filter: brightness(1.1); }

/* profil photo upload */
.avatar-upload { display: flex; align-items: center; gap: 12px; }
.avatar-preview {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--c-bg);
  border: 1.5px solid var(--c-border);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.avatar-preview img { width:100%; height:100%; object-fit:cover; }

/* =============================================
   QUICK ACTIONS — Dashboard
   ============================================= */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media(min-width: 480px) {
  .quick-actions {
    grid-template-columns: repeat(4, 1fr);
  }
}

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--c-bg);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  font-family: var(--font);
}

.quick-btn:hover {
  background: var(--c-blue);
  border-color: var(--c-blue);
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}

.quick-btn:hover .quick-btn-icon,
.quick-btn:hover .quick-btn-label {
  color: #fff;
}

.quick-btn-icon {
  font-size: 28px;
  line-height: 1;
}

.quick-btn-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text);
  white-space: nowrap;
}

/* =============================================
   CORRECTIONS DIVERSES
   ============================================= */

/* Formulaire recherche dans les pages */
.filters-bar input.form-control,
.filters-bar select.form-control {
  color: var(--c-text);
  background: white;
}

/* Garantir texte visible dans search header */
.search-field {
  color: var(--c-text) !important;
}

.search-field:focus {
  color: var(--c-text) !important;
}

/* =============================================
   LOADER GLOBAL
   ============================================= */

.gp-loader-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}

.gp-loader-box {
  background: white;
  border-radius: var(--r-xl);
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: var(--sh-lg);
  min-width: 180px;
  animation: scaleIn .2s ease;
}

.gp-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.gp-loader-msg {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text2);
}

.gp-loader-out .gp-loader-backdrop {
  animation: fadeOut .3s ease forwards;
}

/* Spinner inline pour search */
.sd-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--c-border);
  border-top-color: var(--c-blue);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes fadeIn   { from { opacity:0; } to { opacity:1; } }
@keyframes fadeOut  { from { opacity:1; } to { opacity:0; } }

/* =============================================
   ANIMATIONS CARDS AU SCROLL
   ============================================= */

.gp-fade-in {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .4s ease, transform .4s ease;
}

.gp-fade-in.gp-visible {
  opacity: 1;
  transform: translateY(0);
}

/* =============================================
   TRANSITIONS MODALS AMÉLIORÉES
   ============================================= */

.modal-overlay {
  transition: opacity .25s ease;
  opacity: 0;
  pointer-events: none;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-sheet {
  transition: transform .3s cubic-bezier(.25,.46,.45,.94), opacity .25s ease;
  transform: translateY(40px);
  opacity: 0;
}
.modal-overlay.open .modal-sheet {
  transform: translateY(0);
  opacity: 1;
}

@media(min-width:640px) {
  .modal-sheet {
    transform: scale(.95) translateY(0);
  }
  .modal-overlay.open .modal-sheet {
    transform: scale(1) translateY(0);
  }
}

/* =============================================
   BOUTON LOADER INLINE (dans btn)
   ============================================= */

.btn.loading {
  position: relative;
  pointer-events: none;
  opacity: .7;
}
.btn.loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-left: 8px;
  display: inline-block;
  vertical-align: middle;
}

/* =============================================
   PAGE TRANSITION
   ============================================= */

.page-body {
  animation: pageIn .35s ease;
}

@keyframes pageIn {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:translateY(0);    }
}

/* =============================================
   FICHE INTERVENTION IMPRIMABLE
   ============================================= */

.fiche-print {
  background: white;
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: 32px;
  margin-top: 16px;
  box-shadow: var(--sh-sm);
  font-size: 14px;
}

.fiche-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--c-text);
}

.fiche-logo { display: flex; align-items: center; gap: 12px; }
.fiche-meta { text-align: right; }
.fiche-num  { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }

.fiche-section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media(max-width:640px) { .fiche-section-grid { grid-template-columns: 1fr; } }

.fiche-bloc {
  background: var(--c-bg);
  border-radius: var(--r-md);
  padding: 16px;
  border: 1px solid var(--c-border);
}

.fiche-bloc-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--c-text2);
  margin-bottom: 12px;
}

.fiche-table-info { width: 100%; border-collapse: collapse; }
.fiche-table-info td { padding: 5px 4px; font-size: 13px; border-bottom: 1px solid var(--c-border); }
.fiche-table-info td:first-child { color: var(--c-text2); width: 50%; }

.fiche-desc {
  background: white;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 12px;
  font-size: 14px;
  line-height: 1.7;
  min-height: 60px;
}

.fiche-table-pieces {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.fiche-table-pieces th {
  background: var(--c-primary);
  color: white;
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
}
.fiche-table-pieces td { padding: 8px 10px; border-bottom: 1px solid var(--c-border); }
.fiche-table-pieces tfoot td { background: var(--c-bg); font-size: 14px; border-top: 2px solid var(--c-text); }

.fiche-couts { margin-top: 16px; }
.fiche-table-couts { width: 100%; border-collapse: collapse; }
.fiche-table-couts td { padding: 10px 0; border-bottom: 1px solid var(--c-border); font-size: 14px; }
.fiche-table-couts td:last-child { text-align: right; font-weight: 600; }
.fiche-total-row td { border-top: 2px solid var(--c-text); padding-top: 12px; font-size: 16px !important; }

.fiche-commentaires { margin-top: 16px; }
.fiche-lines { padding: 8px 0; }
.fiche-line {
  height: 32px;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 4px;
}

.fiche-photos { display: flex; flex-wrap: wrap; gap: 8px; }
.fiche-photo  { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid var(--c-border); cursor: pointer; }

.fiche-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--c-border);
}
.fiche-signature-bloc { text-align: center; }
.fiche-signature-line { height: 60px; border-bottom: 1px solid var(--c-text); margin-bottom: 8px; }
.fiche-signature-label { font-size: 11px; color: var(--c-text2); }

.fiche-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--c-border);
  font-size: 11px;
  color: var(--c-text3);
}

/* ── PRINT CSS ── */
@media print {
  .main-header, .nav-tabs, .page-header .btn, .print-hide,
  .modal-overlay, #toastWrap, #gpLoader {
    display: none !important;
  }

  body { background: white !important; }
  .app-wrap { padding-top: 0 !important; }
  .page-body { padding: 0 !important; animation: none !important; }

  .fiche-print {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 20px !important;
    page-break-inside: avoid;
  }

  .fiche-photo { width: 100px !important; height: 75px !important; }
  .fiche-photos { gap: 4px !important; }

  .page-header { display: none !important; }
}

/* =============================================
   SPLASH SCREEN — Bonjour
   ============================================= */

.gp-splash {
  position: fixed;
  inset: 0;
  background: var(--c-text);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .4s ease, visibility .4s;
}

.gp-splash.gp-splash-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gp-splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: white;
}

.gp-splash-logo {
  font-size: 64px;
  animation: splashPop .5s cubic-bezier(.25,1.5,.5,1) both;
}

.gp-splash-hello {
  font-size: 18px;
  color: rgba(255,255,255,.6);
  animation: splashFade .4s .2s ease both;
}

.gp-splash-name {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  animation: splashFade .4s .35s ease both;
}

.gp-splash-sub {
  font-size: 13px;
  color: rgba(255,255,255,.4);
  margin-top: 4px;
  animation: splashFade .4s .5s ease both;
}

.gp-splash-bar {
  width: 160px;
  height: 3px;
  background: rgba(255,255,255,.15);
  border-radius: 2px;
  margin-top: 20px;
  overflow: hidden;
  animation: splashFade .4s .5s ease both;
}

.gp-splash-progress {
  height: 100%;
  background: var(--c-blue);
  border-radius: 2px;
  width: 0;
  animation: splashProgress 1.4s .6s cubic-bezier(.4,0,.2,1) forwards;
}

@keyframes splashPop     { from { transform:scale(.5); opacity:0; } to { transform:scale(1); opacity:1; } }
@keyframes splashFade    { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@keyframes splashProgress{ from { width:0; } to { width:100%; } }

/* =============================================
   STAT CARDS CLIQUABLES
   ============================================= */

.stat-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow .2s, transform .2s, border-color .2s;
  cursor: pointer;
}

.stat-card-link:hover {
  box-shadow: var(--sh-md);
  transform: translateY(-3px);
  border-color: var(--c-blue);
}

.stat-hint {
  font-size: 11px;
  color: var(--c-text3);
  margin-top: 4px;
  transition: color .2s;
}

.stat-card-link:hover .stat-hint {
  color: var(--c-blue);
}

/* =============================================
   TIMELINE — améliorations photos
   ============================================= */

.tl-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.tl-date-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tl-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.tl-comment {
  background: rgba(0,122,255,.05);
  border-left: 3px solid var(--c-blue);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 8px 12px;
  margin-top: 8px;
}

/* Photos avant/après dans timeline */
.tl-photos-section {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tl-photos-group {}

.tl-photos-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--c-text3);
  margin-bottom: 6px;
}

.tl-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tl-photo {
  width: 72px;
  height: 54px;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1.5px solid var(--c-border);
  cursor: zoom-in;
  transition: transform .2s, box-shadow .2s;
  flex-shrink: 0;
}

.tl-photo:hover {
  transform: scale(1.08);
  box-shadow: var(--sh-md);
  border-color: var(--c-blue);
  z-index: 1;
}

.tl-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* =============================================
   LIGHTBOX
   ============================================= */

#gpLightboxOverlay {
  animation: fadeIn .2s ease;
}

#gpLightboxOverlay.open {
  display: flex !important;
}

@media print {
  .gp-splash, .nav-tabs, .main-header { display: none !important; }
  .page-body { animation: none !important; opacity: 1 !important; }
}
