/* ==========================================================
   SENDA CONSCIENTE — Tema Claro (Edición Patek)
   Estilo base + mejoras estéticas seleccionadas
   ========================================================== */

:root {
  --color-bg: #f8f7f4;
  --color-bg-secondary: #ffffff;
  --color-text: #1a1a1a;
  --color-muted: #5a5a5a;
  --color-accent: #c6a664;
  --color-hover: #b79846;
  --color-border: #ddd;
  --radius-base: 8px;
  --shadow-soft: 0 2px 6px rgba(0,0,0,0.05);
  --shadow-medium: 0 4px 14px rgba(0,0,0,0.08);
  --transition-speed: 0.6s;
}

/* ==========================================================
   BASE TIPOGRÁFICA Y ESTRUCTURA
   (a2: transiciones suaves globales)
   ========================================================== */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  font-family: 'Lato', sans-serif;
  font-weight: 400;
  line-height: 1.65;
  background:
    radial-gradient(circle at top, rgba(198,166,100,0.024) 0%, rgba(248,247,244,1) 55%)
    fixed; /* b2 */
  background-color: var(--color-bg); /* b3 */
  color: var(--color-text);
  transition:
    background-color var(--transition-speed) ease,
    color var(--transition-speed) ease;
}

* {
  box-sizing: border-box;
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

/* ==========================================================
   CABECERA FIJA Y NAVEGACIÓN
   (d1 header compacto, d2 mobile first)
   ========================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid rgba(0,0,0,0.03);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.055);
  transition: padding .25s ease, box-shadow .25s ease, background .25s ease;
}

.site-header.compact {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  background: rgba(248,247,244,0.92);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.65em 1.1em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.logo img {
  height: 40px;
  transition: opacity var(--transition-speed) ease;
}
.logo:hover img { opacity: 0.85; }

nav {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
}
nav a {
  color: var(--color-text);
  padding: .25rem .4rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: 4px;
  transition: color .25s ease, background .25s ease;
}
nav a:hover {
  color: var(--color-accent);
  background: rgba(198,166,100,0.06);
}

/* Mobile-first: más compacto en pantallas estrechas */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
  }
  nav {
    width: 100%;
    justify-content: flex-start;
  }
  nav a {
    margin: 0 .25rem .25rem 0;
  }
}

/* ==========================================================
   BOTONES (e1, e2, e3)
   ========================================================== */
button,
.btn,
.btn-primary {
  background-color: var(--color-accent);
  color: #111;
  border: none;
  padding: 0.55em 1.4em;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: .01em;
  transition: background-color .25s ease, transform .1s ease, box-shadow .25s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
button:hover,
.btn:hover,
.btn-primary:hover {
  background-color: var(--color-hover);
  box-shadow: 0 3px 10px rgba(183,152,70,0.28);
}
button:active,
.btn:active,
.btn-primary:active {
  transform: translateY(1px);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.4em 1.2em;
  border-radius: 7px;
  transition: all .25s ease;
}
.btn-ghost:hover {
  background: var(--color-accent);
  color: #111;
}

/* Botón de tema refinado (ya acordado) */
.btn-theme {
  position: relative;
  font-family: 'Lato', sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  font-weight: 600;
  padding: 0.6em 1.6em;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.4s ease;
  border: 1px solid var(--color-accent);
  background: transparent;
  color: var(--color-accent);
  box-shadow: inset 0 0 0 1px rgba(198,166,100,0.2);
  overflow: hidden;
}
.btn-theme::before {
  content: "";
  position: absolute;
  top: 0; left: -70%;
  width: 40%;
  height: 100%;
  background: linear-gradient(
    120deg,
    rgba(255,255,255,0.05) 0%,
    rgba(255,255,255,0.14) 50%,
    rgba(255,255,255,0.0) 100%
  );
  transform: skewX(-25deg);
  transition: all 0.8s ease;
  border-radius: inherit;
}
.btn-theme:hover::before { left: 130%; }
.btn-theme:hover {
  background: var(--color-accent);
  color: #111;
  box-shadow: 0 0 10px rgba(198,166,100,0.4);
  transform: translateY(-1px);
}
body.dark .btn-theme {
  background: var(--color-accent);
  color: #111;
  border: 1px solid var(--color-accent);
  box-shadow: 0 0 6px rgba(198,166,100,0.2);
}
body.dark .btn-theme:hover {
  background: var(--color-hover);
  color: #000;
  box-shadow: 0 0 12px rgba(198,166,100,0.4);
}

/* ==========================================================
   TARJETAS, PANELES, FORMULARIOS
   (a3: sombras y bordes coherentes)
   ========================================================== */
.card,
.box,
.panel {
  background-color: var(--color-bg-secondary);
  border: 1px solid rgba(221,221,221,0.75);
  border-radius: var(--radius-base);
  padding: 1.15em;
  box-shadow: var(--shadow-soft);
}
.card:hover,
.panel:hover {
  box-shadow: var(--shadow-medium);
}

input,
select,
textarea {
  background-color: var(--color-bg-secondary);
  border: 1px solid rgba(221,221,221,0.8);
  border-radius: 4px;
  padding: 0.5em 0.8em;
  color: var(--color-text);
  transition: border .2s ease, box-shadow .2s ease;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-accent);
  outline: none;
  box-shadow: 0 0 0 2px rgba(198,166,100,0.15);
}

/* ==========================================================
   TABLAS Y ALERTAS
   ========================================================== */
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  border-bottom: 1px solid var(--color-border);
  padding: 0.7em;
}
th {
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.alert {
  background-color: #fffbe9;
  border-left: 4px solid var(--color-accent);
  color: #4b4a47;
  padding: 1em;
  border-radius: 4px;
}

/* ==========================================================
   MAIN + FOOTER (f1, f2, f3)
   ========================================================== */
main.main-content {
  flex: 1 0 auto;
  padding-top: 80px;
}

footer {
  flex-shrink: 0;
  text-align: center;
  padding: 1.4em 0 1.8em;
  background: radial-gradient(circle at 50% 20%, rgba(198,166,100,0.1), rgba(248,247,244,0)) , var(--color-bg-secondary);
  color: var(--color-text);
  border-top: 1px solid rgba(221,221,221,0.7);
  box-shadow: 0 -2px 4px rgba(0,0,0,0.035);
}
footer .footer-links a {
  color: inherit;
  margin: 0 .25rem;
  transition: color .2s ease;
}
footer .footer-links a:hover {
  color: var(--color-accent);
}
footer .social-icons img {
  height: 22px;
  margin: .3rem .18rem 0;
  transition: filter .25s ease, transform .25s ease;
}
footer .social-icons img:hover {
  transform: scale(1.03);
  filter: saturate(1.1);
}

/* ==========================================================
   SCROLLBAR
   ========================================================== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-accent);
}

/* ==========================================================
   ANIMACIONES SUAVES (g1, g2, g3)
   ========================================================== */
@keyframes fadeInSmooth {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.main-content { animation: fadeInSmooth 1.2s ease-out both; }

/* ==========================================================
   CHAT GENERAL (usuario)
   (c1, c2, c4 ya integrados)
   ========================================================== */
.chat-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  max-width: 720px;
  margin: 30px auto;
  border: 1px solid rgba(221,221,221,0.7);
  border-radius: 12px;
  background: var(--color-bg-secondary);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.chat-header {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  color: var(--color-accent);
}

.chat-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 1rem;
  padding-bottom: 40px; /* c4: espacio para “escribiendo” */
  overflow-y: auto;
  scroll-behavior: smooth;
}

.message {
  display: inline-block;
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.4;
  word-break: break-word;
  font-size: 0.95rem;
  animation: chatPop .25s ease;
}
@keyframes chatPop {
  from { transform: translateY(3px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.message.sent {
  align-self: flex-end;
  background: var(--color-accent);
  color: #111;
  border-top-right-radius: 2px;
}
.message.received {
  align-self: flex-start;
  background: #f1f3f4;
  color: #111;
  border-top-left-radius: 2px;
}

/* Footer del chat */
.chat-footer {
  padding: 0.8rem;
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border);
}
.chat-footer .row {
  display: flex;
  gap: 0.6rem;
}
.chat-footer input#msg {
  flex: 1;
  padding: 0.9rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: #fff;
  color: #111;
  font-size: 1rem;
}
.chat-footer button#btnEnviar {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.9rem 1.4rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s ease;
}
.chat-footer button#btnEnviar:hover {
  background: var(--color-hover);
}

/* ==========================================================
   ADMIN CHAT
   ========================================================== */
.admin-chat-wrapper {
  max-width: 1080px;
  margin: 24px auto;
  color: var(--color-text);
}

.admin-chat-main {
  display: flex;
  height: 70vh;
  min-height: 480px;
  border: 1px solid rgba(221,221,221,0.7);
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-bg);
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.admin-chat-usuarios {
  width: 28%;
  border-right: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  overflow-y: auto;
}
.admin-chat-usuarios .u {
  position: relative;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  color: var(--color-text);
  transition: background .3s ease;
}
.admin-chat-usuarios .u:hover { background: rgba(0,0,0,0.04); }
.admin-chat-usuarios .u.active {
  background: var(--color-accent);
  color: #111;
  font-weight: 600;
}

/* Badge rojo de no leídos con pulso */
.admin-chat-usuarios .u .unread {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: #d32f2f;
  color: #fff;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
  font-weight: 600;
  box-shadow: 0 0 0 2px #fff;
  animation: unreadPulse 1.2s ease-out infinite;
}
@keyframes unreadPulse {
  0%   { transform: translateY(-50%) scale(1); }
  60%  { transform: translateY(-50%) scale(1.15); }
  100% { transform: translateY(-50%) scale(1); }
}
.admin-chat-usuarios .u.active .unread {
  box-shadow: 0 0 0 2px rgba(198,166,100,0.4);
}

.admin-chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-secondary);
}

.admin-chat-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow-y: auto;
  padding: 12px;
  padding-bottom: 40px;
  scroll-behavior: smooth;
}
.admin-chat-box .message {
  margin: 6px 0;
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 75%;
  line-height: 1.4;
  word-break: break-word;
  animation: chatPop .2s ease;
}
.admin-chat-box .message.sent {
  align-self: flex-end;
  background: var(--color-accent);
  color: #111;
  border-top-right-radius: 2px;
}
.admin-chat-box .message.received {
  align-self: flex-start;
  background: #f1f3f4;
  color: #111;
  border-top-left-radius: 2px;
}

/* Footer admin */
.admin-chat-footer {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border);
}
.admin-chat-footer #msg {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg-secondary);
  color: var(--color-text);
}
.admin-chat-footer #sendBtn {
  padding: 10px 16px;
  background: var(--color-accent);
  border: none;
  color: #111;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.3s ease;
}
.admin-chat-footer #sendBtn:hover { opacity: 0.9; }

/* Scrollbars internos */
.admin-chat-box::-webkit-scrollbar,
.admin-chat-usuarios::-webkit-scrollbar {
  width: 8px;
}
.admin-chat-box::-webkit-scrollbar-thumb,
.admin-chat-usuarios::-webkit-scrollbar-thumb {
  background: var(--color-border);
}
.admin-chat-box::-webkit-scrollbar-thumb:hover,
.admin-chat-usuarios::-webkit-scrollbar-thumb:hover {
  background: var(--color-accent);
}

/* ==========================================================
   INDICADOR DE ESCRITURA — NO TAPA MENSAJES (c2)
   ========================================================== */
.typing-indicator {
  font-size: 0.78rem;
  color: var(--color-muted);
  font-style: italic;
  text-align: left;
  padding: 3px 12px 0;
  margin: 0 0 4px 4px;
  opacity: 0.7;
  pointer-events: none;
  border-left: 2px solid rgba(198,166,100,0.45);
  max-width: 90%;
}
body.dark .typing-indicator {
  color: var(--color-accent);
  border-left-color: rgba(198,166,100,0.6);
}
