/*!
 * Cabix Hub 2.0 — Thor Luxury Sidebar & Clean Topbar Architecture
 * Inspired by Image 1 (Thor DEX Floating Dark Sidebar) and Image 2 (Uncluttered Topbar)
 * Implemented according to /tasteskill guidelines
 */

/* ========================================================
   APP SHELL LAYOUT (Sidebar Left + Content Right)
   ======================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background: var(--page);
  color: var(--ink);
  overflow-x: hidden;
}

/* ========================================================
   THOR LUXURY SIDEBAR (COLLAPSIBLE, IMAGE 1 STYLE)
   ======================================================== */
.thor-sidebar {
  position: fixed;
  top: 14px;
  bottom: 14px;
  left: 14px;
  width: 236px;
  background: #10151f;
  background: linear-gradient(180deg, #121824 0%, #0d121b 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  z-index: 1100;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 16px 10px;
  user-select: none;
}

/* Collapsed Rail State */
.thor-sidebar.is-collapsed {
  width: 70px;
  padding: 16px 8px;
}

/* Sidebar Brand Header */
.thor-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 16px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 14px;
  overflow: hidden;
}

.thor-brand__icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(16, 185, 129, 0.2));
  border: 1px solid rgba(6, 182, 212, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #06b6d4;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.25);
  transition: transform 0.2s ease;
}

.thor-brand__icon:hover {
  transform: rotate(15deg) scale(1.05);
}

.thor-brand__info {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.thor-sidebar.is-collapsed .thor-brand__info {
  opacity: 0;
  pointer-events: none;
  display: none;
}

.thor-brand__name {
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #f1f5f9;
}

.thor-brand__tag {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  background: rgba(6, 182, 212, 0.15);
  color: #06b6d4;
  border-radius: 6px;
  font-family: var(--font-mono);
}

/* Sidebar Nav Body */
.thor-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-width: none;
}

.thor-nav::-webkit-scrollbar {
  display: none;
}

.thor-nav__group-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #4b5563;
  padding: 10px 10px 4px 10px;
  text-transform: uppercase;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.thor-sidebar.is-collapsed .thor-nav__group-label {
  opacity: 0;
  display: none;
}

.thor-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

/* Individual Links */
.thor-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 13px;
  color: #94a3b8;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.thor-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f8fafc;
}

.thor-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.thor-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  transition: transform 0.2s ease;
}

.thor-link:hover .thor-icon svg {
  transform: scale(1.1);
}

.thor-label {
  flex: 1;
  transition: opacity 0.2s ease;
}

.thor-sidebar.is-collapsed .thor-label {
  opacity: 0;
  display: none;
}

/* Badges */
.thor-badge {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}

.thor-sidebar.is-collapsed .thor-badge {
  display: none;
}

.thor-badge.ai {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.thor-badge.online {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

/* ========================================================
   ACTIVE THOR PILL (IMAGE 1 SIGNATURE STYLE)
   ======================================================== */
.thor-link.is-active {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 4px 18px rgba(14, 165, 233, 0.4);
}

.thor-link.is-active .thor-icon svg {
  stroke: #ffffff;
  stroke-width: 2.3;
}

/* Specific Glowing Accent for AI Agent tab */
.thor-link[data-route="agent"].is-active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.45);
}

/* Floating Tooltip in Collapsed Rail Mode (Image 1 Thor Style) */
.thor-sidebar.is-collapsed .thor-link::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 62px;
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  background: #1e293b;
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 9px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 9999;
}

.thor-sidebar.is-collapsed .thor-link:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(12px);
}

/* ========================================================
   SIDEBAR FOOTER & COLLAPSE CONTROLS (IMAGE 1 BOTTOM)
   ======================================================== */
.thor-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.thor-collapse-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.thor-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

.thor-sidebar.is-collapsed .thor-collapse-btn {
  justify-content: center;
  padding: 9px 0;
}

.thor-sidebar.is-collapsed .thor-collapse-btn .thor-label {
  display: none;
}

.thor-collapse-btn svg {
  transition: transform 0.3s ease;
}

.thor-sidebar.is-collapsed .thor-collapse-btn svg {
  transform: rotate(180deg);
}

/* Social Quick Links Bar (Thor Style) */
.thor-social-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 4px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.thor-sidebar.is-collapsed .thor-social-bar {
  flex-direction: column;
  gap: 6px;
  padding: 6px 2px;
}

.thor-social-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: #64748b;
  transition: all 0.2s ease;
}

.thor-social-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #38bdf8;
  transform: translateY(-2px);
}

/* ========================================================
   MAIN CONTENT COLUMN WITH CLEAN TOPBAR
   ======================================================== */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: 264px; /* 236px width + 28px offset */
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: calc(100% - 264px);
}

.thor-sidebar.is-collapsed ~ .app-main {
  margin-left: 98px; /* 70px width + 28px offset */
  width: calc(100% - 98px);
}

/* ========================================================
   CLEAN TOPBAR (IMAGE 2 FIX: ZERO OVERCROWDING)
   ======================================================== */
.topbar-clean {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 32px;
  background: rgba(11, 14, 15, 0.75);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--hair);
  gap: 16px;
}

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

.mobile-menu-btn {
  display: none;
}

.breadcrumb-trail {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.breadcrumb-parent {
  font-weight: 600;
  color: var(--muted);
}

.breadcrumb-slash {
  color: var(--faint);
  font-size: 12px;
}

.breadcrumb-active {
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.thor-mobile-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  margin-left: auto;
}

.thor-mobile-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

/* Native Mobile Bottom Navigation Bar (App Bar) */
.mobile-bottom-nav {
  display: none;
}

/* Mobile Sidebar Drawer Overlay */
.thor-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 2400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.thor-overlay.is-open {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ========================================================
   RESPONSIVE DESIGN (TABLET & MOBILE)
   ======================================================== */
@media (max-width: 900px) {
  .thor-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 270px;
    transform: translateX(-110%);
    border-radius: 0 20px 20px 0;
    border-left: none;
    z-index: 2500;
    padding: 18px 14px;
    background: #0f141d;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.6);
  }

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

  .thor-mobile-close-btn {
    display: flex;
  }

  .app-main,
  .thor-sidebar.is-collapsed ~ .app-main {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .mobile-menu-btn {
    display: flex;
  }
}

@media (max-width: 768px) {
  /* Native Mobile Bottom Nav Bar (iOS / Android HIG Compliant) */
  .mobile-bottom-nav {
    display: block !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
    background: rgba(14, 18, 26, 0.95) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5) !important;
    z-index: 2000 !important;
    padding: 4px 6px env(safe-area-inset-bottom, 0px) 6px !important;
  }

  .mobile-bottom-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: 52px;
    align-items: center;
  }

  .mobile-tab-link {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #64748b;
    text-decoration: none;
    background: transparent;
    border: none;
    padding: 4px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-tab-icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    transition: transform 0.2s ease, color 0.2s ease;
  }

  .mobile-tab-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1;
    transition: color 0.2s ease;
  }

  .mobile-tab-link.is-active {
    color: #0ea5e9;
  }

  .mobile-tab-link.is-active .mobile-tab-icon {
    color: #0ea5e9;
    transform: scale(1.1);
  }

  .mobile-tab-link[data-route="agent"].is-active {
    color: #10b981;
  }

  .mobile-tab-link[data-route="agent"].is-active .mobile-tab-icon {
    color: #10b981;
  }

  .mobile-tab-badge {
    position: absolute;
    top: 4px;
    right: 14px;
    font-size: 8.5px;
    font-weight: 800;
    padding: 1px 4px;
    background: rgba(99, 102, 241, 0.25);
    color: #818cf8;
    border-radius: 4px;
    border: 1px solid rgba(99, 102, 241, 0.4);
  }

  .mobile-tab-dot {
    position: absolute;
    top: 6px;
    right: 18px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
  }

  /* Compact Topbar on Mobile (Zero Overcrowding / Zero Side-Scroll) */
  .topbar-clean {
    height: 52px !important;
    padding: 0 10px !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  .topbar-left {
    gap: 8px !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }

  .mobile-menu-btn {
    width: 34px !important;
    height: 34px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: #f1f5f9 !important;
    flex-shrink: 0 !important;
  }

  .breadcrumb-trail {
    font-size: 13px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .breadcrumb-parent,
  .breadcrumb-slash {
    display: none !important;
  }

  .breadcrumb-active {
    font-size: 13.5px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .topbar-actions {
    gap: 4px !important;
    flex-shrink: 0 !important;
  }

  .search-trigger {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    justify-content: center !important;
    border-radius: 50% !important;
  }

  .search-trigger span,
  .search-trigger kbd {
    display: none !important;
  }

  .status-pill {
    width: 26px !important;
    height: 32px !important;
    padding: 0 !important;
    justify-content: center !important;
    border-radius: 50% !important;
  }

  .status-pill span:not(.status-dot) {
    display: none !important;
  }

  .topbar-ai-btn {
    height: 32px !important;
    padding: 0 6px !important;
    border-radius: 16px !important;
    font-size: 11px !important;
  }

  .topbar-ai-btn span:not(.ai-sparkle) {
    display: none !important;
  }

  .topbar-ai-badge {
    display: none !important;
  }

  .token-meter-pill {
    height: 32px !important;
    padding: 0 6px !important;
    border-radius: 16px !important;
  }

  .token-meter-text,
  .token-meter-track {
    display: none !important;
  }

  .token-meter-pct {
    font-size: 10px !important;
    padding: 1px 3px !important;
  }

  .icon-btn,
  .profile-btn {
    width: 32px !important;
    height: 32px !important;
    font-size: 11px !important;
  }

  /* Safe Area Bottom Padding for Views Container */
  .app-main,
  .views-container {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 12px)) !important;
  }
}
