/*
 * RadioAIVT Dashboard — Styles
 * ===========================
 * Palette : pink #e91e8c (microphone) / red #e8001c (signature AI)
 * Fond sombre cohérent avec le tray client et le wizard d'installation.
 */

/* ============================================================
   Reset minimal + box-sizing global
   ============================================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #1f1f23;
    color: #ffffff;
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================================
   Variables CSS — palette
   ============================================================ */
:root {
    --color-pink: #e91e8c;
    --color-red: #e8001c;
    --color-green: #00c853;
    --color-yellow: #ffb300;
    --color-gray: #888888;
    --color-bg: #1f1f23;
    --color-bg-card: #2a2a2e;
    --color-bg-hover: #3a3a3e;
    --color-border: #444444;
    --color-text: #ffffff;
    --color-text-muted: #aaaaaa;
}

/* ============================================================
   Header
   ============================================================ */
.aivt-header {
    background: #15151a;
    border-bottom: 1px solid var(--color-border);
    padding: 16px 24px;
}

.aivt-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.aivt-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
}

.logo-mic {
    color: var(--color-pink);
    font-size: 22px;
    line-height: 1;
}

.logo-name {
    color: var(--color-text);
}

.logo-product {
    color: var(--color-red);
    font-weight: 700;
}

.header-actions {
    display: inline-flex;
    align-items: center;
    gap: 16px;
}

/* ============================================================
   Main
   ============================================================ */
.aivt-main {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ============================================================
   Footer
   ============================================================ */
.aivt-footer {
    background: #15151a;
    border-top: 1px solid var(--color-border);
    padding: 16px 24px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 12px;
}

.aivt-footer .sep {
    margin: 0 8px;
    color: var(--color-border);
}

/* ============================================================
   Utilitaires
   ============================================================ */
.muted {
    color: var(--color-text-muted);
}

/* ============================================================
   Login
   ============================================================ */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 40px;
}

.login-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 40px 32px;
    width: 100%;
    max-width: 420px;
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--color-text-muted);
    margin-bottom: 28px;
}

.login-form .form-group {
    margin-bottom: 16px;
}

.login-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
}

.login-form input {
    width: 100%;
    padding: 12px 14px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    font-size: 14px;
    font-family: inherit;
}

.login-form input:focus {
    outline: none;
    border-color: var(--color-pink);
    box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.15);
}

.login-help {
    margin-top: 20px;
    text-align: center;
    font-size: 13px;
}

.login-help a {
    color: var(--color-pink);
    text-decoration: none;
}

.login-help a:hover {
    text-decoration: underline;
}

.login-placeholder-note {
    margin-top: 24px;
    padding: 12px 14px;
    background: rgba(255, 179, 0, 0.1);
    border: 1px solid rgba(255, 179, 0, 0.3);
    border-radius: 6px;
    font-size: 12px;
    color: #ffe082;
}

/* ============================================================
   Boutons
   ============================================================ */
.btn {
    display: inline-block;
    padding: 12px 20px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg-card);
    color: var(--color-text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 120ms, border-color 120ms;
}

.btn:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-pink);
}

.btn-primary {
    background: var(--color-red);
    border-color: var(--color-red);
    color: #ffffff;
    font-weight: 700;
}

.btn-primary:hover {
    background: #ff1a3a;
    border-color: #ff1a3a;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border-color: var(--color-border);
    padding: 8px 14px;
    font-size: 13px;
}

.btn-ghost:hover {
    background: var(--color-bg-card);
    color: var(--color-text);
}

/* ============================================================
   Dashboard
   ============================================================ */
.dashboard-wrapper h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.placeholder-card {
    margin-top: 24px;
    padding: 24px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.placeholder-card h2 {
    color: var(--color-yellow);
    font-size: 18px;
    margin-bottom: 12px;
}

.placeholder-card ul {
    margin: 12px 0 12px 24px;
}

.placeholder-card li {
    margin-bottom: 6px;
}

/* ============================================================
   ÉTAPE 2 — Auth : alertes, badges, info-cards
   ============================================================ */

/* Alertes (erreur login, info, success) */
.alert {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 18px;
    font-size: 14px;
}

.alert-error {
    background: rgba(232, 0, 28, 0.12);
    border: 1px solid rgba(232, 0, 28, 0.4);
    color: #ff7a8a;
}

.alert-success {
    background: rgba(0, 200, 83, 0.12);
    border: 1px solid rgba(0, 200, 83, 0.4);
    color: #6ee895;
}

.alert-info {
    background: rgba(233, 30, 140, 0.12);
    border: 1px solid rgba(233, 30, 140, 0.4);
    color: #ff8ac0;
}

/* Header user badge */
.user-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
    font-size: 13px;
}

.user-station {
    color: var(--color-pink);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.user-email {
    color: var(--color-text-muted);
    font-size: 12px;
}

.aivt-logo {
    text-decoration: none;
}

/* Badges inline */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 6px;
    vertical-align: middle;
}

.badge-admin {
    background: var(--color-red);
    color: white;
}

/* Info card (dashboard) */
.info-card {
    margin-top: 24px;
    padding: 24px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.info-card h3 {
    margin-bottom: 14px;
    font-size: 16px;
    color: var(--color-pink);
}

.info-list {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 8px 16px;
    font-size: 14px;
}

.info-list dt {
    color: var(--color-text-muted);
    font-size: 13px;
}

.info-list dd {
    color: var(--color-text);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.info-list dd.warning {
    color: var(--color-yellow);
    font-family: inherit;
}


/* ============================================================
   ÉTAPE 3 — Sections de configuration
   ============================================================ */

/* Header dashboard */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

.dashboard-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dashboard-title-row h1 {
    font-size: 28px;
    font-weight: 700;
}

.station-pill {
    background: var(--color-pink);
    color: white;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sélecteur station (admin) */
.station-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.station-switcher label {
    color: var(--color-text-muted);
}

.station-switcher select {
    background: var(--color-bg-card);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.station-switcher select:focus {
    outline: none;
    border-color: var(--color-pink);
}

/* Bandeau lecture seule */
.readonly-banner {
    padding: 12px 16px;
    margin-bottom: 24px;
    background: rgba(233, 30, 140, 0.08);
    border: 1px solid rgba(233, 30, 140, 0.3);
    border-radius: 6px;
    color: #ff8ac0;
    font-size: 13px;
}

.readonly-banner strong {
    color: var(--color-pink);
}

/* Section de config */
.config-section {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 20px;
}

.config-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border);
}

.config-section.meta-section {
    background: rgba(255, 255, 255, 0.02);
    font-size: 13px;
}

.config-section.meta-section h2 {
    color: var(--color-text-muted);
    font-size: 14px;
}

/* Tags */
.tag {
    display: inline-block;
    padding: 3px 10px;
    margin: 2px 4px 2px 0;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 12px;
    color: var(--color-text);
}

.tag-warning {
    background: rgba(255, 179, 0, 0.15);
    border-color: rgba(255, 179, 0, 0.4);
    color: #ffe082;
}

/* Tiers */
.tier-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tier-trial { background: var(--color-gray); color: white; }
.tier-standard { background: var(--color-pink); color: white; }
.tier-premium { background: var(--color-red); color: white; }

.badge-info {
    background: rgba(0, 200, 255, 0.15);
    color: #66d9ef;
    border: 1px solid rgba(0, 200, 255, 0.4);
}

/* Table slots */
.slots-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.slots-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--color-text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    border-bottom: 1px solid var(--color-border);
}

.slots-table td {
    padding: 12px;
    border-bottom: 1px solid var(--color-border);
}

.slots-table tr:last-child td {
    border-bottom: none;
}

.slots-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Code blocks */
.code-block {
    background: #0d0d10;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 12px 14px;
    margin: 8px 0;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: #a0e0a0;
    overflow-x: auto;
    white-space: pre-wrap;
}

/* Small notes */
.small-note {
    font-size: 12px;
    margin-top: 8px;
}

/* Info list (réutilisé de l'étape 2) — ajustement pour sections */
.config-section .info-list {
    grid-template-columns: 220px 1fr;
    gap: 12px 16px;
}

.config-section .info-list dt {
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .config-section .info-list,
    .info-list {
        grid-template-columns: 1fr;
        gap: 4px 0;
    }
    .info-list dt {
        margin-top: 12px;
        font-weight: 600;
    }
    .slots-table {
        font-size: 12px;
    }
    .slots-table th,
    .slots-table td {
        padding: 8px;
    }
}

/* ============================================================
   ÉTAPE 3 — Sections dashboard, tables, overlays
   ============================================================ */

/* Bandeau d'en-tête du dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    gap: 24px;
    flex-wrap: wrap;
}

.dashboard-header h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 4px;
}

.dashboard-status {
    text-align: right;
    font-size: 13px;
    padding-top: 6px;
}

#last-updated {
    font-size: 12px;
}

/* Sélecteur inline (admin pour changer de station) */
.inline-select {
    background: var(--color-bg-card);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 3px 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.inline-select:focus {
    outline: none;
    border-color: var(--color-pink);
}

/* Bandeau d'info étape */
.etape-banner {
    margin-bottom: 24px;
}

/* Sections config */
.config-section {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--color-border);
    background: rgba(255, 255, 255, 0.02);
}

.section-header h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text);
}

.section-body {
    padding: 24px;
}

.subhead {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    margin: 20px 0 12px;
}

.subhead:first-child {
    margin-top: 0;
}

/* Bouton désactivé (étape 3) */
.btn-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-disabled:hover {
    background: var(--color-bg-card);
    border-color: var(--color-border);
}

/* Listes d'infos (dt/dd alignés) */
.info-list dd.multivalue {
    font-family: inherit;
}

/* Chips pour les listes (variantes, catégories, mots-clés) */
.chip {
    display: inline-block;
    padding: 3px 10px;
    margin: 2px 4px 2px 0;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    font-size: 12px;
    font-family: inherit;
    color: var(--color-text);
}

/* Tables de slots */
.slots-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8px;
    font-size: 13px;
}

.slots-table th,
.slots-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.slots-table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--color-text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.slots-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.slot-hours {
    font-family: 'Consolas', 'Monaco', monospace;
    color: var(--color-pink);
    font-weight: 600;
    white-space: nowrap;
}

/* Animateur pace */
.pace-value {
    font-size: 15px;
    font-weight: 500;
}

/* Booleens visuels */
.bool-on  { color: var(--color-green); }
.bool-off { color: var(--color-text-muted); }

/* Section debug admin */
.debug-section {
    border-color: rgba(255, 179, 0, 0.3);
}

.debug-section .section-header h2 {
    color: var(--color-yellow);
}

.raw-json {
    background: #0a0a0d;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 16px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: #aaffaa;
    overflow-x: auto;
    white-space: pre;
    max-height: 600px;
}

.hidden {
    display: none !important;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(31, 31, 35, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-pink);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: var(--color-text-muted);
    font-size: 14px;
}

/* Error overlay */
.error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(31, 31, 35, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.error-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-red);
    border-radius: 8px;
    padding: 32px;
    max-width: 500px;
    text-align: center;
}

.error-card h2 {
    color: var(--color-red);
    margin-bottom: 12px;
}

.error-card p {
    margin-bottom: 20px;
    color: var(--color-text-muted);
}

/* Responsive : tableaux scrollables sur mobile */
@media (max-width: 768px) {
    .slots-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    .info-list {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .info-list dt {
        font-weight: 600;
        color: var(--color-pink);
        font-size: 12px;
        margin-top: 8px;
    }
    .info-list dd {
        margin-bottom: 8px;
    }
    .section-body {
        padding: 16px;
    }
}

/* ============================================================
   ÉTAPE 4a — Formulaires d'édition, chips éditables, toasts
   ============================================================ */

/* Actions de section (groupe de boutons en haut à droite) */
.section-actions {
    display: inline-flex;
    gap: 8px;
}

/* Section en mode édition : bordure rose discrète */
.config-section.editing {
    border-color: var(--color-pink);
    box-shadow: 0 0 0 1px rgba(233, 30, 140, 0.3);
}

/* Form grid (mode edit) */
.form-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-row-inline {
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
}

.form-row-inline input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    accent-color: var(--color-pink);
    cursor: pointer;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 2px;
}

.form-label-inline {
    font-size: 14px;
    color: var(--color-text);
    flex: 1;
}

.form-hint {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
    font-style: italic;
    flex-basis: 100%;
}

.form-hint.warning-text {
    color: var(--color-yellow);
    font-style: normal;
}

/* Inputs en mode edit */
.mode-edit input[type="text"],
.mode-edit input[type="email"],
.mode-edit input[type="number"],
.mode-edit select {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    font-family: inherit;
    font-size: 14px;
    padding: 10px 12px;
    width: 100%;
    max-width: 480px;
}

.mode-edit input:focus,
.mode-edit select:focus {
    outline: none;
    border-color: var(--color-pink);
    box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.15);
}

.mode-edit select {
    cursor: pointer;
}

/* Chips editor (variantes éditables) */
.chips-editor {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 10px;
    max-width: 600px;
}

.chips-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 24px;
    margin-bottom: 10px;
}

.chips-list:empty::before {
    content: "Aucune variante pour l'instant.";
    color: var(--color-text-muted);
    font-style: italic;
    font-size: 12px;
}

.chip-editable {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 4px 4px 4px 10px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.chip-remove {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    transition: background 120ms;
}

.chip-remove:hover {
    background: rgba(232, 0, 28, 0.3);
    color: white;
}

.chips-input-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.chips-input {
    flex: 1;
    background: var(--color-bg-card) !important;
    padding: 6px 10px !important;
    font-size: 13px !important;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* Inputs dans tableaux slots (mode edit) */
.slot-show-name-input {
    width: 100%;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    color: var(--color-text);
    padding: 6px 10px;
    font-family: inherit;
    font-size: 13px;
}

.slot-show-name-input:focus {
    outline: none;
    border-color: var(--color-pink);
    box-shadow: 0 0 0 2px rgba(233, 30, 140, 0.15);
}

.slots-edit-table td:first-child {
    width: 100px;
}

/* ============================================================
   Toast notifications
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 460px;
}

.toast {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 14px 18px;
    color: var(--color-text);
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    transform: translateX(120%);
    transition: transform 280ms ease-out;
    white-space: pre-line;
    line-height: 1.4;
}

.toast.toast-show {
    transform: translateX(0);
}

.toast-success {
    border-color: var(--color-green);
    border-left: 4px solid var(--color-green);
}

.toast-error {
    border-color: var(--color-red);
    border-left: 4px solid var(--color-red);
}

.toast-warning {
    border-color: var(--color-yellow);
    border-left: 4px solid var(--color-yellow);
}

.toast-info {
    border-color: var(--color-pink);
    border-left: 4px solid var(--color-pink);
}

/* Responsive mobile */
@media (max-width: 768px) {
    .toast-container {
        bottom: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
    }
    .section-actions {
        flex-direction: column;
        gap: 4px;
    }
    .form-row-inline {
        flex-wrap: wrap;
    }
}
