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

:root {
  --primary: #2c5f2e;
  --primary-light: #3a7a3c;
  --primary-dark: #1e4020;
  --secondary: #f0a500;
  --danger: #dc3545;
  --success: #28a745;
  --warning: #ffc107;
  --info: #17a2b8;
  --light: #f8f9fa;
  --dark: #343a40;
  --gray: #6c757d;
  --border: #dee2e6;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; }
body { font-family: var(--font); color: var(--dark); background: #f5f6fa; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ===== TYPOGRAPHY ===== */
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.2rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }

/* ===== LAYOUT ===== */
.container { max-width: 900px; margin: 0 auto; padding: 24px 16px; }
.admin-layout, .client-layout { display: flex; min-height: 100vh; }
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.content-area { flex: 1; padding: 24px; overflow-y: auto; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 240px;
  background: #fff;
  color: var(--dark);
  border-right: 1px solid #dee2e6;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: 20px 16px;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
}
.brand-icon { font-size: 1.5rem; }
.sidebar-nav { list-style: none; flex: 1; padding: 8px 0; }
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: #495057;
  transition: background 0.2s;
  font-size: 0.9rem;
  position: relative;
}
.sidebar-nav li a:hover, .sidebar-nav li a.active {
  background: #f0f5f0;
  color: var(--primary-dark);
  text-decoration: none;
}
.sidebar-nav li a.active { border-left: 3px solid var(--secondary); }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid #dee2e6; }
.btn-logout {
  display: block;
  text-align: center;
  padding: 8px;
  background: #fef2f2;
  color: #dc3545;
  border-radius: var(--radius);
  font-size: 0.85rem;
  transition: background 0.2s;
}
.btn-logout:hover { background: #fde8e8; text-decoration: none; }

/* ===== TOPBAR ===== */
.topbar {
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.page-title { font-size: 1.3rem; font-weight: 600; }
.admin-badge {
  background: var(--primary);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
}
.user-email { font-size: 0.85rem; color: var(--gray); }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.alert ul { margin: 8px 0 0 16px; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger  { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger  { background: #f8d7da; color: #721c24; }
.badge-info    { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: #e2e3e5; color: #383d41; }

.sidebar-nav .badge {
  background: var(--secondary);
  color: #000;
  margin-left: auto;
  padding: 2px 7px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(0.9); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-outline, .btn-outline-secondary { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover, .btn-outline-secondary:hover { background: var(--primary); color: #fff; }
.btn-outline-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.9rem; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: var(--font);
  background: #fff;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44,95,46,0.15);
}
.form-control-sm { padding: 5px 8px; font-size: 0.82rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 0.8rem; color: var(--gray); margin-top: 4px; display: block; }
.required { color: var(--danger); }
.form-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}
.form-section h3 { margin-bottom: 16px; color: var(--primary); font-size: 1rem; }
.form-actions { text-align: right; padding-top: 8px; }
.form-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
  margin: 24px auto;
}
.form-card-centered { max-width: 480px; }
.form-subtitle { color: var(--gray); margin-bottom: 24px; font-size: 0.9rem; }

/* Radio groups */
.radio-group { display: flex; flex-wrap: wrap; gap: 12px; }
.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}
.radio-label:has(input:checked) { border-color: var(--primary); background: rgba(44,95,46,0.05); }
.radio-label input { accent-color: var(--primary); }

/* ===== TABLES ===== */
.table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table thead th { background: var(--light); font-weight: 600; color: var(--gray); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
.table tbody tr:hover { background: rgba(0,0,0,0.02); }
.table-responsive { overflow-x: auto; }
.table-hover tbody tr { cursor: pointer; }

/* ===== CARDS ===== */
.card { background: #fff; border-radius: var(--radius-lg); border: 1px solid var(--border); overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-body { padding: 20px; }

/* ===== STATS DASHBOARD ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  border-left: 4px solid var(--border);
  box-shadow: var(--shadow);
}
.stat-card.stat-pending { border-color: var(--warning); }
.stat-card.stat-validated { border-color: var(--success); }
.stat-card.stat-refused { border-color: var(--danger); }
.stat-card.stat-messages { border-color: var(--info); }
.stat-number { font-size: 2.5rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.85rem; color: var(--gray); margin-top: 4px; }
.stat-link { font-size: 0.8rem; color: var(--primary); display: block; margin-top: 8px; }

.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.dashboard-section { background: #fff; border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-header h2 { font-size: 1.1rem; }
.venue-summary { padding: 16px 0; border-bottom: 1px solid var(--border); }
.venue-summary:last-child { border-bottom: none; }
.venue-summary h3 { margin-bottom: 4px; }
.venue-summary p { font-size: 0.85rem; color: var(--gray); margin-bottom: 8px; }
.venue-links { display: flex; gap: 8px; flex-wrap: wrap; }
.empty-state { color: var(--gray); font-size: 0.9rem; padding: 20px 0; text-align: center; }
.empty-state-large { text-align: center; padding: 48px; color: var(--gray); }

/* ===== TOOLBAR ===== */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.result-count { margin-left: auto; color: var(--gray); font-size: 0.85rem; }

/* ===== DETAIL VIEW ===== */
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.detail-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-venue { font-weight: 600; }
.detail-date { color: var(--gray); }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.detail-info {}
.info-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--light); font-size: 0.88rem; }
.info-row:last-child { border-bottom: none; }
.info-row > span:first-child { width: 130px; flex-shrink: 0; color: var(--gray); font-weight: 500; }
.info-row-admin { background: rgba(255,243,205,0.5); border-radius: 4px; padding: 8px; }

/* ===== FINANCIAL ===== */
.financial-summary { margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.financial-row { display: flex; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.financial-row:last-child { border-bottom: none; }
.financial-row-balance { background: var(--light); font-weight: 600; }

.payment-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.payment-form { display: flex; gap: 6px; align-items: center; }
.payment-form .form-control { width: auto; }

/* ===== DOCUMENTS ===== */
.document-list { list-style: none; }
.document-list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.document-list li:last-child { border-bottom: none; }
.upload-form { padding: 16px; background: var(--light); border-radius: var(--radius); margin-bottom: 16px; }
.document-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.document-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  transition: box-shadow 0.2s;
}
.document-card:hover { box-shadow: var(--shadow); text-decoration: none; }
.doc-icon { font-size: 2.5rem; margin-bottom: 8px; }
.doc-info strong { display: block; font-size: 0.9rem; }
.doc-info small { color: var(--gray); font-size: 0.8rem; }
.doc-action { margin-top: 12px; font-size: 0.8rem; color: var(--primary); }

/* ===== MESSAGES ===== */
.messages-container { display: flex; flex-direction: column; gap: 20px; }
.messages-thread { display: flex; flex-direction: column; gap: 12px; max-height: 500px; overflow-y: auto; padding: 4px; }
.message-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
}
.message-admin { background: var(--primary); color: #fff; align-self: flex-start; border-bottom-left-radius: 4px; }
.message-client { background: var(--light); color: var(--dark); align-self: flex-end; border-bottom-right-radius: 4px; border: 1px solid var(--border); }
.message-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 0.8rem; opacity: 0.85; }
.message-admin .message-meta time { opacity: 0.7; }
.message-form { display: flex; flex-direction: column; gap: 12px; }

.messages-thread .message-bubble { display: block; }

/* ===== LOGIN PAGE ===== */
.login-page { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); min-height: 100vh; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.login-container { width: 100%; max-width: 420px; padding: 24px; }
.login-card { background: #fff; border-radius: var(--radius-lg); padding: 40px; box-shadow: var(--shadow-lg); }
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { font-size: 3rem; display: block; margin-bottom: 8px; }
.login-header h1 { font-size: 1.5rem; }
.login-header p { color: var(--gray); font-size: 0.9rem; }
.login-footer { text-align: center; color: rgba(255,255,255,0.7); font-size: 0.85rem; margin-top: 16px; }
.login-footer a { color: #fff; }

/* ===== VENUE PAGE ===== */
.venue-hero {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
  color: #fff;
  padding: 60px 24px;
  text-align: center;
}
.venue-hero h1 { font-size: 2.5rem; margin-bottom: 8px; }
.venue-hero p { opacity: 0.9; font-size: 1.1rem; }
.venue-footer { background: var(--dark); color: rgba(255,255,255,0.6); text-align: center; padding: 20px; font-size: 0.85rem; margin-top: 40px; }

/* ===== CONFIRMATION PAGE ===== */
.confirmation-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  margin: 40px auto;
}
.confirmation-icon { font-size: 4rem; margin-bottom: 16px; }
.confirmation-card h1 { color: var(--primary); margin-bottom: 12px; }
.confirmation-ref { font-size: 1.1rem; margin-bottom: 16px; }
.confirmation-info { background: var(--light); border-radius: var(--radius); padding: 20px; margin: 24px 0; text-align: left; }
.confirmation-info h3 { margin-bottom: 12px; color: var(--primary); }
.confirmation-info ol { padding-left: 20px; }
.confirmation-info li { padding: 4px 0; font-size: 0.9rem; }

/* ===== CLIENT DASHBOARD ===== */
.client-header { margin-bottom: 24px; }
.client-header h2 { font-size: 1.6rem; }
.client-header p { color: var(--gray); }
.res-card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px; margin-bottom: 24px; }
.res-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.res-ref { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.res-details { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.res-detail-item { display: flex; gap: 12px; align-items: flex-start; }
.detail-icon { font-size: 1.5rem; }
.res-detail-item strong { display: block; font-size: 0.8rem; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; }
.res-detail-item p { margin-top: 2px; font-weight: 500; }

.payment-overview { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px; margin-bottom: 24px; }
.payment-overview h3 { margin-bottom: 16px; }
.payment-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.payment-box { background: var(--light); border-radius: var(--radius); padding: 16px; text-align: center; }
.payment-box-paid { background: #d4edda; }
.payment-label { font-size: 0.8rem; color: var(--gray); margin-bottom: 6px; }
.payment-amount { font-size: 1.4rem; font-weight: 700; color: var(--primary); }

.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.action-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--dark);
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
}
.action-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); text-decoration: none; }
.action-icon { font-size: 2rem; }
.action-card .badge { position: absolute; top: 12px; right: 12px; }

/* ===== CALENDAR ===== */
#calendar-container { background: #fff; border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.legend { display: flex; gap: 16px; align-items: center; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot-green { background: #2c5f2e; }
.dot-yellow { background: #f0a500; }
.dot-red { background: #dc3545; }

/* ===== SETTINGS ===== */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.settings-card { background: #fff; border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); }
.settings-card h3 { margin-bottom: 20px; color: var(--primary); padding-bottom: 10px; border-bottom: 1px solid var(--border); }

/* ===== ERROR PAGE ===== */
.error-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.error-container { text-align: center; }
.error-container h1 { font-size: 5rem; color: var(--gray); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .payment-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-actions { grid-template-columns: 1fr; }
  .res-details { grid-template-columns: 1fr; }
  .venue-hero h1 { font-size: 1.8rem; }
}

/* Autocomplétion adresse */
.autocomplete-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  list-style: none;
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
}
.autocomplete-list li {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--light);
}
.autocomplete-list li:last-child { border-bottom: none; }
.autocomplete-list li:hover,
.autocomplete-list li.highlighted {
  background: rgba(44,95,46,0.08);
  color: var(--primary);
}

/* Grid columns for admin forms */
.form-row.col-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.col-4 { grid-template-columns: repeat(4, 1fr); }
.col-md-3 { grid-column: span 1; }
.col-md-4 { grid-column: span 1; }
.col-md-6 { grid-column: span 1; }

/* Form row with col-md helpers */
.form-row > .col-md-3 { }
.form-row > .col-md-4 { }
.form-row > .col-md-6 { }

/* 4-col rows */
.form-row:has(> .col-md-3) { grid-template-columns: repeat(4, 1fr); }
/* 3-col rows */
.form-row:has(> .col-md-4) { grid-template-columns: repeat(3, 1fr); }
/* 2-col rows */
.form-row:has(> .col-md-6) { grid-template-columns: repeat(2, 1fr); }

/* Inline grid form for calendar block panel */
.form-inline-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.form-inline-grid .form-group { margin-bottom: 0; }
.form-inline-grid .form-group-btn { display: flex; align-items: flex-end; }

/* Utils */
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mr-2 { margin-right: 0.5rem; }
.p-0 { padding: 0; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.text-right { text-align: right; }
.table-sm td, .table-sm th { padding: 6px 10px; }

/* Flatpickr customization */
.flatpickr-day.reserved-date { background: #fce8e8 !important; color: #dc3545 !important; cursor: not-allowed !important; }
.flatpickr-day.selected { background: var(--primary) !important; border-color: var(--primary) !important; }
