/* ── GLOBAL LAYOUT SAFETY ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
img, video, canvas, iframe { max-width: 100%; height: auto; }

/* ═══════════════════════════════════════════════════════════════
   RËEL STUDIO — Layout CSS
   Three-panel persistent workspace architecture
   ═══════════════════════════════════════════════════════════════ */

/* ── APP SHELL ──────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 360px;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "header header header"
    "left   center right";
  height: 100vh;
  overflow: hidden;
}

/* ── HEADER ─────────────────────────────────────────────────── */
.app-header {
  grid-area: header;
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-5);
  background: rgba(5,5,9,0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
  z-index: 100; gap: var(--sp-4);
}
.app-header .logo { display: flex; align-items: center; gap: var(--sp-3); text-decoration: none; }
.app-header .logo img { height: 28px; width: auto; }
.app-header .header-center { flex: 1; display: flex; align-items: center; justify-content: center; }
.app-header .header-right { display: flex; align-items: center; gap: var(--sp-4); }
.header-user { display: flex; align-items: center; gap: var(--sp-2); font-size: 12px; color: var(--text-muted); }
.header-units {
  display: flex; align-items: center; gap: var(--sp-1);
  padding: 4px 12px;
  background: rgba(245,201,106,0.08);
  border: 1px solid var(--border-gold);
  border-radius: 999px;
  font-size: 11px; font-family: var(--ff-display);
  letter-spacing: 0.1em; color: var(--gold);
  cursor: pointer; transition: all var(--t-fast);
  box-shadow: 0 0 12px rgba(245,201,106,0.1);
}
.header-units:hover {
  background: rgba(245,201,106,0.15);
  box-shadow: 0 0 20px rgba(245,201,106,0.2);
}

/* ── LEFT PANEL ─────────────────────────────────────────────── */
.panel-left {
  grid-area: left;
  background: rgba(11,11,18,0.9);
  border-right: 1px solid var(--border);
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  backdrop-filter: blur(12px);
}
.nav-section { padding: var(--sp-5) 0 var(--sp-2); }
.nav-section:first-child { padding-top: var(--sp-4); }
.nav-section-label {
  font-family: var(--ff-display); font-size: 9px;
  letter-spacing: 0.25em; color: var(--text-faint);
  padding: 0 12px var(--sp-2); text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 7px 12px; font-size: 12px; color: var(--text);
  cursor: pointer; transition: all var(--t-fast);
  border-left: 2px solid transparent;
  user-select: none; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  border-top: none; border-right: none; border-bottom: none;
  background: none; width: 100%; text-align: left;
  font-family: var(--ff-body);
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-item.active {
  color: var(--gold); border-left-color: var(--gold);
  background: rgba(245,201,106,0.06);
}
.nav-item .nav-icon { font-size: 13px; flex-shrink: 0; width: 16px; text-align: center; }
.nav-item .nav-lucide {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.75);
}
.nav-item .nav-lucide svg { width: 18px; height: 18px; stroke-width: 1.75; }
.nav-item.active .nav-lucide { color: #B26DFF; }
.nav-item .nav-badge {
  margin-left: auto; background: var(--gold); color: var(--bg);
  font-size: 9px; padding: 1px 5px; border-radius: 8px;
  font-family: var(--ff-display); letter-spacing: 0.05em; flex-shrink: 0;
}
.nav-divider { height: 1px; background: var(--border); margin: var(--sp-2) var(--sp-5); }

/* ── CENTER PANEL ───────────────────────────────────────────── */
.panel-center {
  grid-area: center;
  background: transparent !important;
  overflow: hidden; position: relative;
  display: flex; flex-direction: column;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

/* Ensure panel modules don't cover background gradients */
.panel-center > .panel-module {
  background: transparent !important;
}

/* Breathing cinematic glow behind center */
.panel-center::before {
  content: "";
  position: absolute;
  inset: -80px;
  background:
    radial-gradient(circle at 30% 0%,   rgba(245,201,106,0.10), transparent 60%),
    radial-gradient(circle at 80% 100%, rgba(144,92,255,0.14),  transparent 60%);
  opacity: 0.85;
  filter: blur(40px);
  animation: centerGlow 22s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}
@keyframes centerGlow {
  0%   { transform: translate3d(-10px,-10px,0) scale(1); }
  50%  { transform: translate3d(10px,5px,0) scale(1.03); }
  100% { transform: translate3d(-5px,10px,0) scale(1.01); }
}

.panel-center > .panel-module {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  height: 100%; position: relative; z-index: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

/* ── RIGHT PANEL ────────────────────────────────────────────── */
.panel-right {
  flex-shrink: 0;
  width: 360px;

  grid-area: right;
  background: rgba(11,11,18,0.88);
  border-left: 1px solid var(--border);
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  backdrop-filter: blur(12px);
}
.right-section { border-bottom: 1px solid var(--border); padding: var(--sp-4); }
.right-section:last-child { border-bottom: none; }
.right-section-title {
  font-family: var(--ff-display); font-size: 9px;
  letter-spacing: 0.25em; color: var(--text-faint);
  text-transform: uppercase; margin-bottom: var(--sp-3);
}

/* ── OUTAGE BANNER ──────────────────────────────────────────── */
.outage-banner {
  position: fixed; top: var(--header-h);
  left: var(--left-width); right: var(--right-width);
  z-index: 500;
  background: rgba(255,75,107,0.1);
  border-bottom: 1px solid rgba(255,75,107,0.3);
  padding: 10px var(--sp-5);
  display: flex; align-items: center; gap: var(--sp-3);
  font-size: 12px; color: var(--red);
}
.outage-banner.hidden { display: none; }

/* ── AUTH OVERLAY ───────────────────────────────────────────── */
.auth-overlay {
  position: fixed; inset: 0;
  background: rgba(5,5,9,0.96);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}
.auth-overlay.hidden { display: none; }
.auth-card {
  background: linear-gradient(145deg, rgba(255,255,255,0.03), rgba(0,0,0,0.8));
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
  padding: var(--sp-10) var(--sp-8);
  width: 100%; max-width: 400px; text-align: center;
}

/* ── RECOVERY BANNER ────────────────────────────────────────── */
.recovery-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9000;
  background: linear-gradient(135deg, #1a1200, #0d0d0d);
  border-bottom: 1px solid var(--border-gold);
  padding: 12px var(--sp-5);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
}
.recovery-banner.hidden { display: none; }

@media (prefers-reduced-motion: reduce) {
  .panel-center::before { animation: none; }
}

/* ── PREVIEW PANEL CONSTRAINT ───────────────────────────────── */
.preview-panel {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

/* ── CARD GRID ───────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

/* ── IDENTITY PILL SAFETY ────────────────────────────────────── */
.identity-pill,
.identity-tab,
.presence-pill,
[data-identity-tab] {
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 5;
}

/* Patch 1H — Responsive safety */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 210px minmax(0, 1fr) 0px;
  }
  .panel-right {
    display: none;
  }
}

@media (max-width: 600px) {
  .app-shell {
    grid-template-columns: 0px minmax(0, 1fr) 0px;
  }
  .panel-left {
    display: none;
  }
}
