/* ═══════════════════════════════════════════════════════
   بلانيبرو — Feuille de style (RTL / Arabe)
   ═══════════════════════════════════════════════════════ */

/* ── Variables & reset ─────────────────────────────────── */
:root {
    --primary:        #3B5BDB;
    --primary-dark:   #2F4AC0;
    --primary-light:  #EEF2FF;
    --green:          #10B981;
    --green-light:    #D1FAE5;
    --green-dark:     #059669;
    --red:            #EF4444;
    --red-light:      #FEE2E2;

    --bg:             #F0F4FF;
    --surface:        #FFFFFF;
    --border:         #CBD5E1;
    --border-light:   #E2E8F0;
    --gap-color:      #C7D2F0;

    --text-dark:      #1E293B;
    --text-mid:       #475569;
    --text-light:     #94A3B8;

    --radius-sm:      6px;
    --radius-md:      12px;
    --radius-lg:      16px;

    --shadow-md:      0 4px 16px rgba(59,91,219,.10), 0 1px 4px rgba(0,0,0,.06);
    --transition:     150ms cubic-bezier(.4,0,.2,1);

    /* Police arabe */
    --font: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* RTL géré par dir="rtl" dans le HTML */
}

/* ── En-tête ───────────────────────────────────────────── */
.header {
    background: var(--primary);
    box-shadow: 0 2px 12px rgba(59,91,219,.3);
}

.header-inner {
    max-width: 1020px;
    margin: 0 auto;
    padding: 18px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon { width: 40px; height: 40px; flex-shrink: 0; }

.brand-name {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0;
}

.brand-tagline {
    color: rgba(255,255,255,.7);
    font-size: 0.9rem;
    /* Séparateur côté gauche en RTL = border-left */
    border-left: 1px solid rgba(255,255,255,.3);
    padding-left: 20px;
    margin-left: 4px;
}

/* ── Layout principal ──────────────────────────────────── */
.main {
    flex: 1;
    max-width: 1020px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Cartes ────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 24px;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.card-title svg {
    width: 18px;
    height: 18px;
    color: var(--primary);
    flex-shrink: 0;
}

/* ── Carte setup ───────────────────────────────────────── */
.setup-card { padding: 20px 24px; }

.setup-form .field-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-mid);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.input-row {
    display: flex;
    gap: 10px;
}

.text-input {
    flex: 1;
    height: 44px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    font-family: var(--font);
    font-size: 1rem;
    color: var(--text-dark);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    text-align: right; /* RTL text alignment */
}

.text-input::placeholder { color: var(--text-light); }

.text-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,91,219,.12);
}

.last-update {
    margin-top: 12px;
    font-size: 0.82rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 5px;
}

.last-update svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ── Alertes ───────────────────────────────────────────── */
.alert {
    border-radius: var(--radius-md);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 600;
}

.alert svg { width: 22px; height: 22px; flex-shrink: 0; }

.alert--success {
    background: var(--green-light);
    color: var(--green-dark);
    border: 1px solid #6EE7B7;
}

.alert--error {
    background: var(--red-light);
    color: #B91C1C;
    border: 1px solid #FCA5A5;
}

/* ── Carte grille ──────────────────────────────────────── */
.grid-card { padding: 24px 24px 20px; }

.grid-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.grid-hint {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* ── Badge compteur ────────────────────────────────────── */
.counter-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-light);
    border: 1.5px solid var(--primary);
    border-radius: 999px;
    padding: 6px 16px;
    flex-shrink: 0;
}

.counter-num {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.counter-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
}

/* ════════════════════════════════════════════════════════
   GRILLE EMPLOI DU TEMPS
   ════════════════════════════════════════════════════════ */
.schedule-grid {
    display: grid;
    /* colonne heure + colonnes des jours */
    grid-template-columns: 72px repeat(var(--cols, 6), 1fr);
    gap: 2px;
    background: var(--gap-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--gap-color);
}

.grid-corner,
.day-header,
.time-label,
.slot {
    background: var(--surface);
}

/* ── Coin vide ── */
.grid-corner {
    background: var(--primary-light);
}

/* ── En-têtes des jours ── */
.day-header {
    background: var(--primary);
    color: white;
    text-align: center;
    padding: 11px 4px;
    font-size: 0.85rem;
    font-weight: 700;
    user-select: none;
}

.day-short { display: none; }
.day-full  { display: block; }

/* ── Étiquettes d'heure ── */
.time-label {
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    padding: 0 4px;
    user-select: none;
    font-variant-numeric: tabular-nums;
    min-height: 46px;
    /* Les heures restent en LTR même en RTL */
    direction: ltr;
    unicode-bidi: isolate;
}

/* ── Créneaux cliquables ── */
.slot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    cursor: pointer;
    background: var(--border-light);
    transition: background-color var(--transition);
}

.slot:hover { background: #DDE6FF; }

.slot--active         { background: var(--green-light); }
.slot--active:hover   { background: #A7F3D0; }

.slot input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Icône check */
.slot-check {
    width: 18px;
    height: 18px;
    opacity: 0;
    transform: scale(.5);
    transition: opacity var(--transition), transform var(--transition);
}

.slot--active .slot-check {
    opacity: 1;
    transform: scale(1);
}

.slot--active .slot-check path {
    stroke: var(--green-dark);
}

/* ── Actions du formulaire ── */
.form-actions {
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.legend {
    display: flex;
    gap: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.85rem;
    color: var(--text-mid);
    font-weight: 500;
}

.legend-dot {
    width: 15px;
    height: 15px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-dot--available   { background: var(--green-light); border: 1.5px solid var(--green); }
.legend-dot--unavailable { background: var(--border-light); border: 1.5px solid var(--border); }

/* ── Boutons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 44px;
    padding: 0 20px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; }

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

.btn-ghost {
    background: transparent;
    color: var(--text-mid);
    border: 1.5px solid var(--border);
}
.btn-ghost:hover {
    background: var(--border-light);
    color: var(--text-dark);
}

.btn-save {
    background: var(--green);
    color: white;
}
.btn-save:hover { background: var(--green-dark); }

.action-btns {
    display: flex;
    gap: 10px;
}

/* ── Pied de page ──────────────────────────────────────── */
.footer {
    text-align: center;
    padding: 20px;
    font-size: 0.82rem;
    color: var(--text-light);
    margin-top: auto;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 720px) {
    .header-inner   { flex-direction: column; align-items: flex-start; gap: 6px; }
    .brand-tagline  { border: none; padding: 0; margin: 0; font-size: 0.82rem; }
    .main           { padding: 14px; gap: 14px; }
    .card           { padding: 14px; border-radius: var(--radius-md); }

    .schedule-grid {
        grid-template-columns: 52px repeat(var(--cols, 6), 1fr);
    }

    .time-label { font-size: 0.62rem; padding: 0 2px; min-height: 38px; }
    .day-header { padding: 8px 2px; font-size: 0.72rem; }
    .day-full   { display: none; }
    .day-short  { display: block; }
    .slot       { min-height: 38px; }
    .slot-check { width: 14px; height: 14px; }

    .form-actions   { flex-direction: column; align-items: stretch; }
    .action-btns    { justify-content: flex-end; }
    .legend         { justify-content: center; }
}

@media (max-width: 460px) {
    .input-row      { flex-direction: column; }
    .btn-primary    { justify-content: center; }
    .grid-header    { flex-direction: column; }
}

/* ══════════════════════════════════════════════════════════
   AUTHENTIFICATION — Pages login / register
   ══════════════════════════════════════════════════════════ */

/* ── Layout centré pour les pages auth ──────────────────── */
.auth-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px 16px;
}

.auth-box {
    width: 100%;
    max-width: 440px;
}

/* ── Logo sur les pages auth ─────────────────────────────── */
.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}

/* ── Carte auth ──────────────────────────────────────────── */
.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 36px 32px;
}

.auth-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-dark);
    text-align: center;
    margin-bottom: 6px;
}

.auth-subtitle {
    font-size: 0.9rem;
    color: var(--text-light);
    text-align: center;
    margin-bottom: 28px;
}

/* ── Champs auth ─────────────────────────────────────────── */
.auth-fields {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.field-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-mid);
    margin-bottom: 7px;
    letter-spacing: 0.01em;
}

.auth-input {
    width: 100%;
    height: 46px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    font-family: var(--font);
    font-size: 0.97rem;
    color: var(--text-dark);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    text-align: right;
}

.auth-input::placeholder { color: var(--text-light); }

.auth-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,91,219,.12);
}

/* ── Champ mot de passe avec icône œil ───────────────────── */
.password-wrapper {
    position: relative;
}

.toggle-eye {
    position: absolute;
    left: 12px;      /* côté gauche en RTL = côté visuel gauche */
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-light);
    line-height: 0;
    transition: color var(--transition);
}

.toggle-eye:hover { color: var(--primary); }

.eye-icon {
    width: 18px;
    height: 18px;
    display: block;
    transition: opacity var(--transition);
}

/* ── Bouton principal auth ───────────────────────────────── */
.btn-auth {
    width: 100%;
    height: 48px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background var(--transition), transform 80ms;
}

.btn-auth:hover  { background: var(--primary-dark); }
.btn-auth:active { transform: scale(.98); }

/* ── Lien bascule login ↔ register ──────────────────────── */
.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-mid);
}

.auth-switch a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.auth-switch a:hover { text-decoration: underline; }


/* ══════════════════════════════════════════════════════════
   BARRE UTILISATEUR — En-tête de index.php
   ══════════════════════════════════════════════════════════ */

.header-inner {
    justify-content: space-between;   /* brand à droite, user-bar à gauche */
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.user-name {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255,255,255,.9);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,.3);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--transition), border-color var(--transition);
}

.btn-logout svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-logout:hover {
    background: rgba(255,255,255,.28);
    border-color: rgba(255,255,255,.55);
}

/* ── Responsive auth ──────────────────────────────────────── */
@media (max-width: 480px) {
    .auth-card   { padding: 24px 18px; }
    .auth-title  { font-size: 1.1rem; }
    .user-name   { display: none; }  /* masquer le nom sur petit écran, garder le bouton */
}

/* Chips de niveau */
.level-chip {
    padding: 8px 16px;
    background: #f1f3f5;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.level-chip:hover {
    background: #e9ecef;
}

.level-chip--active {
    background: #fff4e6;
    color: #f76707;
    border-color: #ffd8a8;
}

/* Amlioration des puces de niveau */
.level-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.level-chip:hover {
    border-color: #dee2e6;
    background: #f8f9fa;
    transform: translateY(-1px);
}

.level-chip--active {
    background: #fff4e6;
    color: #f76707;
    border-color: #f76707;
    box-shadow: 0 4px 12px rgba(247, 103, 7, 0.15);
}

.level-chip--active::before {
    content: '';
    width: 18px;
    height: 18px;
    background-image: url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 20 20%22 fill=%22%23f76707%22%3E%3Cpath fill-rule=%22evenodd%22 d=%22M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z%22 clip-rule=%22evenodd%22/%3E%3C/svg%3E');
    background-size: contain;
    background-repeat: no-repeat;
}
