/* ============================================================
   Riad Le Ksar de Fès — Thème Fassi · Sidebar
   Bleu de Fès · laiton doré · plâtre crème
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #16406e;
  --navy-deep: #0b2440;
  --navy-ink: #071a30;
  --gold: #c1922f;
  --gold-light: #e0b95f;
  --cream: #f7f2e6;
  --cream-dark: #e9dfc8;
  --paper: #fffdf7;
  --ink: #23211c;
  --muted: #8a7f66;
  --ok: #2e7d4f;
  --err: #b03a2e;
  --side-w: 250px;
}

html, body { height: 100%; }
body {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
}
h1, h2, legend, .side-title, .stat-num, .fiche-head h1 {
  font-family: Georgia, "Times New Roman", serif;
}

/* ---------- Zellige strip (signature) ---------- */
.zellige {
  height: 7px;
  background:
    repeating-linear-gradient(45deg,
      var(--gold) 0 8px,
      transparent 8px 16px,
      var(--gold-light) 16px 24px,
      transparent 24px 32px);
  opacity: .9;
  margin: 4px 18px 10px;
  border-radius: 4px;
}

/* ============================================================
   LAYOUT : sidebar + content
   ============================================================ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--side-w);
  background: linear-gradient(180deg, var(--navy-deep) 0%, var(--navy-ink) 100%);
  color: var(--cream);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 50;
  box-shadow: 4px 0 18px rgba(7,26,48,.25);
}

.side-brand { text-align: center; padding: 26px 16px 14px; }
.side-logo {
  width: 104px; height: 104px; object-fit: contain;
  background: var(--cream);
  border: 2px solid var(--gold);
  border-radius: 50%;                /* logo rond */
  padding: 9px;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.side-title { font-size: 26px; margin-top: 12px; letter-spacing: 1px; color: #fff; }
.side-sub { font-size: 11px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--gold-light); margin-top: 3px; }

.side-nav { display: flex; flex-direction: column; padding: 8px 12px; gap: 4px; }
.side-link {
  display: flex; align-items: center; gap: 12px;
  color: #cfd9e6; text-decoration: none;
  font-size: 14.5px; font-weight: 600;
  padding: 12px 14px; border-radius: 8px;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.side-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-link.active {
  background: rgba(193,146,47,.16);
  border-left-color: var(--gold);
  color: var(--gold-light);
}
.side-ico { width: 20px; text-align: center; font-size: 16px; }

.side-bottom { margin-top: auto; padding: 16px; border-top: 1px solid rgba(255,255,255,.09); }
.side-user { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #e8e2d2; margin-bottom: 12px; }
.side-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gold); color: var(--navy-ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
}
.side-logout {
  display: block; text-align: center;
  color: var(--cream); text-decoration: none; font-size: 13px; font-weight: 600;
  border: 1px solid rgba(255,255,255,.25); border-radius: 6px; padding: 8px;
  transition: background .15s;
}
.side-logout:hover { background: var(--err); border-color: var(--err); color: #fff; }

/* ---------- Content ---------- */
.content { flex: 1; margin-left: var(--side-w); display: flex; flex-direction: column; min-height: 100vh; }
.container { max-width: 1150px; width: 100%; margin: 0 auto; padding: 28px 26px 50px; flex: 1; }
.page-title { font-size: 26px; color: var(--navy-deep); margin-bottom: 18px; }

.mobilebar { display: none; }
.overlay { display: none; }

.footer { background: transparent; color: var(--muted); }
.footer p { text-align: center; padding: 16px; font-size: 12.5px; }

/* ---------- Cards ---------- */
.card {
  background: var(--paper); border: 1px solid var(--cream-dark);
  border-radius: 12px; padding: 24px;
  box-shadow: 0 3px 14px rgba(11,36,64,.06);
}

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--paper); border: 1px solid var(--cream-dark);
  border-radius: 12px; padding: 18px;
  position: relative; overflow: hidden;
}
.stat:before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--gold), var(--gold-light));
}
.stat-num { display: block; font-size: 32px; color: var(--navy); line-height: 1.1; }
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.search-form { display: flex; gap: 8px; flex: 1; min-width: 260px; }
.search-form input { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none; text-align: center;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-light); color: var(--navy-ink); }
.btn-navy { background: var(--navy); color: var(--cream); }
.btn-navy:hover { background: var(--navy-deep); }
.btn-plain { background: transparent; color: var(--navy); border-color: #c8bda0; }
.btn-plain:hover { background: var(--navy); color: var(--cream); border-color: var(--navy); }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 700; color: var(--navy-deep); margin: 0 0 5px; }
input, select, textarea {
  width: 100%; padding: 10px 11px; border: 1px solid #d5c9ab; border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(193,146,47,.2); }
.input-ro { background: var(--cream); font-weight: 800; color: var(--navy); text-align: center; }

fieldset { border: 1px solid var(--cream-dark); border-radius: 10px; padding: 18px; margin-bottom: 18px; background: #fff; }
legend { padding: 0 10px; color: var(--gold); font-size: 17px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 12px; }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 12px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-ok { background: #e5f2ea; color: var(--ok); border: 1px solid #bcdcc9; }
.alert-error { background: #f9e8e6; color: var(--err); border: 1px solid #ecc4bf; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--cream-dark); border-radius: 12px; box-shadow: 0 3px 14px rgba(11,36,64,.05); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 920px; }
.table th {
  background: var(--navy-deep); color: var(--cream); text-align: left;
  padding: 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; white-space: nowrap;
}
.table th:first-child { border-top-left-radius: 11px; }
.table th:last-child { border-top-right-radius: 11px; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--cream-dark); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fbf6e9; }
.td-strong { font-weight: 700; color: var(--navy-deep); }
.empty { text-align: center; color: var(--muted); padding: 34px !important; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge-cin { background: #e4ecf5; color: var(--navy); }
.badge-pass { background: #f6ecd4; color: #96701e; }

.td-actions { white-space: nowrap; }
.act { text-decoration: none; font-size: 12.5px; font-weight: 700; margin-right: 4px; padding: 4px 9px; border-radius: 6px; }
.act-view { color: var(--navy); background: #e9eff6; }
.act-edit { color: #96701e; background: #f6ecd4; }
.act-del { color: var(--err); background: #f9e8e6; }
.act:hover { filter: brightness(.93); }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  background: var(--navy-ink);
  background-image:
    repeating-linear-gradient(45deg, rgba(193,146,47,.05) 0 26px, transparent 26px 52px),
    repeating-linear-gradient(-45deg, rgba(247,242,230,.03) 0 26px, transparent 26px 52px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: var(--cream); border-top: 6px solid var(--gold);
  border-radius: 14px; padding: 36px 34px; width: 100%; max-width: 390px; text-align: center;
  box-shadow: 0 22px 60px rgba(0,0,0,.5);
}
.login-logo {
  width: 132px; height: 132px; object-fit: contain; margin-bottom: 10px;
  border: 2px solid var(--gold); border-radius: 50%; padding: 10px; background: #fff;
}
.login-card h1 { color: var(--navy-deep); font-size: 27px; }
.login-sub { color: var(--gold); font-size: 12px; letter-spacing: 3px; text-transform: uppercase; margin: 4px 0 20px; }
.login-card form { text-align: left; }
.login-card label { margin-top: 12px; }
.login-card .btn { margin-top: 22px; }

/* ---------- Fiche ---------- */
.fiche-actions { display: flex; gap: 10px; margin-bottom: 16px; }
.fiche { max-width: 860px; margin: 0 auto; }
.fiche-head { display: flex; align-items: center; gap: 18px; border-bottom: 3px double var(--gold); padding-bottom: 14px; margin-bottom: 18px; }
.fiche-logo { width: 76px; height: 76px; object-fit: contain; }
.fiche-head h1 { font-size: 24px; color: var(--navy-deep); }
.fiche-sub { font-size: 13px; color: var(--muted); }
.fiche-num { margin-left: auto; font-family: Georgia, serif; font-size: 18px; color: var(--gold); white-space: nowrap; }

.fiche-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.fiche-table th {
  text-align: left; background: var(--cream); color: var(--navy-deep);
  padding: 9px 12px; width: 18%; border: 1px solid var(--cream-dark); font-size: 12.5px;
}
.fiche-table td { padding: 9px 12px; border: 1px solid var(--cream-dark); width: 32%; background: #fff; }

.fiche-sign { display: flex; gap: 60px; margin-top: 34px; }
.fiche-sign p { font-size: 13px; color: var(--muted); margin-bottom: 34px; }
.sign-line { border-bottom: 1px solid var(--ink); width: 220px; }
.fiche-date { margin-top: 22px; font-size: 12px; color: var(--muted); text-align: right; }

/* ---------- Print ---------- */
@media print {
  .sidebar, .mobilebar, .footer, .fiche-actions, .no-print, .overlay { display: none !important; }
  body { background: #fff; }
  .content { margin-left: 0; }
  .container { padding: 0; max-width: 100%; }
  .fiche { border: none; box-shadow: none; padding: 0; }
}

/* ============================================================
   MOBILE : sidebar coulissante
   ============================================================ */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .content { margin-left: 0; }

  .mobilebar {
    display: flex; align-items: center; gap: 14px;
    background: var(--navy-deep); color: var(--cream);
    padding: 12px 16px; position: sticky; top: 0; z-index: 40;
  }
  .burger {
    background: none; border: 1px solid rgba(255,255,255,.3); color: var(--cream);
    font-size: 20px; padding: 4px 10px; border-radius: 6px; cursor: pointer;
  }
  .mobile-title { font-family: Georgia, serif; font-size: 18px; letter-spacing: .5px; }

  .overlay.show {
    display: block; position: fixed; inset: 0;
    background: rgba(7,26,48,.55); z-index: 45;
  }

  .container { padding: 20px 16px 40px; }
  .stat-num { font-size: 26px; }
  .fiche-sign { flex-direction: column; gap: 20px; }
  .toolbar { flex-direction: column; align-items: stretch; }
}

/* ============================================================
   TOUCHES ZELLIJ MAROCAIN + ICÔNES SVG
   ============================================================ */

/* Motif khatam (étoile 8 branches) discret dans la sidebar */
.zellij-bg {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23e0b95f' stroke-width='1' opacity='0.10'%3E%3Crect x='16' y='16' width='24' height='24'/%3E%3Crect x='16' y='16' width='24' height='24' transform='rotate(45 28 28)'/%3E%3Ccircle cx='28' cy='28' r='4'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(180deg, var(--navy-deep) 0%, var(--navy-ink) 100%);
}

/* Même motif, très léger, sur la page de connexion */
.login-body {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23c1922f' stroke-width='1' opacity='0.12'%3E%3Crect x='21' y='21' width='30' height='30'/%3E%3Crect x='21' y='21' width='30' height='30' transform='rotate(45 36 36)'/%3E%3Ccircle cx='36' cy='36' r='5'/%3E%3C/g%3E%3C/svg%3E");
}

/* Séparateur khatam : ligne — étoile — ligne */
.khatam-divider {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--gold-light); margin: 14px 18px 4px;
}
.khatam-divider .kh-line { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); max-width: 70px; }
.khatam-divider .kh-line:last-child { background: linear-gradient(90deg, var(--gold), transparent); }
.khatam-divider.dark { color: var(--gold); margin: 2px 0 18px; justify-content: flex-start; }
.khatam-divider.dark .kh-line { max-width: 46px; background: linear-gradient(90deg, transparent, var(--gold)); }
.khatam-divider.dark .kh-line:first-child { display: none; }

.section-head .page-title { margin-bottom: 4px; }

/* Icônes SVG alignées dans boutons et liens */
.ico { vertical-align: -3px; }
.btn .ico { margin-right: 4px; }
.side-link .ico { flex-shrink: 0; }
.side-logout { display: flex; align-items: center; justify-content: center; gap: 7px; }

/* Cartes stats cliquables avec icône */
.stat { text-decoration: none; color: inherit; transition: transform .12s, box-shadow .12s; }
.stat:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(11,36,64,.12); }
.stat-ico {
  position: absolute; right: 14px; top: 14px;
  color: var(--gold); opacity: .55;
}

/* Boutons d'action du tableau : pastilles carrées icône */
.act {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; border-radius: 8px; margin-right: 5px;
}
.act .ico { vertical-align: 0; }

.toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; }

/* Coin supérieur du tableau : filet doré */
.table-wrap { border-top: 3px solid var(--gold); }

@media (max-width: 860px) {
  .toolbar-right { justify-content: stretch; }
  .toolbar-right .btn { flex: 1; }
}


/* ============================================================
   RÔLES + CONFIDENTIALITÉS + LE GOLF
   ============================================================ */
.side-user-info { display: flex; flex-direction: column; line-height: 1.2; }
.side-role { font-size: 10.5px; color: var(--gold-light); text-transform: uppercase; letter-spacing: 1.2px; }

.page-intro { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

.users-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; }
.user-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.side-avatar.big { width: 44px; height: 44px; font-size: 19px; }
.user-card-name { font-weight: 800; font-size: 17px; color: var(--navy-deep); }
.user-card-desc { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; min-height: 34px; }
.user-card label { margin-top: 10px; }
.user-card .btn { margin-top: 14px; }

.role-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .5px;
}
.role-admin { background: #f6ecd4; color: #96701e; }
.role-gerant { background: #e4ecf5; color: var(--navy); }
.role-reception { background: #e5f2ea; color: var(--ok); }

/* Badge Golf dans le tableau */
.badge-golf {
  background: #e5f2ea; color: var(--ok);
  display: inline-flex; align-items: center; gap: 4px;
}

/* Case à cocher générique (style tuile) */
.check-tile {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: #fff; border: 1px solid #d5c9ab; border-radius: 8px;
  padding: 10px 12px; font-weight: 600; color: var(--ink);
}
.check-tile input { display: none; }
.check-tile .check-box {
  width: 20px; height: 20px; border: 2px solid #c8bda0; border-radius: 5px;
  flex-shrink: 0; position: relative; background: #fff;
}
.check-tile input:checked + .check-box { background: var(--gold); border-color: var(--gold); }
.check-tile input:checked + .check-box:after {
  content: ""; position: absolute; left: 5px; top: 1px;
  width: 5px; height: 10px; border: solid #fff; border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.check-tile input:checked ~ .check-text { color: var(--gold); }
.check-tile .check-text { display: inline-flex; align-items: center; gap: 6px; }


/* ============================================================
   PERMISSIONS (page Confidentialités)
   ============================================================ */
.perm-block {
  margin-top: 16px; padding: 14px;
  background: var(--cream); border: 1px solid var(--cream-dark); border-radius: 8px;
}
.perm-head {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px;
  color: var(--navy-deep); margin-bottom: 10px;
}
.perm-all {
  margin-left: auto; background: none; border: 1px solid var(--gold); color: var(--gold);
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 9px; border-radius: 999px; cursor: pointer;
}
.perm-all:hover { background: var(--gold); color: #fff; }

.perm-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 4px; cursor: pointer; margin: 0;
  font-weight: 500; font-size: 13.5px; color: var(--ink);
  border-bottom: 1px dashed rgba(0,0,0,.06);
}
.perm-row:last-child { border-bottom: none; }
.perm-row:hover { color: var(--navy); }
.perm-row input { display: none; }
.perm-row .check-box { width: 18px; height: 18px; }
.perm-row input:checked + .check-box { background: var(--gold); border-color: var(--gold); }
.perm-row input:checked + .check-box:after {
  content: ""; position: absolute; left: 4.5px; top: 0.5px;
  width: 5px; height: 9px; border: solid #fff; border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.perm-row input:checked ~ .perm-label { color: var(--navy-deep); font-weight: 700; }
.perm-locked {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); font-style: italic;
}

/* Page restreinte */
.restricted { text-align: center; padding: 46px 24px; color: var(--muted); max-width: 520px; margin: 0 auto; }
.restricted .ico { color: var(--gold); margin-bottom: 10px; }
.restricted h2 { color: var(--navy-deep); font-size: 21px; margin-bottom: 8px; }
.restricted p { font-size: 14px; margin-bottom: 18px; }
.muted-note { font-size: 13px; font-style: italic; }
