/* Soporte IAcademy — tema oscuro con los tokens de iacedemy-web. Sin frameworks. */

:root {
  --bg: #0f0f18;
  --bg-alt: #1a1a2e;
  --surface: #1a1a2e;
  --surface-alt: #2a2a3d;
  --border: #3a3a50;
  --accent: #EF4444;
  --accent-dark: #DC2626;
  --accent-deep: #B91C1C;
  --accent-soft: rgba(239, 68, 68, .12);
  --text: #F1F1F1;
  --text-secondary: #A0A0B0;
  --text-muted: #8B8BA0;
  --text-faded: #8A8AA0;
  --success: #22C55E;
  --info: #3B82F6;
  --warning: #F59E0B;
  --error: #EF4444;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-metric: 'Inter Tight', 'Inter', system-ui, sans-serif;
  --font-code: 'JetBrains Mono', monospace;
  --shadow-card: rgba(0, 0, 0, .2) 0 2px 4px, rgba(0, 0, 0, .1) 0 0 1px;
  --shadow-elevated: rgba(0, 0, 0, .3) 0 8px 24px, rgba(0, 0, 0, .15) 0 2px 8px;
  --focus-ring: 0 0 0 3px rgba(239, 68, 68, .55);
  --radius: 16px;
  --radius-sm: 8px;
  --radius-pill: 9999px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--text); }

h1, h2 { font-family: var(--font-display); font-weight: 400; letter-spacing: .2px; }
h3 { font-family: var(--font-body); font-weight: 700; }

/* --- Cabecera y navegación ------------------------------------------------------- */

header.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

header.top .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text);
}

header.top .brand img { display: block; width: 24px; height: 24px; }

header.top .spacer { flex: 1; }
header.top > a:not(.btn) { color: var(--text-secondary); font-weight: 500; }
header.top > a:not(.btn):hover { color: var(--text); }
header.top > span:not(.brand):not(.spacer) { color: var(--text-muted); font-size: 12px; }

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

/* --- Botones ---------------------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  transition: background .15s ease, border-color .15s ease;
}

.btn:hover { background: var(--surface-alt); border-color: var(--text-muted); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.btn.primary {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
}

.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

/* --- Tarjetas y KPIs ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-card);
}

.kpi .v {
  font-family: var(--font-metric);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.kpi .l { font-size: 12px; color: var(--text-muted); }

/* --- Tabla de la cola ---------------------------------------------------------------- */

table.list { width: 100%; border-collapse: collapse; }

table.list th, table.list td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

table.list th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
}

table.list tbody tr, table.list tr:hover { transition: background .12s ease; }
table.list tr:hover { background: var(--surface-alt); }

/* --- Pills de estado y prioridad -------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
}

/* Estados: texto al 100 %, fondo al 18 %, borde al 40 % */
.pill-open { color: #EF4444; background: rgba(239, 68, 68, .18); border: 1px solid rgba(239, 68, 68, .4); }
.pill-in_progress { color: #F59E0B; background: rgba(245, 158, 11, .18); border: 1px solid rgba(245, 158, 11, .4); }
.pill-waiting_customer { color: #3B82F6; background: rgba(59, 130, 246, .18); border: 1px solid rgba(59, 130, 246, .4); }
.pill-resolved { color: #22C55E; background: rgba(34, 197, 94, .18); border: 1px solid rgba(34, 197, 94, .4); }
.pill-closed { color: #F1F1F1; background: rgba(160, 160, 176, .18); border: 1px solid rgba(160, 160, 176, .4); }

/* Prioridades: P1 rojo, P2 ámbar, P3 gris claro, P4 azul */
.pill-P1 { color: #EF4444; background: rgba(239, 68, 68, .18); border: 1px solid rgba(239, 68, 68, .4); }
.pill-P2 { color: #F59E0B; background: rgba(245, 158, 11, .18); border: 1px solid rgba(245, 158, 11, .4); }
.pill-P3 { color: #A0A0B0; background: rgba(160, 160, 176, .18); border: 1px solid rgba(160, 160, 176, .4); }
.pill-P4 { color: #3B82F6; background: rgba(59, 130, 246, .18); border: 1px solid rgba(59, 130, 246, .4); }

/* --- Filtros y formularios ---------------------------------------------------------- */

form.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

label { display: block; font-size: 12px; color: var(--text-muted); margin: 10px 0 4px; }

input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--text);
  font: inherit;
}

input::placeholder, textarea::placeholder { color: var(--text-faded); }

input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

select { appearance: auto; }
textarea { min-height: 90px; resize: vertical; }

.error { color: var(--error); font-weight: 600; }

/* --- Hilo de mensajes ---------------------------------------------------------------- */

.thread { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }

.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.msg.customer { align-self: flex-start; background: var(--surface); }
.msg.team { align-self: flex-end; background: var(--accent-soft); border-color: rgba(239, 68, 68, .3); }

.msg.internal {
  align-self: flex-end;
  background: var(--bg-alt);
  border-style: dashed;
}

.msg.internal::before {
  content: "interna";
  display: inline-block;
  margin-bottom: 4px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--warning);
  background: rgba(245, 158, 11, .15);
}

.msg .meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.msg p { margin: 0; white-space: pre-wrap; }

.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }

/* --- Login ---------------------------------------------------------------------------- */

.login-wrap { max-width: 380px; margin: 80px auto; text-align: center; }
.login-wrap h2 { font-size: 26px; }
.login-wrap img.logo { width: 56px; height: 56px; margin: 0 auto 12px; display: block; }
.login-wrap form { text-align: left; }

/* --- Responsive (390 px) --------------------------------------------------------------- */

@media (max-width: 800px) {
  .grid2 { grid-template-columns: 1fr; }
  header.top { flex-wrap: wrap; gap: 8px 14px; padding: 10px 14px; }
  main { padding: 14px; }
}

@media (max-width: 480px) {
  /* La cola pasa de tabla a tarjetas apiladas */
  .card:has(table.list) { padding: 0; border: none; box-shadow: none; background: transparent; overflow: visible; }

  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr:first-child, table.list thead, table.list th { display: none; }

  table.list tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 10px 14px;
    margin-bottom: 10px;
  }

  table.list td { border: none; padding: 3px 0; }
  table.list td:last-child { color: var(--text-muted); font-size: 12px; }

  .thread .msg { max-width: 100%; }
}
