/* ============================================================
   admin.css — Panel CRM de TST Solutions
   Marca: Montserrat + Inter · verde #1F6F63 / #3FAE9A / accent #00D4AA
   ============================================================ */

:root {
  --tst-green: #1F6F63;
  --tst-green-light: #3FAE9A;
  --tst-dark: #0E2E2A;
  --tst-darker: #0a221f;
  --tst-white: #FFFFFF;
  --tst-accent: #00D4AA;
  --gradient-primary: linear-gradient(135deg, #1F6F63, #3FAE9A);
  --gradient-accent: linear-gradient(135deg, #3FAE9A, #00D4AA);
  --card-bg: rgba(14, 46, 42, 0.55);
  --card-border: rgba(63, 174, 154, 0.22);
  --text-dim: rgba(255, 255, 255, 0.62);
  --text-mute: rgba(255, 255, 255, 0.42);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(0, 212, 170, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(63, 174, 154, 0.16), transparent 55%),
    var(--tst-darker);
  color: var(--tst-white);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand-name { font-family: 'Montserrat', sans-serif; }
a { color: inherit; text-decoration: none; }

/* ============================== LOGIN ============================== */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.2rem;
}

.login-card {
  width: 100%;
  max-width: 410px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: 2.6rem 2.2rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}

.login-logo { display: block; height: 52px; margin: 0 auto 1.4rem; }

.login-card h1 {
  font-size: 1.45rem;
  text-align: center;
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}
.login-sub {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 1.9rem;
}

.field { margin-bottom: 1.1rem; }
.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}
.field input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  color: var(--tst-white);
  font-size: 0.98rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus {
  outline: none;
  border-color: var(--tst-accent);
  box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  border-radius: 12px;
  transition: transform 0.18s, box-shadow 0.18s, background 0.18s, opacity 0.18s;
}
.btn-primary {
  width: 100%;
  padding: 0.95rem;
  font-size: 1rem;
  color: #06231f;
  background: var(--gradient-accent);
  box-shadow: 0 10px 26px rgba(0, 212, 170, 0.28);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(0, 212, 170, 0.38); }

.alert {
  background: rgba(255, 78, 78, 0.12);
  border: 1px solid rgba(255, 78, 78, 0.4);
  color: #ffb4b4;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.88rem;
  margin-bottom: 1.2rem;
  text-align: center;
}
.login-foot {
  text-align: center;
  margin-top: 1.6rem;
  font-size: 0.78rem;
  color: var(--text-mute);
}

/* ============================== LAYOUT ============================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.8rem;
  background: rgba(10, 34, 31, 0.82);
  border-bottom: 1px solid var(--card-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.topbar .brand { display: flex; align-items: center; gap: 0.7rem; }
.topbar .brand img { height: 34px; }
.topbar .brand-name { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em; }
.topbar .brand-name span { color: var(--tst-accent); }
.topbar .pill {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tst-accent);
  border: 1px solid var(--card-border);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}
.topbar .right { display: flex; align-items: center; gap: 1rem; }
.topbar .who { font-size: 0.82rem; color: var(--text-dim); }
.btn-ghost {
  padding: 0.5rem 0.9rem;
  font-size: 0.82rem;
  color: var(--tst-white);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }

.container { max-width: 1240px; margin: 0 auto; padding: 1.8rem; }
.page-head { margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
.page-head p { color: var(--text-dim); font-size: 0.92rem; margin-top: 0.25rem; }

/* ============================== STATS ============================== */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.8rem;
}
.stat {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--gradient-accent);
}
.stat .num { font-family: 'Montserrat'; font-size: 2rem; font-weight: 800; line-height: 1; }
.stat .lbl {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.stat.is-nuevo .num { color: var(--tst-accent); }

/* ============================== TOOLBAR ============================== */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
  margin-bottom: 1.2rem;
}
.toolbar form { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; }
.toolbar select, .toolbar input[type="text"] {
  padding: 0.6rem 0.85rem;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--tst-white);
  font-family: inherit;
  font-size: 0.88rem;
}
.toolbar select:focus, .toolbar input:focus { outline: none; border-color: var(--tst-accent); }
.toolbar .btn-primary { width: auto; padding: 0.6rem 1.1rem; font-size: 0.88rem; }
.toolbar .spacer { flex: 1; }
.toolbar .count { font-size: 0.82rem; color: var(--text-dim); }

/* ============================== TABLE ============================== */

.table-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
  padding: 0.95rem 1.1rem;
  background: rgba(0, 0, 0, 0.22);
  border-bottom: 1px solid var(--card-border);
}
tbody td {
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(63, 174, 154, 0.06); }

.lead-name { font-weight: 600; }
.lead-phone { color: var(--text-dim); font-size: 0.82rem; }
.lead-msg { max-width: 360px; color: rgba(255,255,255,0.85); }
.lead-date { color: var(--text-dim); font-size: 0.82rem; white-space: nowrap; }
.muted { color: var(--text-mute); font-style: italic; }

.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  text-transform: capitalize;
}
.tag-cotizacion { background: rgba(0, 212, 170, 0.16); color: var(--tst-accent); }
.tag-consulta { background: rgba(255, 255, 255, 0.1); color: rgba(255,255,255,0.8); }

.estado-select {
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--card-border);
  background: rgba(0,0,0,0.3);
  color: #fff;
  cursor: pointer;
}
.estado-select.e-nuevo { border-color: var(--tst-accent); color: var(--tst-accent); }
.estado-select.e-contactado { border-color: #f5b942; color: #f5b942; }
.estado-select.e-cerrado { border-color: var(--text-mute); color: var(--text-dim); }

.row-actions { display: flex; gap: 0.4rem; }
.icon-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--card-border);
  color: var(--text-dim);
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.18s;
}
.icon-btn:hover { color: #fff; background: rgba(255,255,255,0.12); }
.icon-btn.danger:hover { color: #ff8888; border-color: rgba(255,120,120,0.5); }

.empty { text-align: center; padding: 3.5rem 1rem; color: var(--text-dim); }
.empty i { font-size: 2.4rem; color: var(--text-mute); margin-bottom: 0.8rem; display: block; }

/* ============================== RESPONSIVE ============================== */

@media (max-width: 820px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .container { padding: 1.1rem; }
  .topbar { padding: 0.8rem 1.1rem; }
  .topbar .who { display: none; }
}

/* ---- Móvil: la tabla se convierte en tarjetas apiladas (100% responsive) ---- */
@media (max-width: 720px) {
  .toolbar form { width: 100%; }
  .toolbar select, .toolbar input[type="text"] { flex: 1 1 100%; }
  .toolbar .btn-primary { flex: 1 1 auto; justify-content: center; }
  .toolbar .spacer { display: none; }
  .toolbar .count { width: 100%; }

  .table-scroll { overflow-x: visible; }
  table { min-width: 0; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }

  tbody tr {
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 0.4rem 0.2rem;
    margin: 0 0.7rem 0.9rem;
  }
  tbody tr:hover { background: rgba(0, 0, 0, 0.18); }

  tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.7rem 1rem;
  }
  tbody tr td:last-child { border-bottom: none; }

  /* Etiqueta de columna a la izquierda de cada celda */
  tbody td::before {
    content: attr(data-label);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    flex: 0 0 90px;
  }
  .lead-msg { max-width: none; text-align: right; }
  .estado-select { width: auto; }
  .row-actions { justify-content: flex-end; width: 100%; }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 0.7rem; }
  .stat { padding: 1rem; }
  .stat .num { font-size: 1.7rem; }
  .login-card { padding: 2rem 1.4rem; }
  .page-head h1 { font-size: 1.35rem; }
  tbody td::before { flex-basis: 76px; }
}
