/* ============================================
   Cabinet Louvet Topo — Web admin styles
   Minimal, accessible, no framework.
   ============================================ */

:root {
  --color-primary: #1e40af;
  --color-primary-dark: #1e3a8a;
  --color-success: #15803d;
  --color-warning: #b45309;
  --color-danger: #b91c1c;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-text: #1f2937;
  --color-muted: #6b7280;
  --color-border: #e5e7eb;
  --radius: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--color-bg);
  color: var(--color-text);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Topbar ===== */

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.topbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  padding-bottom: 12px;
}

.brand {
  font-weight: 600;
  font-size: 17px;
  color: var(--color-primary);
  text-decoration: none;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.main-nav a {
  color: var(--color-text);
  text-decoration: none;
  font-size: 14px;
}

.main-nav a:hover {
  color: var(--color-primary);
}

.nav-user {
  font-size: 14px;
  color: var(--color-muted);
  border-left: 1px solid var(--color-border);
  padding-left: 16px;
}

.logout-form {
  display: inline;
  margin: 0;
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  text-decoration: underline;
}

/* ===== Main / pages ===== */

main.container {
  padding-top: 32px;
  padding-bottom: 64px;
  min-height: calc(100vh - 130px);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

h1 {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 16px;
}

h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 12px;
}

.lead {
  font-size: 15px;
  color: var(--color-muted);
  margin-bottom: 24px;
}

/* ===== Cards ===== */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

/* ===== Login page ===== */

.login-card {
  max-width: 400px;
  margin: 80px auto 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 40px 32px;
  box-shadow: var(--shadow);
}

.login-title {
  font-size: 22px;
  margin: 0 0 4px;
  text-align: center;
  color: var(--color-primary);
}

.login-subtitle {
  text-align: center;
  color: var(--color-muted);
  margin: 0 0 24px;
  font-size: 14px;
}

.login-note {
  margin-top: 24px;
  font-size: 12px;
  color: var(--color-muted);
  text-align: center;
  line-height: 1.6;
}

/* ===== Forms ===== */

.form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  margin-top: 14px;
}

.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form select,
.form textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface);
  resize: vertical;
  min-height: 80px;
}

.form input:focus,
.form select:focus,
.form textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
  border-color: var(--color-primary);
}

.form-narrow {
  max-width: 500px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form button[type="submit"],
.form .btn {
  margin-top: 20px;
}

/* ===== Buttons ===== */

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s;
}

.btn:hover {
  background: #f3f4f6;
}

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-success {
  background: var(--color-success);
  border-color: var(--color-success);
  color: white;
}

.btn-warning {
  background: var(--color-warning);
  border-color: var(--color-warning);
  color: white;
}

.btn-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: white;
}

.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

.inline-form {
  display: inline-block;
  margin: 0;
}

.actions-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ===== Alerts ===== */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
}

.alert-error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: var(--color-danger);
}

.alert-success {
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  color: var(--color-success);
}

/* ===== Tables ===== */

.data-table {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  background: #f9fafb;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  font-weight: 600;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover {
  background: #f9fafb;
}

.row-inactive {
  opacity: 0.55;
}

/* ===== Badges & statuses ===== */

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 12px;
  background: #e5e7eb;
  color: var(--color-text);
}

.role-admin { background: #fef3c7; color: #92400e; }
.role-secretaire { background: #dbeafe; color: #1e3a8a; }
.role-responsable { background: #e0e7ff; color: #3730a3; }
.role-salarie { background: #f3f4f6; color: #374151; }

.status-active { color: var(--color-success); font-weight: 500; }
.status-inactive { color: var(--color-muted); }

.muted { color: var(--color-muted); }

code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 3px;
}

/* ===== Dashboard stats ===== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.1s, transform 0.1s;
  box-shadow: var(--shadow-sm);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.stat-card-disabled {
  opacity: 0.5;
  cursor: default;
}

.stat-value {
  font-size: 32px;
  font-weight: 600;
  color: var(--color-primary);
}

.stat-label {
  margin-top: 4px;
  font-size: 13px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== Info boxes ===== */

.info-box {
  background: #f0f9ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.info-box h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #1e40af;
}

.info-box ul {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
}

/* ===== Definition lists ===== */

.info-list {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 8px 16px;
  margin: 0;
}

.info-list dt {
  font-size: 13px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.info-list dd {
  margin: 0;
}

/* ===== Sites (chantiers) ===== */

.zone-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
}

.zone-1 { background: #d1fae5; color: #065f46; }
.zone-2 { background: #dbeafe; color: #1e3a8a; }
.zone-3 { background: #fed7aa; color: #9a3412; }
.zone-4 { background: #fecaca; color: #991b1b; }

.site-status {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
}

.site-status-open { background: #d1fae5; color: #065f46; }
.site-status-completed { background: #e0e7ff; color: #3730a3; }
.site-status-provisional { background: #fef3c7; color: #92400e; }
.site-status-archived { background: #f3f4f6; color: #6b7280; }

/* ===== Calendar grid ===== */

.week-label {
  font-size: 18px;
  font-weight: 500;
  color: var(--color-muted);
  margin: 0 0 16px;
}

.calendar-grid-wrapper {
  overflow-x: auto;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.calendar-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 900px;
}

.calendar-grid th,
.calendar-grid td {
  border: 1px solid var(--color-border);
  padding: 8px;
  vertical-align: top;
  font-size: 13px;
}

.calendar-grid thead th {
  background: var(--color-background);
  font-weight: 600;
  text-align: center;
  padding: 12px 8px;
}

.calendar-user-col {
  width: 150px;
  background: var(--color-background);
  text-align: left !important;
}

.calendar-user-cell {
  width: 150px;
  background: var(--color-background);
  font-size: 13px;
}

.calendar-day-col {
  width: calc((100% - 150px) / 7);
}

.calendar-day-cell {
  height: 100px;
  vertical-align: top;
}

.calendar-day-today {
  background: rgba(59, 130, 246, 0.05);
}

.calendar-day-today.calendar-day-col {
  background: rgba(59, 130, 246, 0.1);
  font-weight: 700;
}

.calendar-empty {
  color: var(--color-border);
  font-size: 18px;
}

.calendar-event {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 6px 8px;
  border-radius: 6px;
  margin-bottom: 4px;
  border-left: 3px solid currentColor;
  background: rgba(0, 0, 0, 0.02);
  font-size: 12px;
  line-height: 1.3;
  transition: transform 0.1s ease;
}

.calendar-event:hover {
  transform: translateY(-1px);
  background: rgba(0, 0, 0, 0.04);
}

.calendar-event-site {
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-event-client {
  color: var(--color-muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-event-time {
  font-size: 11px;
  color: var(--color-muted);
  margin-top: 2px;
}

/* Réutilise les couleurs de status-* déjà définies pour le border-left */
.calendar-event.status-prevu { border-color: #3730a3; background: rgba(55, 48, 163, 0.06); }
.calendar-event.status-realise { border-color: #92400e; background: rgba(146, 64, 14, 0.06); }
.calendar-event.status-a_verifier { border-color: #78350f; background: rgba(120, 53, 15, 0.06); }
.calendar-event.status-valide_secretaire { border-color: #065f46; background: rgba(6, 95, 70, 0.06); }
.calendar-event.status-modifie { border-color: #9a3412; background: rgba(154, 52, 18, 0.06); }
.calendar-event.status-exporte_excel { border-color: #4338ca; background: rgba(67, 56, 202, 0.06); }
.calendar-event.status-facture { border-color: #312e81; background: rgba(49, 46, 129, 0.06); }
.calendar-event.status-annule { border-color: #6b7280; background: rgba(107, 114, 128, 0.06); }

/* ===== Interventions ===== */

.intervention-status {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
}

.status-prevu { background: #e0e7ff; color: #3730a3; }
.status-realise { background: #fef3c7; color: #92400e; }
.status-a_verifier { background: #fde68a; color: #78350f; }
.status-valide_secretaire { background: #d1fae5; color: #065f46; }
.status-modifie { background: #fed7aa; color: #9a3412; }
.status-exporte_excel { background: #e0e7ff; color: #4338ca; }
.status-facture { background: #c7d2fe; color: #312e81; }
.status-annule { background: #f3f4f6; color: #6b7280; }

/* ===== Filter bar ===== */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 14px;
}

.filter-bar select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--color-surface);
}

/* ===== H3 (nested titles inside cards) ===== */

.card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 16px 0 6px;
}

.card h3:first-child { margin-top: 0; }

/* ===== Footer ===== */

.footer {
  border-top: 1px solid var(--color-border);
  padding: 16px 0;
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 12px;
}
