/* =========================================
   RESET BÁSICO
========================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at top, #0f172a 0, #020617 45%, #020617 100%);
  color: #0f172a;
}

/* =========================================
   CONTENEDOR GENERAL
========================================= */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* =========================================
   HEADER
========================================= */

.header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
  color: #f9fafb;
}

.brand h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
}

.brand .subtle {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: #e5e7eb;
}

/* =========================================
   SEARCH + BOTONES
========================================= */

.tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.7);
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  min-width: 230px;
}

.search .icon {
  color: #94a3b8;
  font-size: 0.9rem;
  margin-right: 6px;
}

.search input {
  border: none;
  outline: none;
  background: transparent;
  color: #e5e7eb;
  font-size: 0.9rem;
  width: 100%;
}

.search input::placeholder {
  color: #9ca3af;
}

.btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  padding: 6px 14px;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.1s ease;
}

.btn i {
  font-size: 0.9rem;
}

.btn:hover {
  background-color: #0b1120;
  border-color: #e5e7eb;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.5);
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  border-color: transparent;
  color: #0f172a;
  font-weight: 600;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0ea5e9, #4f46e5);
  box-shadow: 0 12px 40px rgba(59, 130, 246, 0.7);
}

/* =========================================
   GRID DE PLATAFORMAS
========================================= */

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

.item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.card {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #f9fafb;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.65);
  overflow: hidden;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    filter 0.16s ease;
}

.card i {
  font-size: 2.1rem;
}

.card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 26px 65px rgba(15, 23, 42, 0.9);
  filter: brightness(1.03);
}

/* Botón de favorito dentro de la card */
.fav {
  position: absolute;
  top: 8px;
  right: 8px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.55);
  color: #e5e7eb;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    transform 0.1s ease,
    color 0.15s ease;
}

.fav i {
  font-size: 0.9rem;
}

.fav:hover {
  transform: translateY(-1px) scale(1.05);
  background-color: rgba(248, 250, 252, 0.95);
  color: #eab308;
}

.fav.active {
  background-color: rgba(248, 250, 252, 0.95);
  color: #eab308;
}

/* Título debajo de la card */
.title {
  font-size: 0.9rem;
  color: #e5e7eb;
  text-align: center;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mensaje vacío */
.empty {
  color: #e5e7eb;
  grid-column: 1 / -1;
  text-align: center;
}

/* =========================================
   SECCIONES (MANUALES / ANUNCIOS)
========================================= */

.section {
  background: #f9fafb;
  border-radius: 20px;
  padding: 18px 18px 20px;
  margin-bottom: 24px;
  box-shadow: 0 16px 45px rgba(15, 23, 42, 0.24);
  border: 1px solid #e5e7eb;
}

.section h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section h2 i {
  color: #2563eb;
}

/* =========================================
   MANUALES
========================================= */

.manuals {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.manual {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 14px;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  text-decoration: none;
  color: #111827;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    transform 0.1s ease;
}

.manual:hover {
  background-color: #eff6ff;
  border-color: #2563eb;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.18);
  transform: translateY(-1px);
}

.manual .pdf {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fee2e2;
  color: #b91c1c;
  flex-shrink: 0;
}

.manual .pdf i {
  font-size: 1.1rem;
}

.manual-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.manual-sub {
  font-size: 0.78rem;
  color: #6b7280;
}

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

@media (max-width: 1024px) {
  .container {
    max-width: 100%;
    padding: 20px 14px 32px;
  }
}

/* Para tablets / pantallas medianas */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
  }

  .brand h1 {
    font-size: 1.5rem;
  }

  .tools {
    width: 100%;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: flex-start;
    row-gap: 8px;
  }

  .search {
    flex: 1 1 100%;
    min-width: 0;
    margin-right: 0;
  }

  .btn {
    flex: 1 1 auto;
    justify-content: center;
    padding-inline: 10px;
    font-size: 0.8rem;
  }

  .portal-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 14px;
  }

  .section {
    padding: 14px 12px 16px;
    border-radius: 16px;
  }
}

/* =========================================
   ANUNCIOS – GRID + TARJETAS (UNIFICADO)
========================================= */

.section-anuncios {
  margin-bottom: 24px;
}

/* Forzamos que el contenido completo oculto NO se vea */
.anuncio-full[hidden] {
  display: none !important;
}

/* GRID consistente: 3 / 2 / 1 */
.anuncios-list{
  display: grid;
  gap: 18px;
  align-items: stretch;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1100px){
  .anuncios-list{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px){
  .anuncios-list{
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

/* Tarjeta */
.anuncio-item{
  background: #ffffff;
  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.anuncio-item:hover{
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
  background-color: #f9fafb;
}

/* Header */
.anuncio-header{
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 2px;
}

.anuncio-titulo{
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  font-weight: 800;
  font-size: 0.94rem;
  color: #111827;
  line-height: 1.2;
  min-width: 0;
}

.anuncio-titulo i{
  font-size: 0.92rem;
  color: #2563eb;
  margin-top: 2px;
}

/* Clamp del título a 2 líneas */
.anuncio-titulo span{
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.anuncio-meta{
  font-size: 0.75rem;
  color: #6b7280;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.anuncio-fecha i{
  margin-right: 2px;
}

/* Body: texto + thumb (si existe) */
.anuncio-body{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

/* Si NO hay imagen, el grid se vuelve 1 columna */
.anuncio-item.sin-img .anuncio-body{
  grid-template-columns: 1fr;
}

.anuncio-resumen{
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #4b5563;

  /* Clamp a 3 líneas para uniformidad */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.anuncio-thumb{
  flex-shrink: 0;
  width: 84px;
  height: 84px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #f8fafc;
}

.anuncio-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Footer pegado abajo para igualar cards */
.anuncio-footer{
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.anuncio-envios-meta{
  font-size: 0.78rem;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

/* Botón */
.btn-anuncio-ver{
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #ffffff;
  color: #111827;
  font-size: 0.8rem;
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 700;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    transform 0.12s ease;
}

.btn-anuncio-ver i{
  font-size: 0.75rem;
}

.btn-anuncio-ver:hover{
  background-color: #eff6ff;
  border-color: #2563eb;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.18);
  transform: translateY(-1px);
}

/* =========================================
   CONTENIDO COMPLETO (EN MODAL)
========================================= */

.anuncio-full-header h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  color: #111827;
}

.anuncio-full-fecha {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: #6b7280;
}

.anuncio-full-envios {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: #6b7280;
}

.anuncio-full-mensaje {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #111827;
}

.anuncio-full-mensaje p {
  margin-bottom: 6px;
}

.anuncio-full-imagen {
  margin-top: 10px;
}

.anuncio-full-imagen img {
  max-width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
}

/* =========================================
   MODAL DE ANUNCIO (CLARO)
========================================= */

.no-scroll {
  overflow: hidden;
}

.anuncio-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 999;
}

.anuncio-modal.is-open {
  display: block;
}

.anuncio-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
}

.anuncio-modal-dialog {
  position: relative;
  max-width: 760px;
  margin: 5vh auto;
  background: #ffffff;
  border-radius: 20px;
  padding: 18px 20px 20px;
  box-shadow: 0 32px 80px rgba(15, 23, 42, 0.35);
  border: 1px solid #e5e7eb;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.anuncio-modal-content {
  margin-top: 4px;
  overflow-y: auto;
  padding-right: 6px;
}

/* Botón cerrar del modal */
.anuncio-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  border-radius: 999px;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.anuncio-modal-close:hover {
  background-color: #f3f4f6;
  color: #111827;
}

/* =========================================
   ESTILOS GENERALES ADMIN (TABLAS / FORMULARIOS)
========================================= */

.admin-main {
  margin-top: 1.6rem;
  margin-bottom: 2rem;
}

/* Caja principal del admin (dashboard, listas, etc.) */
.card-box {
  background: rgba(15, 23, 42, 0.92);
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  padding: 1.1rem 1.2rem 1.3rem;
  box-shadow: 0 22px 55px rgba(15, 23, 42, 0.85);
  color: #e5e7eb;
  margin-bottom: 1.3rem;
}

.card-box h2 {
  margin: 0 0 .35rem;
  font-size: 1.02rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

.card-box h2 i {
  color: #60a5fa;
}

.card-box p {
  margin: 0 0 .9rem;
  font-size: .86rem;
  color: #9ca3af;
}

/* Píldora usuario logueado */
.user-pill {
  font-size: .8rem;
  color: #9ca3af;
  margin-top: .4rem;
}
.user-pill strong { color: #e5e7eb; }

/* Tablas */
.admin-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 0.8rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  color: #e5e7eb;
  background: #020617;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.85);
}

.admin-table thead {
  background: #0f172a;
}

.admin-table th,
.admin-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(31, 41, 55, 0.95);
}

.admin-table th {
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9ca3af;
}

.admin-table tbody tr:hover {
  background: rgba(15, 23, 42, 0.9);
}

/* Formularios */
.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  margin-top: 0.8rem;
}

@media (max-width: 768px) {
  .admin-form {
    grid-template-columns: 1fr;
  }
}

.admin-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-form label {
  font-size: 0.8rem;
  color: #e5e7eb;
}

.admin-form input[type="text"],
.admin-form input[type="email"],
.admin-form input[type="password"],
.admin-form input[type="number"],
.admin-form select,
.admin-form textarea {
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: #020617;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  color: #e5e7eb;
  outline: none;
}

.admin-form textarea {
  min-height: 90px;
  resize: vertical;
}

.admin-form input::placeholder,
.admin-form textarea::placeholder {
  color: #6b7280;
}

/* Botones secundarios pequeños */
.btn-sm {
  padding: 4px 10px;
  font-size: 0.78rem;
}

.btn-danger {
  border-color: #b91c1c;
  color: #fee2e2;
  background: #7f1d1d;
}
.btn-danger:hover {
  background: #991b1b;
  border-color: #f97373;
}

/* Chips / etiquetas */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  background: #0f172a;
  color: #e5e7eb;
}
.chip--admin { background: #4f46e5; }
.chip--anunciante { background: #0ea5e9; }
.chip--usuario { background: #6b7280; }

/* =========================================
   ADMIN DASHBOARD: STATS
========================================= */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 0.5rem;
}

@media (max-width: 1000px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: #020617;
  border-radius: 14px;
  border: 1px solid rgba(51, 65, 85, 0.9);
  padding: 0.8rem 0.9rem;
}

.stat-label {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #f9fafb;
}

.stat-icon {
  font-size: 1rem;
  color: #60a5fa;
}

/* =========================================
   ADMIN DASHBOARD: ACCESOS RÁPIDOS
========================================= */

.quick-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 900px) {
  .quick-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .quick-links {
    grid-template-columns: 1fr;
  }
}

.quick-link {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid #1f2937;
  background: #020617;
  text-decoration: none;
  color: #e5e7eb;
  font-size: 0.85rem;
}

.quick-link:hover {
  border-color: #3b82f6;
  background: rgba(15, 23, 42, 0.95);
}

.quick-link i {
  margin-top: 0.1rem;
  color: #3b82f6;
}

.quick-link-title {
  font-weight: 600;
  margin-bottom: 0.05rem;
}

.quick-link-sub {
  font-size: 0.78rem;
  color: #9ca3af;
}

/* =========================================
   RESPONSIVE EXTRA PARA MÓVILES PEQUEÑOS
========================================= */

@media (max-width: 640px) {
  .container {
    padding: 18px 12px 28px;
  }

  .brand h1 {
    font-size: 1.35rem;
  }

  .brand .subtle {
    font-size: 0.8rem;
  }

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

  .card {
    border-radius: 18px;
  }

  .manual {
    padding: 8px 9px;
  }

  .manual-title {
    font-size: 0.86rem;
  }

  /* ANUNCIOS en móvil: thumb full */
  .anuncio-body{
    grid-template-columns: 1fr;
  }

  .anuncio-thumb{
    width: 100%;
    height: 150px;
  }

  .anuncio-footer{
    flex-direction: row-reverse;
    justify-content: space-between;
  }

  .anuncio-modal-dialog {
    margin: 4vh 14px;
    padding: 16px 14px 18px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 16px 10px 24px;
  }

  .header {
    margin-bottom: 16px;
  }

  .portal-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .card {
    aspect-ratio: 4 / 3;
  }

  .section {
    padding: 12px 10px 14px;
  }

  .anuncio-modal-dialog {
    margin: 0;
    max-width: 100%;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}
