/* ═══════════════════════════════════════════════════════
   LA RATA — Panel Pages (casa.html)
   Dashboard layout, sidebar, chat room, license cards.
   ═══════════════════════════════════════════════════════ */

.panel-layout {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

/* ─── SIDEBAR ─── */
.panel-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform var(--dur-normal) var(--ease-out);
  position: relative;
  z-index: var(--z-sticky);
}

.sidebar-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding-inline: var(--space-lg);
  border-bottom: 1px solid var(--border);
}
.sidebar-header .brand-mark {
  width: 24px;
  height: 24px;
}
.sidebar-header .brand-text {
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
}
.sidebar-header .brand-text strong { font-size: var(--text-md); }

.sidebar-user {
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.sidebar-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px;
  margin-bottom: var(--space-sm);
}
.sidebar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.sidebar-username {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
}
.sidebar-role {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.sidebar-nav {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}
.sidebar-nav button,
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 12px 16px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all var(--dur-fast) var(--ease-out);
  width: 100%;
  text-align: left;
}
.sidebar-nav button:hover,
.sidebar-nav a:hover {
  background: var(--surface);
  color: var(--text-primary);
}
.sidebar-nav button[aria-current="page"] {
  background: var(--accent-subtle);
  color: var(--accent-hover);
}
.sidebar-nav svg {
  width: 18px;
  height: 18px;
  opacity: 0.7;
}
.sidebar-nav button[aria-current="page"] svg { opacity: 1; }

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border);
}

/* ─── MAIN AREA ─── */
.panel-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.panel-topbar {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: var(--space-lg);
  background: rgba(5, 5, 6, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: var(--z-sticky);
}
.panel-topbar h1 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2xl) var(--space-xl);
}
.panel-view {
  max-width: 900px;
  margin-inline: auto;
}

/* ─── PANEL GRID (Dashboard) ─── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  margin-top: var(--space-2xl);
}
@media (min-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1.5fr 1fr;
  }
}

.dashboard-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* License items */
.license-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-md);
}
.license-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  align-items: flex-start;
}
.license-icon {
  width: 48px;
  height: 48px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  flex-shrink: 0;
}
.license-icon img { width: 100%; height: 100%; object-fit: contain; }
.license-info { flex: 1; }
.license-info h3 {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 700;
  margin-bottom: 4px;
}
.license-info p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Stats mini */
.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}
.mini-stat-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}
.mini-stat-box span {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin-bottom: 4px;
}
.mini-stat-box b {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text-primary);
}

/* ─── SALON (Chat) ─── */
.salon-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h) - var(--space-2xl) * 2);
  min-height: 500px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
  position: relative;
}
.salon-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.15;
  mix-blend-mode: screen;
  pointer-events: none;
}
.salon-messages {
  flex: 1;
  padding: var(--space-lg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  z-index: 1;
}
.message-state {
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: var(--space-md);
}
.message-state.error { color: var(--danger); }

.msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  align-self: flex-start;
}
.msg.me { align-self: flex-end; }
.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
}
.msg.me .msg-meta { justify-content: flex-end; }
.msg-author { font-weight: 600; color: var(--text-secondary); }
.msg.me .msg-author { color: var(--accent); }
.msg-time { color: var(--text-muted); }
.msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border-top-left-radius: 2px;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  word-wrap: break-word;
}
.msg.me .msg-bubble {
  background: var(--accent-subtle);
  border-color: var(--border-accent);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: 2px;
}

.salon-form {
  display: flex;
  padding: var(--space-md);
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  z-index: 1;
  gap: var(--space-sm);
}
.salon-form input {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  padding: 0 16px;
  color: var(--text-primary);
  font-size: var(--text-sm);
  transition: border-color var(--dur-normal);
}
.salon-form input:focus {
  border-color: var(--accent);
  outline: none;
}

/* ─── BOOT ERROR ─── */
.boot-error {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.boot-error-card {
  text-align: center;
  max-width: 400px;
  padding: var(--space-2xl);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .panel-sidebar {
    position: fixed;
    inset: 0;
    width: 100%;
    transform: translateX(-100%);
  }
  .panel-sidebar.open {
    transform: translateX(0);
  }
  .panel-topbar {
    justify-content: flex-start;
    gap: var(--space-md);
  }
  .panel-content {
    padding: var(--space-xl) var(--space-md);
  }
  .salon-container {
    height: calc(100vh - var(--header-h) - var(--space-xl) * 2);
  }
}
