/* ===================================================================
   Pointage Oxytec — Thème global
   Reproduction fidèle de l'appli WebDev « Gestion des pointages Oxytec »
   Stack OxySafe (HTML/JS vanilla + api.php + MySQL)
   =================================================================== */

:root {
  /* Layout */
  --sidebar-width: 210px;
  --header-height: 55px;

  /* Couleurs de marque Oxytec */
  --oxy-red: #e53935;
  --oxy-red-dark: #c62828;

  /* Sidebar (dégradé sombre) */
  --sidebar-top: #3a3f4b;
  --sidebar-bottom: #1b1d23;
  --sidebar-section: #8a8f9a;
  --sidebar-item: #f2f3f5;
  --sidebar-active: rgba(126, 138, 235, 0.55);
  --sidebar-hover: rgba(255, 255, 255, 0.06);

  /* Header */
  --header-bg: #ffffff;
  --header-text: #4a4f57;
  --header-muted: #9aa0a8;

  /* Contenu */
  --bg: #ffffff;
  --text: #3a3f47;
  --text-muted: #8a8f99;
  --border: #e3e5ea;
  --table-head: #f5f6f8;
  --card-bg: #fafbfc;

  /* Boutons d'action */
  --btn-violet: #b39ddb;
  --btn-violet-hover: #a382d4;
  --btn-blue: #4a90d9;
  --btn-blue-hover: #3a7fc8;

  /* Indicateurs */
  --ok-green: #2ecc71;
  --alert-red: #e74c3c;

  --radius: 4px;
  --transition: .15s ease;
}

* { box-sizing: border-box; }

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

a { color: inherit; text-decoration: none; }

/* ===================== HEADER (pleine largeur) ===================== */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 200;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
}

.app-header__brand {
  width: var(--sidebar-width);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  flex-shrink: 0;
}

.brand-logo {
  width: 34px; height: 34px;
  background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><defs><linearGradient id='m' x1='0' y1='0' x2='1' y2='1'><stop offset='0' stop-color='%236a717a'/><stop offset='.55' stop-color='%232a2e35'/><stop offset='1' stop-color='%23111418'/></linearGradient><linearGradient id='r' x1='0' y1='0' x2='1' y2='1'><stop offset='0' stop-color='%23ff4b3a'/><stop offset='1' stop-color='%23bf111d'/></linearGradient></defs><circle cx='50' cy='50' r='38' fill='none' stroke='url(%23m)' stroke-width='9'/><path d='M50 12 A38 38 0 0 1 87.2 42.1' fill='none' stroke='url(%23r)' stroke-width='9' stroke-linecap='round'/><line x1='50' y1='50' x2='33.5' y2='40.5' stroke='%2314171b' stroke-width='5' stroke-linecap='round'/><line x1='50' y1='50' x2='74.2' y2='36' stroke='%2314171b' stroke-width='3.4' stroke-linecap='round'/><circle cx='50' cy='50' r='4.6' fill='%2314171b'/><circle cx='50' cy='50' r='1.9' fill='%23ff4b3a'/></svg>") center / contain no-repeat;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  font-size: 15px;
  color: #5a5f67;
  letter-spacing: .3px;
  white-space: nowrap;
}

.app-header__meta {
  display: flex;
  align-items: center;
  gap: 18px;
  font-style: italic;
  font-size: 12.5px;
  color: var(--header-muted);
  padding-left: 6px;
}

.app-header__center {
  flex: 1;
  text-align: center;
  font-weight: 700;
  color: var(--header-text);
  font-style: normal;
}

.app-header__user {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
}
.app-header__user .user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: #c9ccd2; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.app-header__user .user-name { font-weight: 700; color: var(--header-text); }
.app-header__user .btn-logout {
  background: none; border: none; cursor: pointer;
  color: #6a6f77; font-size: 19px; padding: 4px;
  display: flex; align-items: center;
}
.app-header__user .btn-logout:hover { color: var(--oxy-red); }

/* Burger (mobile uniquement) + overlay */
.app-burger {
  display: none; background: none; border: none; cursor: pointer;
  font-size: 20px; color: #5a5f67; padding: 0 12px; align-items: center; height: 100%;
}
.sidebar-overlay {
  display: none; position: fixed; inset: var(--header-height) 0 0 0;
  background: rgba(0, 0, 0, .4); z-index: 150;
}
.sidebar-overlay.show { display: block; }

/* ===================== SIDEBAR ===================== */
.app-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--sidebar-top) 0%, var(--sidebar-bottom) 100%);
  overflow-y: auto;
  z-index: 150;
  padding-bottom: 20px;
}

.sidebar-section {
  color: var(--sidebar-section);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  padding: 18px 18px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  color: var(--sidebar-item);
  font-size: 14px;
  cursor: pointer;
  position: relative;
  transition: background var(--transition);
}
.nav-item i { width: 18px; text-align: center; font-size: 15px; opacity: .9; }
.nav-item:hover { background: var(--sidebar-hover); }
.nav-item.active { background: var(--sidebar-active); }

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--oxy-red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

/* ===================== CONTENU ===================== */
.app-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  padding: 28px 32px;
  background: var(--bg);
}

.page-title {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: #2f343c;
  letter-spacing: .3px;
  margin: 6px 0 4px;
}
.page-title-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0 26px;
}

/* ===================== BOUTONS ===================== */
.btn {
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 22px;
  color: #fff;
  transition: background var(--transition);
}
.btn:disabled { opacity: .65; cursor: default; }
.btn-violet { background: var(--btn-violet); }
.btn-violet:hover:not(:disabled) { background: var(--btn-violet-hover); }
.btn-blue { background: var(--btn-blue); }
.btn-blue:hover:not(:disabled) { background: var(--btn-blue-hover); }
.btn-lg { padding: 13px 34px; text-transform: uppercase; letter-spacing: .5px; }

/* ===================== FORMULAIRES ===================== */
.form-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.form-row > label {
  width: 140px;
  flex-shrink: 0;
  text-align: left;
  color: var(--text-muted);
  padding-top: 11px;
}
/* Champs & combos — style et HAUTEUR uniformes (calés sur COREX : 42px) */
.form-control,
select.form-control,
textarea.form-control {
  width: 100%;
  height: 42px;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  background: #fff;
}
/* Combos : rendu identique aux inputs + flèche personnalisée */
select.form-control {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6 9l6 6 6-6' fill='none' stroke='%23788089' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px;
}
textarea.form-control { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; }
.form-control:focus { outline: none; border-color: var(--btn-blue); }
.form-control::placeholder { color: #aab0b8; }

/* Pictogramme dans le champ / combo (comme COREX) */
.field { position: relative; display: block; }
.field > .fld-ico {
  position: absolute; left: 13px; top: 0; height: 42px;
  display: flex; align-items: center;
  color: var(--text-muted); font-size: 15px; pointer-events: none; z-index: 1;
}
.field > .form-control { padding-left: 38px; }
.field--area > .fld-ico { top: 12px; height: auto; }
.form-row > .field { flex: 1 1 auto; }

/* ===================== CARTE (encadré central) ===================== */
.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 30px;
}
.panel-title {
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  letter-spacing: .5px;
  margin-bottom: 22px;
}

/* ===================== HORLOGE ANALOGIQUE ===================== */
.clock-wrap { display: flex; justify-content: center; margin: 8px 0 30px; }
.analog-clock { display: block; }
.analog-clock .digital {
  font-size: 17px;
  font-weight: 700;
  fill: #2f343c;
}

/* ===================== TABLEAUX ===================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--table-head);
  color: #4a4f57;
  font-weight: 700;
  text-align: left;
  padding: 12px 10px;
  border: 1px solid var(--border);
  white-space: normal;
  word-break: break-word;
}
.data-table td {
  padding: 10px;
  border: 1px solid var(--border);
  white-space: normal;
  word-break: break-word;
}
.table-scroll { width: 100%; overflow-x: auto; }

/* Badges indicateurs durées */
.badge-time {
  display: inline-block;
  min-width: 64px;
  text-align: center;
  padding: 7px 12px;
  border-radius: var(--radius);
  font-weight: 700;
  color: #fff;
}
.badge-time.green { background: var(--ok-green); }
.badge-time.red { background: var(--alert-red); }

/* ===================== UTILITAIRES ===================== */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}
.toolbar label { color: var(--text-muted); }
.spacer { flex: 1; }
.text-alert { color: var(--alert-red); }
.muted { color: var(--text-muted); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1023px) {
  :root { --sidebar-width: 0px; }
  .app-sidebar { transform: translateX(-100%); transition: transform var(--transition); width: 210px; z-index: 210; }
  .app-sidebar.open { transform: translateX(0); box-shadow: 4px 0 18px rgba(0,0,0,.25); }
  .app-burger { display: flex; }
  .app-header__brand { width: auto; }
  .app-header__meta { display: none; }
  .app-header__center { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
  .app-content { padding: 18px 14px; }
  .form-row { flex-direction: column; gap: 6px; }
  .form-row > label { width: auto; padding-top: 0; }
  .form-row > .field { width: 100%; max-width: none !important; }
}
@media (max-width: 600px) {
  .brand-name { display: none; }
  .app-header__center { display: none; }
  .app-header__user { padding: 0 12px; }
  .app-header__user .user-name { display: none; }
  .field { width: 100% !important; max-width: none !important; }
}
