/*
  Feuille de style admin web — conforme à la Charte Graphique ISITEC International 2026.
  Couleurs : Bleu Isitec #019DE0 (primaire), Bleu nuit #1C1D3D (textes/headers), Gris #747374.
  Typo web : Montserrat (700 titres, 500/400 corps). Forme signature : hexagone (favicon + accents).
  Aucune couleur hors charte (rouge/vert/orange) sauf statuts métier indispensables (erreur, succès)
  qui restent dans une palette désaturée pour rester lisibles à côté du bleu Isitec.
*/

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {
    /* Palette ISITEC */
    --isitec-blue: #019DE0;
    --isitec-blue-dark: #007EB4;          /* hover/active du bleu principal */
    --isitec-blue-night: #1C1D3D;         /* textes, headers, contrastes forts */
    --isitec-gray: #747374;               /* textes secondaires, séparateurs */
    --isitec-blue-light: #E6F5FC;         /* fond doux, bannières d'info */
    --isitec-blue-night-soft: #2A2C60;    /* variantes pour cards/borders */

    /* Mappings sémantiques (les noms restent identiques à l'ancienne version pour ne
       pas casser les class names utilisés dans les Razor pages) */
    --bg: #FFFFFF;
    --card: #FFFFFF;
    --border: #E2E8F0;
    --text: var(--isitec-blue-night);
    --muted: var(--isitec-gray);
    --primary: var(--isitec-blue);
    --primary-hover: var(--isitec-blue-dark);

    /* Statuts métier — désaturés pour rester en harmonie avec le bleu Isitec dominant */
    --success: #2E7D5B;
    --warning: #B07300;
    --danger: #B33A3A;
    --pending: var(--isitec-blue-night);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Montserrat', 'Helvetica', Arial, sans-serif;
    background: #F6F8FB;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ───────────────────────────────── Topbar ───────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    height: 60px;
    background: var(--isitec-blue-night);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(28, 29, 61, 0.12);
}
.topbar .brand a {
    color: #FFFFFF;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}
/* Logo ISILeads dans la topbar — version mark (icône carrée) à gauche du libellé. */
.topbar .brand a .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: block;
}
.topnav {
    display: flex;
    align-items: center;
    gap: 20px;
}
.topnav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
}
.topnav a:hover { color: #FFFFFF; }
.topnav .who {
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    font-weight: 400;
}
.logout-form { margin: 0; }
.link-button {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    font: inherit;
    padding: 0;
    font-weight: 500;
}
.link-button:hover { color: #FFFFFF; }

/* ─────────────────────────────── Conteneurs ─────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 28px auto;
    padding: 0 28px;
}

.footer {
    text-align: center;
    color: var(--muted);
    padding: 28px;
    font-size: 12px;
    font-weight: 400;
}

h1, h2 { font-weight: 700; letter-spacing: -0.01em; }
h1 {
    font-size: 24px;
    margin: 0 0 18px;
    color: var(--isitec-blue-night);
}
h2 {
    font-size: 17px;
    margin: 0 0 12px;
    color: var(--isitec-blue-night);
}

a { color: var(--isitec-blue); text-decoration: none; }
a:hover { color: var(--isitec-blue-dark); text-decoration: underline; }

/* ───────────────────────────────── Cards ────────────────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 22px;
    margin-bottom: 16px;
    box-shadow: 0 1px 2px rgba(28, 29, 61, 0.04);
}

/* ─────────────────────────────── Notifications ──────────────────────────── */
.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 500;
    font-size: 13px;
    border-left: 4px solid;
}
.flash-info {
    background: var(--isitec-blue-light);
    color: var(--isitec-blue-night);
    border-color: var(--isitec-blue);
}
.flash-error {
    background: #FBEEEE;
    color: var(--danger);
    border-color: var(--danger);
}

/* ───────────────────────────────── Tables ───────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
th, td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
th {
    background: #F6F8FB;
    font-weight: 600;
    color: var(--isitec-blue-night);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.06em;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFBFD; }

/* ───────────────────────────────── Badges ───────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-pending { background: var(--isitec-blue-night); color: #FFFFFF; }
.badge-queued  { background: var(--isitec-blue); color: #FFFFFF; }
.badge-synced  { background: #DCEFE3; color: var(--success); }
.badge-error   { background: #FBEEEE; color: var(--danger); }
.badge-draft   { background: #E7E9EE; color: var(--muted); }
.badge-super   {
    background: #FFFFFF;
    color: var(--isitec-blue);
    margin-left: 8px;
    font-size: 9px;
    border: 1px solid var(--isitec-blue);
}

/* Badge sidebar : pastille à droite du libellé, rouge quand > 0, gris discret quand 0. */
.sidebar-badge {
    margin-left: auto;
    background: var(--danger, #d33);
    color: #FFFFFF;
    text-transform: none;
    letter-spacing: 0;
    padding: 2px 7px;
    font-size: 11px;
    min-width: 18px;
    text-align: center;
}
.sidebar-badge.badge-zero {
    display: none;
}
.app-sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
}
/* Onglets de la page Validation/Index — état actif visuellement marqué. */
.tabbar .btn.active {
    background: var(--isitec-blue);
    color: #FFFFFF;
    border-color: var(--isitec-blue);
}

.urgence-chaud      { color: var(--danger); font-weight: 700; }
.urgence-tiede      { color: var(--warning); font-weight: 600; }
.urgence-froid      { color: var(--isitec-blue); font-weight: 500; }
.urgence-aqualifier { color: var(--muted); }

/* ───────────────────────────────── Boutons ──────────────────────────────── */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #FFFFFF;
    color: var(--isitec-blue-night);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover {
    background: #F6F8FB;
    border-color: var(--isitec-blue);
    color: var(--isitec-blue);
    text-decoration: none;
}
.btn-primary {
    background: var(--isitec-blue);
    color: #FFFFFF;
    border-color: var(--isitec-blue);
}
.btn-primary:hover {
    background: var(--isitec-blue-dark);
    border-color: var(--isitec-blue-dark);
    color: #FFFFFF;
}
.btn-danger {
    background: var(--danger);
    color: #FFFFFF;
    border-color: var(--danger);
}
.btn-danger:hover {
    background: #8F2D2D;
    border-color: #8F2D2D;
    color: #FFFFFF;
}

/* ────────────────────────────────── Forms ───────────────────────────────── */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.form-field {
    display: flex;
    flex-direction: column;
    flex: 1 1 220px;
}
.form-field label {
    font-size: 11px;
    color: var(--isitec-blue-night);
    margin-bottom: 5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-field input,
.form-field select,
.form-field textarea {
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    font-size: 14px;
    background: #FFFFFF;
    color: var(--isitec-blue-night);
}
.form-field textarea { min-height: 80px; resize: vertical; }
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--isitec-blue);
    box-shadow: 0 0 0 3px rgba(1, 157, 224, 0.18);
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ─────────────────────────────── Page Login ─────────────────────────────── */
.login-card {
    max-width: 400px;
    margin: 80px auto;
    /* Accent hexagonal signature en filigrane derrière le contenu */
    position: relative;
    overflow: hidden;
}
.login-card::before {
    content: "";
    position: absolute;
    top: -60px;
    right: -60px;
    width: 180px;
    height: 180px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><polygon points='12,2 21,7 21,17 12,22 3,17 3,7' fill='%23019DE0' opacity='0.08'/></svg>");
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
}
.login-card > * { position: relative; z-index: 1; }
.login-card h1 { text-align: center; margin-bottom: 24px; }
.login-card .login-logo {
    display: block;
    width: 160px;
    height: auto;
    margin: 0 auto 16px;
}

/* ───────────────────────────────── KPI ─────────────────────────────────── */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.kpi {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    box-shadow: 0 1px 2px rgba(28, 29, 61, 0.04);
}
.kpi .label {
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
    font-weight: 700;
}
.kpi .value {
    font-size: 26px;
    font-weight: 700;
    color: var(--isitec-blue-night);
    line-height: 1.1;
}

/* ──────────────────────────────── Filtres ──────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    background: #FFFFFF;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
}
.filter-bar select,
.filter-bar input {
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font: inherit;
    font-size: 13px;
    color: var(--isitec-blue-night);
}
.filter-bar select:focus,
.filter-bar input:focus {
    outline: none;
    border-color: var(--isitec-blue);
}

/* ───────────────────────────────── Notes ───────────────────────────────── */
.note {
    background: #F6F8FB;
    border-left: 3px solid var(--isitec-blue);
    padding: 10px 14px;
    margin-bottom: 10px;
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    white-space: pre-wrap;
}
.note .timestamp {
    color: var(--muted);
    font-size: 11px;
    margin-bottom: 4px;
    font-weight: 500;
}

/* ───────────────────────────── Médias (galerie admin) ─────────────────────────────
   Affichage inline des pièces jointes — la 1re raison d'être : YB ne reçoit pas ces
   fichiers, donc l'admin web doit pouvoir les consulter (image preview, audio playback,
   download des autres types). Grille responsive auto-fit.
*/
.media-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}
.media-tile {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.media-tile .media-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #F6F8FB;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.media-tile .media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.media-tile .media-thumb .placeholder {
    color: var(--muted);
    font-size: 32px;
    font-weight: 600;
}
.media-tile audio,
.media-tile video {
    width: 100%;
}
.media-tile .media-meta {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
    word-break: break-all;
}
.media-tile .media-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
}
.media-tile .media-actions a {
    flex: 1;
    text-align: center;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--isitec-blue);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
}
.media-tile .media-actions a:hover {
    background: var(--isitec-blue-light);
}

/* ─────────────────────────────── Sidebar admin (style SAGE/Isinet) ───────────────────────────────
   Layout : 2 colonnes (.app-main flex-grow + .app-sidebar 260px sticky, à DROITE).
   Posée derrière la topbar (sticky top = hauteur topbar = 60px).
*/
.app-shell {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - 60px - 56px); /* viewport - topbar - footer */
}
.app-main {
    flex: 1;
    min-width: 0;        /* indispensable pour que les <pre>/<table> ne fassent pas overflow */
}
.app-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: #FFFFFF;
    border-right: 1px solid var(--border);
    position: sticky;
    top: 60px;
    align-self: flex-start;
    height: calc(100vh - 60px);
    overflow-y: auto;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

/* Bandeau brand en haut, dégradé bleu nuit + accent bleu Isitec en pied */
.app-sidebar-brand {
    padding: 18px 20px 14px;
    background: linear-gradient(135deg, var(--isitec-blue-night) 0%, var(--isitec-blue-night-soft) 100%);
    color: #FFFFFF;
    border-bottom: 3px solid var(--isitec-blue);
}
.app-sidebar-brand .brand-name {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.app-sidebar-brand .brand-tag {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 2px;
}

/* Groupes pliables */
.app-sidebar-groups {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}
.app-sidebar-group {
    border-bottom: 1px solid #F0F2F5;
}
.app-sidebar-group:last-child { border-bottom: none; }

.app-sidebar-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}
.app-sidebar-section:hover {
    background: #F6F8FB;
    color: var(--isitec-blue-night);
}
.app-sidebar-section .chevron {
    transition: transform 0.15s ease-out;
}
.app-sidebar-group.is-open .app-sidebar-section .chevron {
    transform: rotate(90deg);
}

/* Liste des liens — masqués si groupe fermé */
.app-sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0 0 6px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.18s ease-out;
}
.app-sidebar-group.is-open .app-sidebar-nav {
    max-height: 800px;   /* assez large pour ne pas couper, sans auto qui casse la transition */
}

/* Liens individuels — alignés à gauche avec icône, bordure gauche bleue au focus/active
   (style SAGE/Isinet exact : bord 4px, fond 10% bleu Isitec). */
.app-sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px 8px 20px;
    font-size: 13px;
    color: var(--isitec-blue-night);
    text-decoration: none;
    border-left: 4px solid transparent;
    transition: background 0.1s ease-out, color 0.1s ease-out, border-color 0.1s ease-out;
}
.app-sidebar-link:hover {
    background: #F6F8FB;
    color: var(--isitec-blue);
}
.app-sidebar-link.active {
    background: var(--isitec-blue-light);
    color: var(--isitec-blue);
    font-weight: 600;
    border-left-color: var(--isitec-blue);
}
.app-sidebar-link svg {
    flex-shrink: 0;
    color: inherit;
}

/* Footer sidebar */
.app-sidebar-footer {
    padding: 10px 18px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    background: #FAFBFC;
}
.app-sidebar-footer .muted { color: var(--muted); }

/* Responsive : sous 1100px, la sidebar passe au-dessus du contenu (largeur full).
   Garde-le accessible sans plein écran, mais évite qu'elle squeeze le main sur tablette. */
@media (max-width: 1100px) {
    .app-shell { flex-direction: column; }
    .app-sidebar {
        width: 100%;
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .app-sidebar-groups { padding: 0; }
}

/* ───────────────────────────── Tableau clé / valeur ─────────────────────────────
   Pour les "fiches" type enveloppe mail, dépouillé : <th> dans la 1re colonne =
   libellé, <td> = valeur. Pas de cellules en surbrillance pour rester sobre.
*/
table.kv {
    border: none;
    width: auto;
    box-shadow: none;
}
table.kv th,
table.kv td {
    padding: 4px 12px 4px 0;
    border: none;
    text-align: left;
    vertical-align: top;
    background: transparent;
}
table.kv th {
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}

.muted { color: var(--muted); }
.empty {
    padding: 36px;
    text-align: center;
    color: var(--muted);
    background: #FFFFFF;
    border: 1px dashed var(--border);
    border-radius: 10px;
}

/* ───────────────────────────── Validation split-screen ─────────────────────────────
   Page /admin/validation/{id} : mail original à gauche, formulaire pré-rempli à droite.
   En dessous de 1024px le layout passe en colonnes empilées (mail au-dessus du form).
*/
.validation-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 16px;
}
@media (max-width: 1024px) {
    .validation-split { grid-template-columns: 1fr; }
}
.validation-pane {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
    box-shadow: 0 1px 2px rgba(28, 29, 61, 0.04);
    min-width: 0; /* pour que le pre ne fasse pas déborder le grid */
}
.validation-pane .pane-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.validation-pane h2 { margin: 0; }
.validation-pane .pane-subheader {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--isitec-blue-night);
    margin: 18px 0 6px;
}
.validation-pane-mail {
    /* Le panneau mail peut être très long → scroll interne pour ne pas étirer la page */
    max-height: 70vh;
    overflow: auto;
    background: #F6F8FB;
}
.mail-source {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 12px;
    color: var(--isitec-blue-night);
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 0;
    line-height: 1.5;
}
.attachments {
    margin: 8px 0 0;
    padding-left: 20px;
    font-size: 13px;
}
.attachments li { margin-bottom: 4px; }

/* ───────────────────────────── Responsive mobile (≤ 720px) ─────────────────────────────
   Cible : un commercial ou un admin qui ouvre le back-office depuis son téléphone pour
   saisir un lead (cas usage : personne sans APK Android, ou intervention rapide en
   déplacement). Toutes les pages doivent rester utilisables au format vertical.
*/
@media (max-width: 720px) {
    body { font-size: 13px; }
    .topbar { padding: 0 14px; height: 54px; }
    .topbar .brand a { font-size: 14px; gap: 6px; }
    .topnav { gap: 10px; }
    .topnav .who { display: none; }      /* libère de la place pour le bouton Déconnexion */
    .container { padding: 0 12px; margin: 16px auto; }
    h1 { font-size: 19px; margin-bottom: 12px; }
    h2 { font-size: 15px; }

    .card { padding: 14px; border-radius: 8px; }
    .kpi { padding: 12px 14px; }
    .kpi .value { font-size: 22px; }
    .form-row { gap: 10px; }
    .form-field { flex-basis: 100%; }    /* 1 champ par ligne sur mobile */

    /* Boutons d'action en bas de formulaire : pleine largeur empilée pour faciliter
       le tap au pouce. L'ordre reste celui du DOM (Annuler à gauche, Submit à droite
       devient Annuler en haut, Submit en bas — on inverse pour que le primaire reste
       sous le pouce). */
    .form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 10px;
    }
    .form-actions .btn { width: 100%; text-align: center; padding: 12px 14px; }

    /* Tables : scroll horizontal plutôt que crop. On les wrap dans un overflow-x via
       le sélecteur :not(.kv) pour préserver les tables clé/valeur qui ne dépassent pas. */
    table:not(.kv) {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    th, td { padding: 10px 10px; font-size: 12px; }

    /* Sidebar : déjà repliée au-dessus du contenu via la media query 1100px existante.
       Sur mobile, on rend les groupes encore plus compacts. */
    .app-sidebar-brand { padding: 12px 14px; }
    .app-sidebar-section { padding: 8px 14px; }
    .app-sidebar-link { padding: 10px 14px 10px 16px; font-size: 14px; }

    /* Login card : retire les marges hautes énormes (80px → 24px) sur petits écrans. */
    .login-card { margin: 24px auto; max-width: 100%; }

    /* Filter bar : inputs full-width pour pouvoir taper au clavier mobile. */
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar input, .filter-bar select { width: 100%; }

    /* Galerie médias : tuiles plus petites pour tenir sur l'écran. */
    .media-gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

