/* ==========================================================================
   Las Delicias de Belén · Portal BI (Obsidian & Gold Corporate Theme)
   Palette: #0d0d0d / #151412 / #1c1b1b · Gold #b39b5f / #dec484 · Cyan #22d3ee
   ========================================================================== */

:root {
  /* Identidad Oficial Las Delicias de Belén */
  --belen-black: #0d0d0d;
  --belen-surface: #151412;
  --belen-charcoal: #1c1b1b;
  --belen-gold: #b39b5f;
  --belen-gold-dark: #8e763c;
  --belen-gold-light: #dec484;
  --belen-olive: #4a6b35;
  --belen-wine: #7a1c28;
  --belen-petrol: #2e4a62;

  --bg-canvas: var(--belen-black);
  --bg-surface: var(--belen-surface);
  --bg-elevated: var(--belen-charcoal);
  --bg-hover: rgba(179, 155, 95, 0.08);

  --border-subtle: rgba(179, 155, 95, 0.14);
  --border-strong: rgba(179, 155, 95, 0.3);

  --gold: var(--belen-gold);
  --gold-soft: rgba(179, 155, 95, 0.14);
  --gold-border: rgba(179, 155, 95, 0.38);

  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.1);
  --cyan-border: rgba(34, 211, 238, 0.28);

  --text-primary: #f5f3ed;
  --text-secondary: #b5b0a4;
  --text-muted: #7b766c;

  --font-head: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --sidebar-width: 292px;
  --topbar-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --transition-fast: 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-layout: 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

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

html,
body {
  height: 100%;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
}

/* Shell Layout */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-canvas);
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  background: linear-gradient(180deg, #12110f 0%, #151412 100%);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-layout), min-width var(--transition-layout), transform var(--transition-layout), opacity var(--transition-layout);
  z-index: 30;
  overflow: hidden;
}

.app-shell.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  border-right-color: transparent;
  opacity: 0;
  pointer-events: none;
}

.sidebar-backdrop {
  display: none;
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: rgba(13, 13, 13, 0.6);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid var(--belen-gold);
  box-shadow: 0 2px 12px rgba(179, 155, 95, 0.28);
  flex-shrink: 0;
  background: var(--belen-black);
}

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

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-size: 10.5px;
  color: var(--belen-gold-light);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 1px;
}

/* Search Box */
.search-box {
  padding: 14px 14px 10px;
  flex-shrink: 0;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition-fast);
}

.search-input-wrap input {
  width: 100%;
  height: 36px;
  padding: 0 34px 0 34px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input-wrap input::placeholder {
  color: var(--text-muted);
}

.search-input-wrap input::-webkit-search-cancel-button {
  display: none;
}

.search-input-wrap input:focus {
  border-color: var(--belen-gold);
  box-shadow: 0 0 0 3px rgba(179, 155, 95, 0.14);
}

.search-input-wrap input:focus ~ .search-kbd {
  opacity: 0;
}

.search-input-wrap:focus-within .search-icon {
  color: var(--belen-gold-light);
}

.search-kbd {
  position: absolute;
  right: 9px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 6px;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.search-clear {
  position: absolute;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 4px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.search-clear[hidden] {
  display: none !important;
}

.search-clear:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.search-clear svg {
  width: 13px;
  height: 13px;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(179, 155, 95, 0.25) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(179, 155, 95, 0.25);
  border-radius: 999px;
}

.nav-category {
  margin-bottom: 10px;
}

.category-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px;
  border: none;
  background: transparent;
  color: var(--belen-gold);
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.category-toggle:hover {
  color: var(--belen-gold-light);
  background: var(--bg-hover);
}

.category-toggle-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.category-chevron {
  width: 13px;
  height: 13px;
  transition: transform var(--transition-fast);
}

.nav-category.is-collapsed .category-chevron {
  transform: rotate(-90deg);
}

.category-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(179, 155, 95, 0.1);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 1px 7px;
}

.category-list {
  list-style: none;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-category.is-collapsed .category-list {
  display: none;
}

.report-item-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 9px 10px 9px 12px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  position: relative;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.report-item-btn:hover {
  background: var(--bg-hover);
}

.report-item-btn:focus-visible {
  outline: none;
  border-color: var(--belen-gold);
}

.report-item-btn.is-active {
  background: linear-gradient(90deg, rgba(179, 155, 95, 0.18), rgba(179, 155, 95, 0.04));
  border-color: var(--gold-border);
}

.report-item-btn.is-active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--belen-gold-light);
}

.report-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  background: var(--text-muted);
  opacity: 0.45;
  transition: background var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.report-item-btn.is-connected .report-dot {
  background: #4ade80;
  opacity: 0.9;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.55);
}

.report-item-btn.is-active .report-dot {
  background: var(--belen-gold-light);
  opacity: 1;
  box-shadow: 0 0 8px rgba(222, 196, 132, 0.7);
}

.report-item-content {
  min-width: 0;
  flex: 1;
}

.report-item-title {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition-fast);
}

.report-item-btn:hover .report-item-title {
  color: #ffffff;
}

.report-item-btn.is-active .report-item-title {
  color: #ffffff;
  font-weight: 600;
}

.report-item-owner {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-empty {
  padding: 28px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
}

.nav-empty strong {
  display: block;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  flex-shrink: 0;
  background: rgba(13, 13, 13, 0.5);
}

.env-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-weight: 500;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--belen-gold-light);
  box-shadow: 0 0 8px rgba(222, 196, 132, 0.65);
}

.report-count {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Main Workspace & Topbar
   ========================================================================== */

.main-workspace {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
}

.protocol-banner {
  background: rgba(179, 155, 95, 0.14);
  border-bottom: 1px solid var(--gold-border);
  color: var(--belen-gold-light);
  padding: 8px 18px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.protocol-banner[hidden] {
  display: none;
}

.protocol-banner svg {
  width: 16px;
  height: 16px;
  color: var(--belen-gold);
  flex-shrink: 0;
}

.protocol-banner code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(0, 0, 0, 0.4);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--cyan);
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  padding: 0 18px;
  background: linear-gradient(180deg, #0d0d0d 0%, #151412 100%);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

.active-report-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.category-chip {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--belen-gold-light);
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
  padding: 2px 9px;
  border-radius: 999px;
  flex-shrink: 0;
}

.active-title {
  font-family: var(--font-head);
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.active-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.refresh-badge {
  font-size: 11px;
  color: var(--belen-gold-light);
  background: rgba(179, 155, 95, 0.1);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  margin-right: 4px;
}

.btn-powerbi-topbar {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--belen-gold-light);
  background: linear-gradient(135deg, var(--belen-gold) 0%, var(--belen-gold-dark) 100%);
  color: #0d0d0d;
  font-family: var(--font-head);
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 12px rgba(179, 155, 95, 0.22);
  transition: filter var(--transition-fast), transform var(--transition-fast);
}

.btn-powerbi-topbar:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-powerbi-topbar svg {
  width: 14px;
  height: 14px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.icon-btn:hover {
  color: #ffffff;
  border-color: var(--belen-gold);
  background: #24221e;
}

.icon-btn:focus-visible {
  outline: none;
  border-color: var(--belen-gold-light);
  box-shadow: 0 0 0 3px rgba(179, 155, 95, 0.2);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.icon-btn.is-spinning .reload-icon {
  animation: spin 650ms linear infinite;
  color: var(--belen-gold-light);
}

.mobile-only {
  display: none;
}

/* ==========================================================================
   Report Stage, Loader & Iframe
   ========================================================================== */

.report-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--bg-canvas);
  overflow: hidden;
}

.report-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--bg-canvas);
}

/* Loader Overlay */
.report-loader {
  position: absolute;
  inset: 0;
  background: rgba(13, 13, 13, 0.94);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 15;
  opacity: 1;
  visibility: visible;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.report-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.spinner-wrap {
  position: relative;
  width: 48px;
  height: 48px;
}

.spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2.5px solid rgba(179, 155, 95, 0.14);
  border-top-color: var(--belen-gold-light);
  animation: spin 850ms cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}

.spinner-ring-inner {
  inset: 8px;
  border-top-color: transparent;
  border-right-color: var(--belen-gold);
  animation: spin-reverse 1.1s linear infinite;
}

.loader-title {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.loader-hint {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 380px;
  text-align: center;
  padding: 0 16px;
}

/* Toast Notification */
.portal-toast {
  position: absolute;
  bottom: 20px;
  right: 20px;
  max-width: 440px;
  background: #1c1b1b;
  border: 1px solid var(--belen-gold);
  color: var(--text-primary);
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  z-index: 25;
}

.portal-toast[hidden] {
  display: none;
}

.portal-toast strong {
  color: var(--belen-gold-light);
}

.portal-toast code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(0, 0, 0, 0.45);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--cyan);
}

/* Error State */
.error-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg-canvas);
  z-index: 20;
}

.error-state[hidden] {
  display: none;
}

.error-card {
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 26px;
  text-align: center;
}

.error-card h2 {
  font-family: var(--font-head);
  font-size: 16px;
  margin-bottom: 8px;
}

.error-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.btn-primary {
  border: 1px solid var(--gold-border);
  background: var(--gold-soft);
  color: var(--belen-gold-light);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-primary:hover {
  background: rgba(179, 155, 95, 0.24);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes spin-reverse {
  to {
    transform: rotate(-360deg);
  }
}

/* ==========================================================================
   Responsive (Mobile / Tablet)
   ========================================================================== */

@media (max-width: 1200px) {
  .refresh-badge {
    display: none !important;
  }
}

@media (max-width: 900px) {
  .mobile-only {
    display: grid;
  }

  .btn-powerbi-topbar span {
    display: none;
  }

  .btn-powerbi-topbar {
    padding: 0 10px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 310px);
    min-width: 0;
    transform: translateX(-100%);
    opacity: 1;
    pointer-events: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  }

  .app-shell.sidebar-mobile-open .sidebar {
    transform: translateX(0);
  }

  .app-shell.sidebar-collapsed .sidebar {
    width: min(86vw, 310px);
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-layout), visibility var(--transition-layout);
    z-index: 25;
  }

  .app-shell.sidebar-mobile-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }

  .active-subtitle {
    display: none;
  }
}
