/* =========================================================
   Pulso Territorial – UI Profesional (Paso 2)
   - Mantiene chat y panel funcionando igual
   - Estilos consistentes para: index.php, admin.php, map.php
   - No toca lógica ni rutas
   ========================================================= */

:root{
  --bg: #0b0f10;
  --panel: #ffffff;
  --muted: #6b7280;
  --text: #111827;

  --brand: #0b5c4d;
  --brand-2: #0a4f42;

  --soft: rgba(255,255,255,0.08);
  --soft-2: rgba(0,0,0,0.06);

  --radius: 14px;
  --radius-sm: 10px;

  --shadow: 0 10px 30px rgba(0,0,0,.25);
  --shadow-soft: 0 6px 18px rgba(0,0,0,.12);

  /* Logo PNG transparente (si no existe, no rompe nada) */
  --logo-url: url("../img/logo-pulso-territorial.png");
}

*{
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

body{
  margin: 0;
  background:
    radial-gradient(1200px 800px at 50% 0%, rgba(11,92,77,.22), transparent 60%),
    radial-gradient(800px 600px at 10% 30%, rgba(255,255,255,.06), transparent 60%),
    var(--bg);
  color: var(--text);
}

/* iOS Safari: evita auto-zoom al enfocar inputs */
#userInput,
.chat-input input,
input,
textarea,
select{
  font-size: 16px !important;
}

/* Helpers */
.muted{ color: var(--muted); }
.small{ font-size: 12px; }
a{ color: inherit; }

.alert{
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin: 10px 0;
  border: 1px solid transparent;
}
.alert-ok{ background: #e7f6ea; border-color: #bfe7c8; }
.alert-warn{ background: #fff4e5; border-color: #ffd7a1; }

.input{
  width: 100%;
  padding: 12px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #e5e7eb;
  outline: none;
  background: #fff;
  color: var(--text);
}
.input:focus{
  border-color: rgba(11,92,77,.55);
  box-shadow: 0 0 0 3px rgba(11,92,77,0.12);
}

.btn{
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.btn-primary{
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(11,92,77,.25);
}
.btn-primary:hover{ filter: brightness(1.03); }
.btn-primary:active{ transform: translateY(1px); }

/* =========================================================
   BRAND (Chat / Panel / Map)
   ========================================================= */
.brand-row{
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge{
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-image: var(--logo-url);
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;

  background-color: transparent;
  border: none;
  box-shadow: none;
  color: transparent;
  font-size: 0;
  text-indent: -9999px;
}

.brand-text h1{
  font-size: 16px;
  margin: 0;
  font-weight: 700;
  letter-spacing: .2px;
}
.brand-text small{
  font-size: 12px;
  opacity: .92;
}

.brand-pill{
  margin-left: auto;
  border: 1px solid rgba(255,255,255,0.35);
  padding: 7px 12px;
  border-radius: 999px;
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  opacity: .95;
}
.brand-pill:hover{ opacity: 1; background: rgba(255,255,255,.06); }

/* =========================================================
   CHAT PÚBLICO (index.php)
   ========================================================= */
.chat-wrapper{
  max-width: 420px;
  margin: 0 auto;
  background: #efe9df;

  min-height: 100vh;
  min-height: 100svh;

  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.chat-header{
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  color: #fff;
  padding: 14px 14px;
  text-align: left;
}

#chat{
  flex: 1;
  padding: 14px;
  overflow-y: auto;
}

.bot, .user{
  max-width: 85%;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
}

.bot{
  background: #ffffff;
  color: #333;
  align-self: flex-start;
}
.user{
  background: #d6f5c9;
  align-self: flex-end;
  margin-left: auto;
}

.bot-buttons{
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.bot-buttons button{
  border: 1px solid rgba(11,92,77,.75);
  background: #fff;
  color: var(--brand);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.bot-buttons button:hover{
  background: rgba(11,92,77,.08);
}

.chat-input{
  display: flex;
  padding: 10px;
  background: #f5f5f5;
  border-top: 1px solid rgba(0,0,0,.08);
}
.chat-input input{
  flex: 1;
  padding: 11px 12px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  outline: none;
  background: #fff;
}
.chat-input button{
  margin-left: 8px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  color: #fff;
  width: 44px;
  height: 44px;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(11,92,77,.25);
}

/* =========================================================
   PANEL / SISTEMA (admin.php y map.php)
   ========================================================= */
.panel-wrapper{
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.panel-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  color: #fff;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}

.hdr-left{ display: flex; gap: 12px; align-items: center; }
.panel-header h2{ margin: 0; font-size: 18px; }
.hdr-sub{ font-size: 12px; opacity: .92; margin-top: 2px; }
.hdr-right{ display: flex; gap: 12px; align-items: center; }

.hdr-user{
  font-size: 12px;
  opacity: .92;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  background: rgba(255,255,255,.06);
}

.hdr-link{
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  opacity: .95;
}
.hdr-link:hover{ text-decoration: underline; opacity: 1; }

/* Login card */
.auth-card{
  background: rgba(255,255,255,0.96);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  max-width: 520px;
  border: 1px solid rgba(255,255,255,.25);
}
.auth-card h3{ margin: 0 0 6px 0; font-size: 18px; }
.form-grid{ display: grid; gap: 10px; margin-top: 12px; }
.form-grid label{ font-size: 12px; color: #374151; font-weight: 700; }

/* Dashboard cards */
.dashboard-cards{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.card{
  background: rgba(255,255,255,0.96);
  border-radius: var(--radius);
  padding: 14px;
  text-align: left;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255,255,255,.25);
  position: relative;
  overflow: hidden;
}
.card::before{
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: rgba(11,92,77,.65);
}
.card h3{
  margin: 0;
  font-size: 26px;
  color: var(--brand);
  padding-left: 10px;
}
.card span{
  font-size: 13px;
  color: #6b7280;
  padding-left: 10px;
  display: block;
  margin-top: 4px;
}

/* Bloques (cards) */
.table-wrapper{
  background: rgba(255,255,255,0.96);
  border-radius: var(--radius);
  padding: 14px;
  overflow-x: auto;
  box-shadow: var(--shadow-soft);
  margin-bottom: 14px;
  border: 1px solid rgba(255,255,255,.25);
}
.section-title{
  font-weight: 800;
  color: #111827;
  margin-bottom: 12px;
  font-size: 14px;
}

.form-inline{
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.two-col{
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
}

/* Tabla */
table{
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: transparent;
}

/* Inputs dentro de tablas: que sean legibles sin romper el layout */
.table-wrapper table .input,
.table-wrapper table input,
.table-wrapper table select{
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 10px;
}
.table-wrapper table select{ border: 1px solid #d1d5db; background: #fff; }

/* Pills para estado */
.status-pill{
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}
.status-pill.active{ background: #e7f6ea; border: 1px solid #bfe7c8; color: #14532d; }
.status-pill.inactive{ background: #fff4e5; border: 1px solid #ffd7a1; color: #7c2d12; }
.table-wrapper table .input{ min-width: 90px; }
th, td{
  padding: 11px 10px;
  border-bottom: 1px solid rgba(0,0,0,.06);
  text-align: left;
  vertical-align: top;
}
th{
  background: rgba(0,0,0,.04);
  font-weight: 800;
  color: #111827;
}
tr:nth-child(even) td{ background: rgba(0,0,0,.012); }
tr:hover td{ background: rgba(11,92,77,.06); }

/* =========================================================
   Admin helpers
   ========================================================= */
.pt-badge-inactive{
  display:inline-block;
  padding:4px 10px;
  border-radius:999px;
  background:#fee2e2;
  color:#991b1b;
  font-weight:800;
  font-size:12px;
  border:1px solid rgba(153,27,27,.18);
}
.pt-row-inactive td{
  opacity:.72;
}

/* QR */
.qr-box{ text-align: center; }
.qr-box img{
  max-width: 180px;
  margin: 10px 0 8px 0;
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 900px){
  .panel-wrapper{ padding: 12px 10px 22px; }
  .two-col{ grid-template-columns: 1fr; }
}

@media (max-width: 768px){
  body{
    background: #efe9df;
  }
  .panel-header{
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .auth-card{ max-width: 100%; }
  table{ font-size: 12.5px; }
}

/* ===== Toast (Admin) ===== */
.pt-toast-host{
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(720px, calc(100vw - 24px));
  pointer-events: none;
}
.pt-toast{
  pointer-events: auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
  border: 1px solid rgba(0,0,0,.12);
  background: #111;
  color: #fff;
}
.pt-toast-warn{ background:#7c2d12; }
.pt-toast-ok{ background:#0f172a; }
.pt-toast-msg{ font-size:14px; line-height:1.25; }
.pt-toast-x{
  border:0;
  background: rgba(255,255,255,.14);
  color:#fff;
  border-radius:10px;
  width:32px;
  height:32px;
  cursor:pointer;
  font-size:18px;
  line-height:1;
}
.pt-toast.hide{ opacity:0; transform: translateY(-6px); transition: all .2s ease; }

/* ===== Coordinadores: celda de contraseña ===== */
.pt-pwcell{ display:flex; flex-direction:column; gap:8px; min-width: 260px; }
.pt-pwactions{ display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
.pt-pwlink-a{ word-break: break-all; font-size:12px; color: #2563eb; }

/* Password link cell */
.pt-pwlink{ display:inline-block; max-width: 520px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pt-pwlink.is-empty{ color: rgba(17,24,39,.55); font-style: italic; pointer-events:none; }
.pt-pwbox{ min-width: 360px; }



/* =========================================================
   FIX10 – Tabs + badges + versión
   ========================================================= */
.pt-tabs{
  display:flex;
  gap:8px;
  padding:10px 14px 0 14px;
}
.pt-tab{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color: #e5e7eb;
  text-decoration:none;
  font-weight:800;
  font-size:13px;
}
.pt-tab.active{
  background: rgba(255,255,255,.95);
  color: #111827;
  border-color: rgba(255,255,255,.35);
}
.pt-version{
  display:inline-block;
  margin-left:8px;
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  font-weight:900;
  background: rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.18);
  color:#e5e7eb;
}
.table-scroll{ overflow-x:auto; }

.badge{
  display:inline-block;
  padding:3px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:900;
  border:1px solid rgba(17,24,39,.10);
  background: rgba(17,24,39,.06);
  color:#111827;
}
.badge-ok{
  background:#dcfce7;
  border-color:rgba(22,163,74,.25);
  color:#166534;
}
.badge-muted{
  background:#f3f4f6;
  border-color:rgba(107,114,128,.25);
  color:#374151;
}
