:root {
  --green: #1f6f43;
  --green-dark: #14502f;
  --green-light: #eaf3ee;
  --bg: #ffffff;
  --border: #d8ded9;
  --text: #1c2b22;
  --text-muted: #5b6b60;
  --danger: #b3261e;
  --danger-light: #fbeceb;
}

* { box-sizing: border-box; }

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

a { color: var(--green-dark); }

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

/* Bandeau superieur */
.topbar {
  background: var(--green-dark);
  color: #fff;
  padding: 12px 0;
}
.topbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.topbar .identity { font-weight: 600; }
.topbar form { margin: 0; }
.topbar button.logout {
  background: transparent;
  border: 1px solid #fff;
  color: #fff;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
}
.topbar button.logout:hover { background: rgba(255,255,255,0.15); }

/* Navigation */
nav.mainnav {
  background: var(--green-light);
  border-bottom: 1px solid var(--border);
}
nav.mainnav .container { display: flex; gap: 4px; flex-wrap: wrap; }
nav.mainnav a {
  display: inline-block;
  padding: 10px 14px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 3px solid transparent;
}
nav.mainnav a:hover, nav.mainnav a.active {
  border-bottom-color: var(--green);
  color: var(--green-dark);
  font-weight: 600;
}

main { padding: 24px 0 60px; }

h1 { font-size: 22px; margin: 0 0 20px; color: var(--green-dark); }
h2 { font-size: 17px; margin: 28px 0 12px; color: var(--green-dark); }

/* Cartes */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 20px;
}
.card + .card { margin-top: 16px; }

/* Formulaires */
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
input[type=text], input[type=password], input[type=email], input[type=time],
input[type=date], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  margin-bottom: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); border-color: var(--green); }
.field-error { color: var(--danger); font-size: 13px; margin: -10px 0 14px; }

button, .btn {
  display: inline-block;
  background: var(--green);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
}
button:hover, .btn:hover { background: var(--green-dark); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f4f6f4; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8a1e18; }
.btn-small { padding: 5px 12px; font-size: 13px; }

/* Tableaux */
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.table-wrap { overflow-x: auto; }

/* Badges de statut */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.badge-active { background: var(--green-light); color: var(--green-dark); }
.badge-absent { background: #fdf2d8; color: #8a6116; }
.badge-disabled, .badge-locked { background: var(--danger-light); color: var(--danger); }
.badge-inactive { background: #eee; color: #666; }

/* Alertes */
.alert { padding: 12px 16px; border-radius: 4px; margin-bottom: 18px; font-size: 14px; }
.alert-status { background: var(--green-light); color: var(--green-dark); border: 1px solid var(--green); }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger); }
.alert-credentials { background: #fff8e1; color: #6b5300; border: 1px solid #e0c34a; }
.alert-credentials code { background: #fff; padding: 2px 6px; border-radius: 3px; font-size: 15px; }

/* Page de connexion */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--green-light);
}
.auth-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 36px;
  width: 100%;
  max-width: 380px;
}
.auth-card h1 { text-align: center; margin-bottom: 24px; }
.auth-card button { width: 100%; padding: 10px; }

/* Confirmation par mot de passe (details/summary natif, sans JS) */
details.confirm-action {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 14px;
  margin: 8px 0;
}
details.confirm-action summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--green-dark);
}
details.confirm-action .confirm-body { margin-top: 12px; }

.schedule-grid { display: grid; grid-template-columns: 110px 1fr 100px 100px; gap: 8px 12px; align-items: center; }
.schedule-grid .head { font-weight: 600; font-size: 12px; color: var(--text-muted); text-transform: uppercase; }

.text-muted { color: var(--text-muted); font-size: 13px; }

@media (max-width: 640px) {
  .schedule-grid { grid-template-columns: 90px 1fr 1fr 1fr; }
  nav.mainnav .container { gap: 0; }
}

/* ==========================================================================
   Portail demandeurs (Module 3) — ajouts Etape 4.
   Reutilise integralement la palette et les classes ci-dessus (.auth-page,
   .auth-card, .card, .alert-*, .btn*, champs...). Rien n'est redefini,
   seulement complete : RTL, bascule de langue, boite de code.
   ========================================================================== */

/* Support RTL (langue arabe). Le conteneur porte dir="rtl" ; on inverse les
   marges/alignements qui dependent du sens de lecture. Les proprietes
   "logiques" (padding-inline, etc.) suffisent pour le reste. */
html[dir="rtl"] body { direction: rtl; }
html[dir="rtl"] .topbar .container,
html[dir="rtl"] nav.mainnav .container { flex-direction: row-reverse; }
html[dir="rtl"] th, html[dir="rtl"] td { text-align: right; }
html[dir="rtl"] label { text-align: right; }

/* Bascule de langue manuelle (lien AR|EN), sur les pages du portail. */
.lang-switch {
  text-align: center;
  margin-bottom: 18px;
  font-size: 13px;
}
.lang-switch a {
  padding: 2px 8px;
  text-decoration: none;
  color: var(--text-muted);
  border-radius: 3px;
}
.lang-switch a.active {
  color: var(--green-dark);
  font-weight: 600;
  background: var(--green-light);
}
.lang-switch span.sep { color: var(--border); margin: 0 2px; }

/* Boite de saisie du code de verification : grand, espace, centre. */
.code-input {
  width: 100%;
  padding: 12px;
  font-size: 22px;
  letter-spacing: 8px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 14px;
  font-family: inherit;
}
.code-input:focus { outline: 2px solid var(--green); border-color: var(--green); }

/* Liens secondaires sous les formulaires d'authentification (mot de passe
   oublie, retour a la connexion, etc.). */
.auth-links {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
}
.auth-links a { display: block; margin-top: 6px; }

/* Boite d'aide/notice sous un formulaire (ex. renvoi de code). */
.notice-box {
  background: var(--green-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* Masque visuellement un label tout en le gardant accessible aux lecteurs
   d'ecran (utilise sur le champ code : le contexte visuel suffit). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Portail demandeurs (Module 3) — Landing institutionnelle v3.
   Bloc hors-cadre (institutional-header) affiche via le yield page_header
   de guest.blade.php, actif uniquement sur home.blade.php. Aucun impact
   sur login/register/password (yield vide par defaut sur ces pages).
   ========================================================================== */

.institutional-header {
  text-align: center;
  margin-bottom: 28px;
}

.institutional-logo {
  display: block;
  width: 100px;
  height: 100px;
  margin: 0 auto 16px;
  object-fit: contain;
}

.institutional-country {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
  color: var(--green-dark);
  line-height: 1.3;
}

.institutional-consulate {
  margin: 0;
  font-size: 25px;
  font-weight: 600;
  color: var(--green-dark);
  line-height: 1.3;
}

.institutional-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 18px auto 0;
  max-width: 220px;
}

.institutional-separator::before,
.institutional-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #c9a227;
}

.institutional-separator span {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 10px;
  background: #c9a227;
  transform: rotate(45deg);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .institutional-header {
    margin-bottom: 20px;
    padding: 0 16px;
  }
  .institutional-logo {
    width: 75px;
    height: 75px;
    margin-bottom: 12px;
  }
  .institutional-country {
    font-size: 20px;
  }
  .institutional-consulate {
    font-size: 19px;
  }
  .institutional-separator {
    margin-top: 14px;
  }
}

/* ==========================================================================
   Portail demandeurs — correctif minimal liste "Mes dossiers"
   (cases/index.blade.php). La liste n'avait aucun style dedie (vue
   TEMPORAIRE Etape 5) : puces natives du navigateur + alignement RTL par
   defaut produisaient un rendu colle a droite, sans separation entre
   lignes, boutons de largeur variable. Correctif limite a l'alignement et
   a l'espacement - pas de refonte, la vue reste marquee TEMPORAIRE.
   ========================================================================== */

.case-file-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  max-width: 700px;
}

.case-file-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.case-file-list li:first-child {
  border-top: 1px solid var(--border);
}

.case-file-list .btn-danger.btn-small {
  min-width: 110px;
  text-align: center;
  flex-shrink: 0;
}
