/* ============================================================
   InvMairie — Feuille de style principale
   Charte : #006666 (vert foncé) + #1C97A6 (teal)
   ============================================================ */

:root {
  --primary:       #006666;
  --primary-dark:  #004d4d;
  --primary-light: #e0f2f2;
  --accent:        #1C97A6;
  --accent-light:  #d0eef1;
  --white:         #ffffff;
  --grey-50:       #f8f9fa;
  --grey-100:      #f1f3f4;
  --grey-200:      #e8eaed;
  --grey-400:      #bdc1c6;
  --grey-600:      #80868b;
  --grey-800:      #3c4043;
  --text:          #202124;
  --danger:        #d93025;
  --danger-light:  #fce8e6;
  --warning:       #f9ab00;
  --warning-light: #fef7e0;
  --success:       #1e8e3e;
  --success-light: #e6f4ea;
  --info:          #1a73e8;
  --info-light:    #e8f0fe;
  --sidebar-w:     260px;
  --radius:        8px;
  --shadow:        0 1px 4px rgba(0,0,0,.12);
  --shadow-md:     0 4px 16px rgba(0,0,0,.14);
}

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

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--grey-100);
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform .25s ease;
}

.sidebar-header { padding: 20px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.15); }
.sidebar-logo   { display: flex; align-items: center; gap: 12px; }
.logo-icon      { width: 40px; height: 40px; background: rgba(255,255,255,.15); border-radius: 10px;
                  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-icon svg  { width: 20px; height: 20px; stroke: #fff; }
.logo-title     { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.logo-sub       { font-size: 10px; opacity: .7; margin-top: 1px; line-height: 1.3; }

.sidebar-menu   { list-style: none; padding: 12px 0; flex: 1; }
.menu-section   { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
                  opacity: .5; padding: 16px 20px 4px; }
.sidebar-menu a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,.85);
  text-decoration: none;
  border-radius: 0;
  transition: background .15s, color .15s;
  font-size: 13.5px;
}
.sidebar-menu a svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-menu a:hover  { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-menu a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600;
                         border-left: 3px solid #fff; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.15);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; opacity: .7; }
.user-info { flex: 1; min-width: 0; }
.btn-logout {
  color: rgba(255,255,255,.7); padding: 6px;
  border-radius: 6px; transition: background .15s, color .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.15); color: #fff; }
.btn-logout svg   { width: 18px; height: 18px; }

.sidebar-toggle {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 200;
  background: var(--primary); color: #fff;
  border: none; border-radius: 8px; padding: 8px; cursor: pointer;
}
.sidebar-toggle svg { width: 20px; height: 20px; }

/* ── MAIN CONTENT ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px;
  min-height: 100vh;
}

/* ── PAGE HEADER ─────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--primary); }
.page-subtitle { font-size: 13px; color: var(--grey-600); margin-top: 2px; }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--grey-200);
}
.card-title { font-size: 15px; font-weight: 600; color: var(--grey-800); }

/* ── STAT CARDS ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex; flex-direction: column;
  border-left: 4px solid var(--primary);
}
.stat-card.accent  { border-left-color: var(--accent); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger  { border-left-color: var(--danger); }
.stat-card.info    { border-left-color: var(--info); }
.stat-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--primary-light);
             display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.stat-icon svg { width: 18px; height: 18px; stroke: var(--primary); }
.stat-card.accent  .stat-icon { background: var(--accent-light); }
.stat-card.accent  .stat-icon svg { stroke: var(--accent); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--grey-600); margin-top: 4px; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px; border: none;
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  text-decoration: none; transition: all .15s;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent    { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #177f8c; }
.btn-outline   { background: transparent; border: 1.5px solid var(--grey-400); color: var(--grey-800); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b5261e; }
.btn-sm        { padding: 5px 10px; font-size: 12px; }
.btn-sm svg    { width: 13px; height: 13px; }
.btn-icon      { padding: 6px; border-radius: 6px; }

/* ── FORMULAIRES ─────────────────────────────────────────── */
.form-group    { margin-bottom: 16px; }
.form-label    { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: var(--grey-800); }
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--grey-200); border-radius: 6px;
  font-size: 13.5px; color: var(--text); background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(28,151,166,.15); }
.form-control::placeholder { color: var(--grey-400); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11.5px; color: var(--grey-600); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table {
  width: 100%; border-collapse: collapse;
  background: var(--white);
}
thead th {
  background: var(--grey-50);
  padding: 11px 14px;
  text-align: left; font-size: 12px; font-weight: 600;
  color: var(--grey-600); text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 2px solid var(--grey-200);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--grey-100);
  font-size: 13.5px;
  vertical-align: middle;
}
tbody tr:hover { background: var(--grey-50); }
tbody tr:last-child td { border-bottom: none; }
.td-actions { display: flex; gap: 6px; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-warning { background: var(--warning-light); color: #7a4f00; }
.badge-info    { background: var(--info-light);    color: var(--info); }
.badge-dark    { background: var(--grey-200);      color: var(--grey-800); }
.badge-secondary { background: var(--grey-100);   color: var(--grey-600); }

/* ── ALERTS ──────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 13.5px;
}
.alert-success { background: var(--success-light); color: var(--success); border-left: 4px solid var(--success); }
.alert-danger  { background: var(--danger-light);  color: var(--danger);  border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: #7a4f00;        border-left: 4px solid var(--warning); }
.alert-info    { background: var(--info-light);    color: var(--info);    border-left: 4px solid var(--info); }
.alert-close   { background: none; border: none; cursor: pointer; font-size: 18px; opacity: .6; padding: 0 4px; }

/* ── SEARCH / FILTERS ────────────────────────────────────── */
.filters-bar {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
}
.filters-bar .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }
.search-input-wrap { position: relative; flex: 2; min-width: 200px; }
.search-input-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; stroke: var(--grey-400); pointer-events: none;
}
.search-input-wrap input { padding-left: 34px; }

/* ── PAGINATION ──────────────────────────────────────────── */
.pagination {
  display: flex; gap: 4px; align-items: center; margin-top: 16px;
  justify-content: center;
}
.page-link {
  padding: 6px 12px; border-radius: 6px; border: 1.5px solid var(--grey-200);
  text-decoration: none; color: var(--grey-800); font-size: 13px;
  background: var(--white); transition: all .15s;
}
.page-link:hover    { border-color: var(--primary); color: var(--primary); }
.page-link.active   { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ── FICHE EQUIPEMENT ────────────────────────────────────── */
.fiche-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.fiche-photo {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  border-radius: var(--radius); background: var(--grey-100);
}
.fiche-photo-placeholder {
  width: 100%; aspect-ratio: 4/3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--grey-100); border-radius: var(--radius); color: var(--grey-400);
}
.fiche-photo-placeholder svg { width: 48px; height: 48px; }
.qr-container { text-align: center; padding: 16px; background: var(--grey-50); border-radius: var(--radius); }
.qr-container img { max-width: 180px; }
.detail-list { list-style: none; }
.detail-list li {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 8px 0; border-bottom: 1px solid var(--grey-100); gap: 16px;
  font-size: 13.5px;
}
.detail-list li:last-child { border-bottom: none; }
.detail-key   { color: var(--grey-600); font-weight: 500; white-space: nowrap; }
.detail-value { color: var(--text); text-align: right; }

/* ── SCAN PAGE ───────────────────────────────────────────── */
.scan-container {
  max-width: 480px; margin: 0 auto; text-align: center;
}
#reader {
  width: 100%; border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-md);
}

/* ── LOGIN PAGE ──────────────────────────────────────────── */
body.login-body {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; margin: 0;
}
.login-card {
  background: var(--white); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  padding: 40px 36px; width: 100%; max-width: 400px;
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .logo-big {
  width: 64px; height: 64px; background: var(--primary);
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}
.login-logo .logo-big svg { width: 32px; height: 32px; stroke: #fff; }
.login-logo h1 { font-size: 24px; font-weight: 700; color: var(--primary); }
.login-logo p  { font-size: 12px; color: var(--grey-600); margin-top: 2px; }
.btn-login {
  width: 100%; padding: 11px; background: var(--primary); color: #fff;
  border: none; border-radius: 8px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-login:hover { background: var(--primary-dark); }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 300;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); border-radius: 12px;
  box-shadow: var(--shadow-md); padding: 28px;
  width: 100%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; position: relative;
}
.modal-title   { font-size: 17px; font-weight: 700; margin-bottom: 20px; color: var(--primary); }
.modal-close   {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--grey-600); font-size: 20px;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .main-content { margin-left: 0; padding: 16px; padding-top: 56px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .fiche-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; align-items: flex-start; }
}

@media print {
  .sidebar, .sidebar-toggle, .btn, .filters-bar, .td-actions { display: none !important; }
  .main-content { margin-left: 0; padding: 0; }
}
