/* ── Variables ── */
:root {
  --blue: #0077B6;
  --blue-dark: #005A8E;
  --honey: #F4A900;
  --bg: #F8F9FA;
  --black: #000000;
  --white: #ffffff;
  --green: #28a745;
  --red: #dc3545;
  --gray: #6c757d;
  --border: #dee2e6;
  --shadow: 0 2px 8px rgba(0,0,0,.1);
  --radius: 6px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: #212529; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: 0.95rem; }

/* ── Header ── */
.site-header {
  background: var(--black);
  color: var(--white);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 60px;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.header-logo img { height: 44px; width: auto; object-fit: contain; }
.logo-placeholder { font-size: 1.8rem; }
.site-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--white);
  white-space: nowrap;
}
.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.main-nav a {
  color: rgba(255,255,255,.85);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.main-nav a:hover { background: rgba(255,255,255,.1); color: var(--white); text-decoration: none; }
.main-nav a.active { color: var(--honey); }
.main-nav a.btn-new {
  background: var(--blue);
  color: var(--white);
  font-weight: 600;
}
.main-nav a.btn-new:hover { background: var(--blue-dark); }
.main-nav a.logout { color: rgba(255,255,255,.6); }
.hamburger { display: none; background: none; border: none; color: var(--white); font-size: 1.5rem; cursor: pointer; margin-left: auto; }

/* ── Page content ── */
.page-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
}
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header h2 { font-size: 1.5rem; font-weight: 700; color: var(--blue-dark); }

/* ── Flash messages ── */
.flash-messages { margin-bottom: 16px; }
.flash {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 500;
}
.flash-success { background: #d1e7dd; color: #0f5132; border-left: 4px solid var(--green); }
.flash-danger  { background: #f8d7da; color: #842029; border-left: 4px solid var(--red); }
.flash-info    { background: #d0e8f7; color: #0a4d7a; border-left: 4px solid var(--blue); }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--blue-dark);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e0eef7;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none !important;
}
.btn-primary  { background: var(--blue);  color: var(--white); border-color: var(--blue); }
.btn-primary:hover  { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-outline  { background: var(--white); color: var(--blue); border-color: var(--blue); }
.btn-outline:hover  { background: #e8f4fb; }
.btn-success  { background: var(--green); color: var(--white); border-color: var(--green); }
.btn-success:hover  { background: #1e7e34; }
.btn-danger   { background: var(--red);   color: var(--white); border-color: var(--red); }
.btn-danger:hover   { background: #b02a37; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
  border-top: 4px solid var(--blue);
}
.stat-label { font-size: 0.8rem; color: var(--gray); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--blue-dark); }

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-header h3 { font-size: 1.1rem; font-weight: 700; color: var(--blue-dark); }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}
.data-table thead tr { background: var(--blue); color: var(--white); }
.data-table thead th { padding: 10px 14px; text-align: left; font-weight: 600; white-space: nowrap; }
.data-table tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f0f7fd; }
.data-table tfoot td { padding: 10px 14px; background: #f0f7fd; font-weight: 700; }
.text-right { text-align: right !important; }
.empty { text-align: center; color: var(--gray); font-style: italic; padding: 24px !important; }
.muted { color: var(--gray); }
.small { font-size: 0.8rem; }
.results-count { color: var(--gray); font-size: 0.85rem; margin-bottom: 8px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}
.badge-brouillon { background: #e9ecef; color: #495057; }
.badge-validee   { background: #cfe2ff; color: #084298; }
.badge-payee     { background: #d1e7dd; color: #0f5132; }
.badge-lg { padding: 5px 14px; font-size: 0.9rem; }

/* ── Filters ── */
.filters-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filters-bar input, .filters-bar select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--white);
}

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: #495057; }
.form-group input, .form-group select, .form-group textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,119,182,.15);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.form-narrow { max-width: 600px; }
.hint { font-size: 0.85rem; color: var(--gray); margin-bottom: 12px; }
.checkbox-group label { flex-direction: row; align-items: center; gap: 8px; font-weight: normal; }

/* ── Detail grid ── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Vente form ── */
.ligne-row select, .ligne-row input { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.85rem; width: 100%; }
.sous-total-display { font-weight: 600; color: var(--blue-dark); font-size: 0.9rem; }
.btn-remove-ligne { background: none; border: none; font-size: 1.1rem; cursor: pointer; opacity: .6; transition: opacity .15s; padding: 4px; }
.btn-remove-ligne:hover { opacity: 1; }
.total-line { text-align: right; margin-top: 16px; font-size: 1.1rem; color: var(--blue-dark); }
.input-qte { width: 70px !important; text-align: center; }
.input-prix { width: 90px !important; }

/* ── Client search autocomplete ── */
.client-search-wrapper { position: relative; margin-bottom: 12px; }
.client-search-wrapper input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.9rem; }
.suggestions {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--white); border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow); z-index: 50; max-height: 240px; overflow-y: auto;
}
.suggestion-item { padding: 8px 12px; cursor: pointer; font-size: 0.9rem; }
.suggestion-item:hover { background: #f0f7fd; }
.client-selected { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #f0f7fd; border-radius: var(--radius); font-weight: 600; color: var(--blue-dark); }
.nouveau-client { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.hidden { display: none !important; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab { background: #e9ecef; border: none; padding: 8px 20px; border-radius: var(--radius) var(--radius) 0 0; cursor: pointer; font-weight: 600; font-size: 0.875rem; color: var(--gray); transition: background .15s, color .15s; }
.tab.active { background: var(--blue); color: var(--white); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Catalogue inline forms ── */
.inline-form { display: flex; align-items: center; gap: 8px; }
.input-annee-inline { width: 70px; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.85rem; }
.input-lot-inline { width: 90px; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.85rem; }
.input-prix-inline { width: 80px; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.85rem; }
.add-form { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.add-form h4 { margin-bottom: 12px; font-size: 0.95rem; color: var(--blue-dark); }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 12px; }

/* ── Pagination ── */
.pagination { display: flex; gap: 6px; margin-top: 16px; justify-content: center; }
.pagination a {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.875rem; color: var(--blue);
}
.pagination a.active { background: var(--blue); color: var(--white); border-color: var(--blue); }
.pagination a:hover { background: #e8f4fb; text-decoration: none; }

/* ── Year selector ── */
.year-selector select { padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.875rem; }

/* ── Logo preview ── */
.logo-preview { margin-bottom: 12px; background: #000; display: inline-block; padding: 8px; border-radius: var(--radius); }

/* ── Login page ── */
body.login-page {
  background: #0d1b2a;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-container {
  background: #fff;
  border-radius: 12px;
  padding: 40px 32px;
  width: 340px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.login-logo { margin-bottom: 16px; }
.login-logo img { max-height: 80px; }
.login-logo-text { font-size: 3rem; }
.login-title { font-size: 1.2rem; font-weight: 700; color: var(--blue-dark); margin-bottom: 4px; }
.login-subtitle { font-size: 0.85rem; color: var(--gray); margin-bottom: 20px; }
.login-error { background: #f8d7da; color: #842029; border-radius: var(--radius); padding: 8px 12px; font-size: 0.85rem; margin-bottom: 16px; }

.pin-display {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}
.pin-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--blue);
  background: var(--white);
  transition: background .15s;
}
.pin-dot.filled { background: var(--blue); }

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.pin-key {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, transform .08s;
  color: #212529;
}
.pin-key:hover { background: #e8f4fb; transform: scale(1.04); }
.pin-key:active { transform: scale(.96); }
.pin-clear { color: var(--red); }
.pin-submit { background: var(--blue); color: var(--white); border-color: var(--blue); }
.pin-submit:hover { background: var(--blue-dark); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .main-nav { display: none; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; background: var(--black); padding: 10px 20px; }
  .main-nav.open { display: flex; }
  .hamburger { display: block; }
  .header-inner { position: relative; }
  .stats-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .ligne-row { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
  .filters-bar { flex-direction: column; align-items: stretch; }
}
