/* ===== Branding Balfour — ajustar estas variables con el manual de marca ===== */
:root {
  --brand: #1b3a5c;          /* azul Balfour (placeholder — reemplazar) */
  --brand-dark: #12283f;
  --accent: #c9a04e;         /* dorado (placeholder) */
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #24313d;
  --muted: #7a8794;
  --ok: #2e7d32;
  --warn: #e09b00;
  --bad: #c62828;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); }
h1, h2, h3 { font-weight: 650; }
.muted { color: var(--muted); font-size: .92rem; }
.error { color: var(--bad); }
[hidden] { display: none !important; }

.center-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.card { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: 0 4px 24px rgba(20,40,60,.08); }
.auth-card { width: 400px; max-width: 94vw; }

.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.brand h1 { font-size: 1.35rem; margin: 0; } .brand em { color: var(--accent); font-style: normal; }
.brand p { margin: 2px 0 0; }
.brand-mark { width: 46px; height: 46px; border-radius: 12px; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 700; }
.brand.small .brand-mark { width: 32px; height: 32px; font-size: 1rem; border-radius: 8px; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab { flex: 1; padding: 9px; border: none; background: #eef0f2; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tab.active { background: var(--brand); color: #fff; }

form input, textarea { width: 100%; padding: 11px 12px; margin-bottom: 10px; border: 1px solid #d8dde2; border-radius: 9px; font-size: .95rem; font-family: var(--font); }
textarea { resize: vertical; }

.btn { border: none; border-radius: 9px; padding: 10px 16px; font-weight: 600; cursor: pointer; font-size: .93rem; background: #e8ebee; color: var(--ink); }
.btn.primary { background: var(--brand); color: #fff; width: auto; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.accent { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.big { width: 100%; padding: 14px; font-size: 1.05rem; margin-top: 10px; }
.btn:disabled { opacity: .55; cursor: wait; }
form .btn.primary { width: 100%; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #fff; padding: 10px 22px; box-shadow: 0 1px 8px rgba(0,0,0,.06); position: sticky; top: 0; z-index: 5; }
.topbar nav { display: flex; gap: 4px; }
.navbtn { border: none; background: transparent; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.navbtn.active { background: var(--bg); color: var(--brand); }
.userbox { display: flex; align-items: center; gap: 10px; font-size: .9rem; }

/* Selector de idioma */
.lang-switch { display: inline-flex; gap: 2px; background: #eef0f2; border-radius: 8px; padding: 2px; }
.auth-card .lang-switch { display: flex; width: fit-content; margin: 0 0 12px auto; }
.lang-btn { border: none; background: transparent; color: var(--muted); font-weight: 700; font-size: .78rem; padding: 4px 9px; border-radius: 6px; cursor: pointer; }
.lang-btn.active { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

.page { max-width: 880px; margin: 26px auto; padding: 0 18px 60px; }
.opts { display: grid; gap: 16px; margin: 14px 0; }
.opt-group label { font-weight: 600; font-size: .88rem; display: block; margin-bottom: 7px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { border: 1.5px solid #d8dde2; background: #fff; border-radius: 999px; padding: 8px 15px; cursor: pointer; font-size: .9rem; text-align: left; }
.pill.active { border-color: var(--brand); background: var(--brand); color: #fff; }
.pill-sub { display: block; font-size: .74rem; opacity: .75; font-weight: 400; pointer-events: none; }

/* Chat */
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.chat-log { background: #e8ded1; border-radius: var(--radius); padding: 18px; min-height: 55vh; max-height: 62vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 12px; line-height: 1.5; font-size: .95rem; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.bubble.agent { white-space: pre-wrap; }
.bubble p { margin: 0 0 6px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 4px 0 8px; padding-left: 20px; } .bubble li { margin-bottom: 4px; }
.bubble.client { background: #fff; align-self: flex-start; border-bottom-left-radius: 3px; }
.bubble.agent { background: #d3e8fd; align-self: flex-end; border-bottom-right-radius: 3px; }
/* Coaching (📝 META): claramente distinto del diálogo — tarjeta dorada con banda lateral */
.bubble.meta { background: #fff9e8; border: 1px solid #ead9ac; border-left: 5px solid var(--accent); border-radius: 8px; align-self: stretch; max-width: 100%; font-size: .86rem; color: #5d5137; }
.bubble.meta strong { color: #3f3826; }
.bubble.meta.danger { background: #fdecec; border-color: #f0c1c1; border-left-color: var(--bad); color: #6b2f2f; }
.meta-title { font-weight: 750; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: #9a7b2f; margin-bottom: 8px; }
.bubble.meta.danger .meta-title { color: var(--bad); }
.trainer-msg { display: contents; }
.chat-input { display: flex; gap: 10px; margin-top: 12px; align-items: flex-end; }
.chat-input textarea { margin: 0; flex: 1; min-width: 0; }
.chat-input .btn.primary { width: auto; flex: 0 0 auto; padding: 11px 22px; }

/* Score */
.score-hero { text-align: center; padding: 26px; }
.score-num { font-size: 4rem; font-weight: 800; }
.score-num.good { color: var(--ok); } .score-num.mid { color: var(--warn); } .score-num.low { color: var(--bad); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #eceff2; vertical-align: top; }
th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.badge.good { background: #e5f3e6; color: var(--ok); } .badge.mid { background: #fdf3dd; color: var(--warn); } .badge.low { background: #fde5e5; color: var(--bad); }

/* Mensajes de éxito */
.ok-msg { color: var(--ok); font-size: .9rem; }

/* Ranking / concurso */
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin: 22px 0 26px; min-height: 40px; }
.podium-spot { flex: 0 1 150px; text-align: center; background: #fff; border-radius: 12px 12px 0 0; padding: 14px 10px 0; box-shadow: 0 2px 10px rgba(20,40,60,.08); }
.podium-medal { font-size: 1.8rem; }
.podium-name { font-weight: 650; font-size: .9rem; margin: 4px 0; }
.podium-score { font-size: 1.6rem; font-weight: 800; color: var(--brand); }
.podium-bar { margin-top: 8px; border-radius: 6px 6px 0 0; background: linear-gradient(var(--brand), var(--brand-dark)); }
.podium-spot.p1 .podium-bar { height: 70px; }
.podium-spot.p2 .podium-bar { height: 48px; }
.podium-spot.p3 .podium-bar { height: 32px; }
.podium-spot.p1 { border-top: 3px solid var(--accent); }
.podium-spot.me { outline: 2px solid var(--accent); }
.lb-me { background: #fff9e8; }
.lb-you { background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: .72rem; font-weight: 700; }

/* Admin — invitar usuario */
.invite-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.invite-form input { margin: 0; flex: 1 1 180px; }
.invite-form select { margin: 0; padding: 11px 12px; border: 1px solid #d8dde2; border-radius: 9px; font-family: var(--font); font-size: .95rem; background: #fff; }
.invite-form .btn.primary { width: auto; }

/* Admin — acciones de usuario */
.btn.mini { padding: 5px 9px; font-size: .85rem; border-radius: 7px; }
.btn.mini.danger { background: #fde5e5; }
.role-select { padding: 5px 8px; border: 1px solid #d8dde2; border-radius: 7px; font-family: var(--font); font-size: .85rem; background: #fff; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border-radius: var(--radius); padding: 16px; }
.kpi .n { font-size: 1.7rem; font-weight: 750; } .kpi .l { color: var(--muted); font-size: .82rem; }

.hist-item { background: #fff; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
@media (max-width: 640px) { .bubble { max-width: 92%; } .topbar { flex-wrap: wrap; } }
