/**
 * ==============================================================================
 * ESTILO DEL PORTAL GENERAL - BASADO EN EL DISEÑO ORIGINAL DE EL INSURGENTE
 * ==============================================================================
 * Paleta cálida clásica (Satin Linen / Soft Amber / Sanguine Brown)
 * Diseño de cuadrícula con portadas de fondo, superposición oscura y texto centrado.
 */

:root {
  --satin-linen: #ece7de;
  --soft-amber: #dfd7cb;
  --sanguine-brown: #80242b;
  --sanguine-brown-dark: #60181e;
  --petrol-blue: #103e4d;
  --petrol-blue-dark: #0a2731;
  --border-color: #d6cdbe;
  --card-radius: 20px;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--satin-linen);
  color: #333333;
  margin: 0;
  padding: 15px 20px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  text-decoration: none;
  outline: 0;
}

/* ==============================================================================
   BARRA SUPERIOR Y ENCABEZADO
   ============================================================================== */
.portal-topbar {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto 20px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 15px;
}

.portal-title-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.portal-title-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  background: transparent;
}

.portal-title-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.portal-title-icon svg {
  width: 26px;
  height: 26px;
  fill: #ffffff;
}

.portal-topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.portal-header-logo {
  display: flex;
  align-items: center;
}

.portal-logo-img {
  height: 44px;
  max-width: 230px;
  width: auto;
  object-fit: contain;
  display: block;
}

.portal-title-texts h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--sanguine-brown);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.portal-title-texts p {
  font-size: 0.85rem;
  color: #666666;
}

/* Sesión y salida */
.portal-session-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  background: var(--satin-linen);
  color: var(--petrol-blue);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 6px 14px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-logout {
  background-color: var(--sanguine-brown);
  color: #ffffff;
  border: none;
  border-radius: 30px;
  padding: 7px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-logout:hover {
  background-color: var(--sanguine-brown-dark);
}

/* ==============================================================================
   BARRA DE BÚSQUEDA Y CONTADOR
   ============================================================================== */
.portal-search-bar {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  flex: 1;
  min-width: 260px;
  position: relative;
}

.search-input-wrapper svg {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  fill: #888888;
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  padding: 12px 40px 12px 44px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
  transition: var(--transition);
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.search-input-wrapper input:focus {
  border-color: var(--sanguine-brown);
  box-shadow: 0 0 0 3px rgba(128, 36, 43, 0.15);
}

.btn-clear-search {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: #888888;
  cursor: pointer;
  display: none;
  line-height: 1;
}

.counter-badge {
  background: #ffffff;
  color: #555555;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

/* ==============================================================================
   CONTENEDOR AMBER PRINCIPAL (ESTILO INDEX ORIGINAL)
   ============================================================================== */
.main-apps-container {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  background-color: var(--soft-amber);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  flex: 1;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 25px;
}

/* ==============================================================================
   TARJETAS CON IMAGEN DE FONDO (.image-grid-cover)
   ============================================================================== */
.image-grid-item {
  width: 100%;
}

.image-grid-cover {
  width: 100%;
  min-height: 190px;
  height: 200px;
  position: relative;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  border-radius: var(--card-radius);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  background-color: var(--petrol-blue);
}

.image-grid-cover:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

/* Capa oscura superpuesta al hacer clic (.image-grid-clickbox) */
.image-grid-clickbox {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  width: 100%;
  height: 100%;
  z-index: 20;
  background: rgba(0, 0, 0, 0.45);
  border-radius: var(--card-radius);
  transition: background 0.3s ease;
  text-decoration: none;
}

.image-grid-cover:hover .image-grid-clickbox {
  background: rgba(0, 0, 0, 0.58);
}

/* Texto centrado del proyecto (.cover-wrapper) */
.cover-wrapper {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  display: block;
  color: #ffffff;
  text-shadow: rgba(0, 0, 0, 0.85) 0 2px 4px;
  z-index: 21;
  line-height: 1.35;
  margin-bottom: 6px;
  padding: 0 10px;
  transition: color 0.2s ease;
}

.image-grid-cover:hover .cover-wrapper {
  color: #ffe6a3;
}

/* Subtítulo / etiqueta de carpeta */
.folder-subwrapper {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: rgba(0, 0, 0, 0.35);
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-shadow: none;
  backdrop-filter: blur(4px);
}

/* Estado de búsqueda vacía */
.empty-search-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 50px 20px;
  color: #666666;
}

.empty-search-state h3 {
  font-size: 1.2rem;
  color: var(--petrol-blue);
  margin-bottom: 6px;
}

/* ==============================================================================
   PIE DE PÁGINA
   ============================================================================== */
.portal-footer {
  max-width: 1440px;
  width: 100%;
  margin: 25px auto 0;
  text-align: center;
  font-size: 0.82rem;
  color: #777777;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 10px;
}

.portal-footer a {
  color: var(--sanguine-brown);
  font-weight: 600;
}

/* ==============================================================================
   RESPONSIVO
   ============================================================================== */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  .portal-topbar {
    padding: 14px 18px;
  }
  .portal-title-texts h1 {
    font-size: 1.3rem;
  }
  .main-apps-container {
    padding: 16px;
    border-radius: 15px;
  }
  .apps-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .portal-footer {
    flex-direction: column;
  }
}
