/* ===================================================================
   BLITZZIP MN - LAYOUT & STRUCTURE
   Estructura general de la aplicación
   =================================================================== */

/* === Reset y Base === */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Background Decorations === */
.bg-orb {
  position: fixed;
  border-radius: var(--radius-full);
  filter: blur(80px);
  opacity: 0.15;
  pointer-events: none;
  animation: float 12s ease-in-out infinite;
  z-index: 0;
}

.orb-primary {
  width: 320px;
  height: 320px;
  background: var(--brand-primary);
  top: -80px;
  left: -100px;
}

.orb-secondary {
  width: 280px;
  height: 280px;
  background: var(--brand-secondary);
  right: -80px;
  top: 160px;
  animation-delay: -3s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 30px) scale(0.95); }
}

/* === Header / Topbar === */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg) var(--space-xl);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  flex: 1;
}

.brand-logo {
  height: 56px;
  width: auto;
  display: block !important;
  object-fit: contain;
  max-width: 280px;
}

.brand-logo-mobile {
  display: none !important;
  height: 48px;
  width: 48px;
  border-radius: var(--radius-md);
  object-fit: contain;
}

.brand-text {
  display: none !important;
  flex-direction: column;
  gap: 2px;
}

.brand-text h1 {
  margin: 0;
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-text p {
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.4;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* === Main Layout === */
.layout {
  width: min(1200px, 95vw);
  margin: var(--space-xl) auto var(--space-3xl);
  display: grid;
  gap: var(--space-lg);
  position: relative;
  z-index: 1;
}

/* === Panels === */
.panel,
.subpanel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--transition-base);
}

.panel:hover,
.subpanel:hover {
  box-shadow: var(--shadow-lg);
}

.panel {
  padding: var(--space-xl);
  animation: reveal 0.4s ease;
}

.subpanel {
  padding: var(--space-lg);
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Grid Layouts === */
.grid-2 {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  margin-top: var(--space-md);
}

.stack {
  display: grid;
  gap: var(--space-md);
}

/* === Headers === */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-md);
  font-weight: var(--font-weight-bold);
  line-height: 1.3;
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }

.muted {
  color: var(--text-muted);
  margin-top: 0;
  font-size: var(--font-size-sm);
}

/* === Responsive === */
@media (max-width: 1024px) {
  .layout {
    width: min(1024px, 92vw);
  }
}

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
  }

  .brand {
    width: 100%;
  }

  .brand-logo {
    display: none !important;
  }

  .brand-logo-mobile {
    display: block !important;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .layout {
    width: 94vw;
    margin: var(--space-lg) auto var(--space-xl);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: var(--space-sm) var(--space-md);
  }

  .brand {
    gap: var(--space-sm);
  }

  .brand-text h1 {
    font-size: var(--font-size-lg);
  }

  .brand-text p {
    font-size: var(--font-size-xs);
  }

  .layout {
    width: 96vw;
    margin: var(--space-md) auto var(--space-lg);
    gap: var(--space-md);
  }

  .panel,
  .subpanel {
    padding: var(--space-md);
  }
}


.settings-gear {
  font-size: 20px;
  line-height: 1;
  min-width: 44px;
  padding: 10px 12px;
}

/* === Stitch application shell === */
body {
  background:
    radial-gradient(circle at 82% 12%, rgba(37, 125, 160, 0.1), transparent 32rem),
    linear-gradient(145deg, #07090c 0%, #0a0e13 48%, #080b0f 100%);
  overflow-x: hidden;
}

body:has(#panel-dashboard:not([hidden])) {
  padding-left: 248px;
}

.bg-orb {
  opacity: 0.07;
  animation: none;
}

.topbar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  height: 100vh;
  padding: 24px 18px 18px;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 24px;
  background: rgba(10, 13, 17, 0.97);
  border: 1px solid var(--border-light);
  border-width: 0 1px 0 0;
  box-shadow: 10px 0 32px rgba(0, 0, 0, 0.24);
}

.brand {
  flex: 0 0 auto;
  min-height: 66px;
  padding: 2px 8px 20px;
  border-bottom: 1px solid var(--border-light);
}

.brand-logo {
  width: 100%;
  height: 56px;
  max-width: 190px;
}

.app-navigation {
  display: none;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

body:has(#panel-dashboard:not([hidden])) .app-navigation {
  display: flex;
}

.app-nav-item {
  position: relative;
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px 7px 15px;
  border: 1px solid rgba(80, 101, 119, 0.16);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.012);
  color: var(--text-secondary);
  font: inherit;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.app-nav-item::before {
  content: "";
  position: absolute;
  left: 6px;
  width: 3px;
  height: 14px;
  border-radius: 3px;
  background: #40505e;
  opacity: 0.55;
  transition: height var(--transition-fast), background var(--transition-fast), opacity var(--transition-fast);
}

.app-nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-color: rgba(84, 112, 133, 0.42);
}

.app-nav-item:hover::before {
  height: 20px;
  background: var(--brand-primary-light);
  opacity: 1;
}

.app-nav-item.active {
  color: var(--brand-secondary-light);
  background: linear-gradient(90deg, rgba(242, 189, 69, 0.2), rgba(242, 189, 69, 0.07));
  border-color: rgba(242, 189, 69, 0.24);
}

.app-nav-item.active::before {
  height: 24px;
  background: var(--brand-secondary);
  opacity: 1;
}

.app-nav-icon {
  width: 22px;
  font-size: 20px;
  text-align: center;
}

.top-actions {
  width: 100%;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px 52px;
  align-items: center;
  gap: 7px;
}

#license-pill {
  grid-column: 1 / -1;
  grid-row: 1;
  width: 100%;
  justify-content: flex-start;
  border: 1px solid var(--border-color);
}

#license-pill.pill-success {
  color: #78df96;
  background: rgba(43, 151, 78, 0.12);
  border: 1px solid rgba(88, 199, 121, 0.78);
  box-shadow: inset 0 0 0 1px rgba(88, 199, 121, 0.08), 0 0 16px rgba(43, 151, 78, 0.08);
}

.account-avatar {
  grid-column: 1;
  grid-row: 2;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--brand-primary), var(--brand-primary-dark));
  color: white;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid #456276;
}

.account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-name {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid #2d3b47;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.018);
}

#btn-logout {
  grid-column: 3;
  grid-row: 2;
  width: 38px;
  min-width: 38px;
  padding: 7px;
  overflow: hidden;
  color: transparent;
  position: relative;
  border-color: #2d3b47;
  background: rgba(255, 255, 255, 0.018);
}

#btn-logout::after {
  content: "↪";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  font-size: 19px;
}

.language-selector {
  grid-column: 4;
  grid-row: 2;
}

#btn-language {
  width: 100%;
  min-width: 0;
  padding: 7px;
  border-color: #2d3b47 !important;
  background: rgba(255, 255, 255, 0.018);
}

#btn-settings {
  display: none !important;
}

.layout {
  width: min(1420px, calc(100vw - 296px));
  margin: 28px auto 48px;
  gap: 20px;
}

.panel,
.subpanel {
  background: linear-gradient(145deg, rgba(18, 24, 31, 0.98), rgba(13, 18, 23, 0.98));
  border-color: rgba(69, 88, 104, 0.55);
  box-shadow: var(--shadow-md);
}

.panel:hover,
.subpanel:hover {
  box-shadow: var(--shadow-md);
}

.panel {
  padding: 22px;
}

#panel-auth,
#panel-password {
  width: min(470px, calc(100vw - 32px));
  margin: 8vh auto;
  border-top: 3px solid var(--brand-secondary);
}

#panel-dashboard {
  display: grid;
  gap: 18px;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

#panel-dashboard:has(.admin-view:not([hidden])) .dashboard-head {
  margin-bottom: 0;
}

.admin-view:not([hidden]) {
  min-height: calc(100vh - 150px);
}

.admin-view:not([hidden]) > .collapsible-header {
  display: none;
}

#panel-dashboard[hidden] {
  display: none;
}

.dashboard-head {
  display: none;
}

.dashboard-head h2 {
  font-size: 28px;
  letter-spacing: -0.02em;
}

.subpanel {
  scroll-margin-top: 24px;
  padding: 20px;
}

.results-workspace {
  border-style: dashed;
  border-color: rgba(72, 104, 126, 0.62);
}

.admin-view {
  border-color: rgba(69, 88, 104, 0.48);
}

h1, h2, h3, h4 {
  letter-spacing: -0.015em;
}

@media (max-width: 900px) {
  body:has(#panel-dashboard:not([hidden])) {
    padding-left: 0;
    padding-bottom: 78px;
  }

  .topbar {
    position: sticky;
    inset: 0;
    width: 100%;
    height: auto;
    min-height: 68px;
    padding: 10px 16px;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    border-width: 0 0 1px;
    backdrop-filter: none;
  }

  .brand {
    width: auto;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
  }

  .brand-logo {
    display: none !important;
  }

  .brand-logo-mobile {
    display: block !important;
  }

  .app-navigation {
    position: fixed;
    z-index: var(--z-fixed);
    inset: auto 0 0;
    height: 70px;
    padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    flex-direction: row;
    justify-content: space-around;
    gap: 2px;
    background: rgba(12, 16, 21, 0.98);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.38);
  }

  .app-nav-item {
    width: auto;
    flex: 1;
    min-width: 0;
    min-height: 54px;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 4px 3px;
    font-size: 10px;
    text-align: center;
  }

  .app-nav-icon {
    font-size: 19px;
    line-height: 1;
  }

  .app-nav-item > span:last-child {
    display: -webkit-box;
    overflow: hidden;
    line-height: 1.15;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .top-actions {
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    display: grid;
    grid-template-columns: 38px minmax(70px, auto) 38px 52px;
  }

  #license-pill {
    display: none;
  }

  .layout {
    width: min(100% - 24px, 900px);
    margin: 16px auto 24px;
  }
}

@media (max-width: 600px) {
  .topbar {
    padding: 8px 10px;
  }

  .brand-logo-mobile {
    width: 42px;
    height: 42px;
  }

  #license-pill {
    display: none;
  }

  #btn-logout {
    min-width: 44px;
    width: 44px;
    overflow: hidden;
    color: transparent;
    position: relative;
  }

  #btn-logout::after {
    content: "↪";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    font-size: 20px;
  }

  .layout {
    width: calc(100% - 16px);
    margin-top: 10px;
  }

  .panel,
  .subpanel {
    padding: 14px;
  }

  .dashboard-head h2 {
    font-size: 23px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 600px) {
  .brand-logo {
    display: block !important;
    width: 142px;
    max-width: 38vw;
    height: 44px;
  }

  .brand-logo-mobile {
    display: none !important;
  }

  .account-name {
    display: none;
  }

  .top-actions {
    grid-template-columns: 48px 38px 38px;
    gap: 6px;
  }

  .language-selector {
    grid-column: 1;
  }

  .account-avatar {
    grid-column: 2;
  }

  #btn-logout {
    grid-column: 3;
    min-width: 38px;
    width: 38px;
  }

  .topbar {
    justify-content: space-between;
  }
}

#panel-dashboard > .dashboard-head {
  display: none !important;
}
