/* ==========================================================================
   VIVACIOUS CLOUD — dashboard.css
   ========================================================================== */

:root {
  /* Default: Dark Theme */
  --ink:        #08090D;
  --surface:    #12151D;
  --surface-2:  #191D28;
  --line:       #262B3A;
  --text:       #F5F3FF;
  --text-muted: #9096AC;
  --violet:     #7C5CFF;
  --violet-dim: #5B3FE0;
  --teal:       #00E5C9;
  --amber:      #FFB454;
  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  24px;
  --sidebar-w:  200px;
}

body.light-theme {
  /* Light Theme Override */
  --ink:        #FFFFFF;
  --surface:    #F9FAFB;
  --surface-2:  #F3F4F6;
  --line:       #E5E7EB;
  --text:       #111827;
  --text-muted: #6B7280;
  --violet:     #6366F1;
  --violet-dim: #4F46E5;
  --teal:       #0D9488;
  --amber:      #D97706;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: grid;
  grid-template-rows: 70px 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas: 
    "header header"
    "sidebar main";
  transition: background 0.3s ease, color 0.3s ease, grid-template-columns 0.3s ease;
  overflow-x: hidden;
}

/* ==========================================================================
   STARFIELD
   ========================================================================== */
#starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  width: 100%;
  height: 100%;
}
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
body.light-theme #starfield, 
body.light-theme .bg-orbs {
  display: none; /* Hide starry backdrops in light mode */
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.header {
  grid-area: header;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.2s ease;
}

.menu-toggle:hover {
  background: var(--line);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* ==========================================================================
   THEME TOGGLE BUTTON
   ========================================================================== */
.theme-toggle-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.theme-toggle-btn:hover {
  border-color: var(--violet);
  background: var(--line);
  transform: translateY(-1px);
}

.theme-toggle-btn:active {
  transform: translateY(0);
}

.theme-icon-sun { display: none; }
.theme-icon-moon { display: inline-flex; }

body.light-theme .theme-icon-sun { display: inline-flex; }
body.light-theme .theme-icon-moon { display: none; }

/* Ensure brand text is visible in all modes */
.brand-name {
  color: var(--text) !important;
}
.brand-sub {
  color: var(--text-muted) !important;
}

/* Ensure sign out button and others are perfectly visible */
.btn-ghost {
  border: 1px solid var(--line);
  color: var(--text);
  background: transparent;
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--violet);
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 16px;
  z-index: 30;
  transition: background 0.3s ease, border-color 0.3s ease, width 0.3s ease, padding 0.3s ease;
  overflow: hidden;
  position: relative;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: var(--text-muted);
  font-size: 14.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.sidebar-link:hover, .sidebar-link.is-active {
  color: var(--text);
  background: var(--surface-2);
}

.sidebar-link.is-active {
  color: var(--teal);
  font-weight: 600;
}

.sidebar-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-link-text {
  transition: opacity 0.2s ease;
}

/* ==========================================================================
   ACCOUNT BADGE
   ========================================================================== */
.account-badge-container {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.avatar-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--violet-dim));
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(124, 92, 255, 0.25);
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  transition: opacity 0.2s ease;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   COLLAPSED STATE
   ========================================================================== */
body.sidebar-collapsed {
  grid-template-columns: 78px 1fr;
}

body.sidebar-collapsed .sidebar-link-text {
  opacity: 0;
  pointer-events: none;
}

body.sidebar-collapsed .user-info {
  opacity: 0;
  pointer-events: none;
}

body.sidebar-collapsed .account-badge-container {
  align-items: center;
}

/* ==========================================================================
   MAIN CONTENT & SECTION CONTAINERS
   ========================================================================== */
.main-content {
  grid-area: main;
  padding: 32px 24px;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 10;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.dashboard-section {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.dashboard-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 820px;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.35);
  transition: background 0.3s ease, border-color 0.3s ease;
  box-sizing: border-box;
  min-width: 0;
  overflow-x: hidden;
}

.dashboard-card h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 32px;
  margin-bottom: 8px;
  font-weight: 700;
}

.dashboard-card p {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 24px;
}

/* Workflow switcher inside dashboard */
.workflow-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  margin: 0 0 20px 0;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 6px;
  border-radius: var(--radius-md);
  box-sizing: border-box;
}

.workflow-tab-btn {
  flex: 1 1 auto;
  min-width: fit-content;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  box-sizing: border-box;
  white-space: nowrap;
}

.workflow-tab-btn:hover {
  color: var(--text);
  border-color: var(--violet);
  background: var(--surface-2);
}

.workflow-tab-btn.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.4), rgba(45, 212, 191, 0.3));
  border-color: var(--teal);
  box-shadow: 0 2px 10px rgba(45, 212, 191, 0.2);
}

.workflow-view {
  display: none;
  width: 100%;
  min-width: 0;
  animation: workflowFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.workflow-view.active {
  display: block;
}

@media (max-width: 680px) {
  .workflow-nav {
    flex-direction: column;
    gap: 8px;
  }
  .workflow-tab-btn {
    width: 100%;
    white-space: normal;
  }
}

.badge-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.status-bullet {
  color: var(--teal);
  font-weight: bold;
}

/* ==========================================================================
   RESPONSIVE LAYOUTS
   ========================================================================== */
@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
    grid-template-areas: 
      "header"
      "main";
  }

  .sidebar {
    position: fixed;
    top: 70px;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 100;
    box-shadow: 20px 0 40px rgba(0, 0, 0, 0.5);
  }

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

  body.sidebar-collapsed {
    /* No collapsed width layout change on mobile */
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   LOADING SKELETONS & KEYFRAMES
   ========================================================================== */
@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite linear;
}

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

/* ==========================================================================
   BILLING SECTION ENHANCEMENTS
   ========================================================================== */
.billing-grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.billing-stat-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.billing-stat-box:hover {
  border-color: var(--violet);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.4);
}

.billing-stat-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--violet), transparent);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.billing-stat-box:hover::before {
  opacity: 1;
}

.billing-tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.billing-tier-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: all 0.25s ease;
}

.billing-tier-card:hover {
  border-color: var(--teal);
  transform: translateY(-3px);
  box-shadow: 0 14px 32px -8px rgba(0, 229, 201, 0.15);
}

.billing-tier-card.featured {
  border-color: rgba(124, 92, 255, 0.5);
  background: linear-gradient(180deg, rgba(124, 92, 255, 0.08), var(--surface-2));
  box-shadow: 0 8px 24px -6px rgba(124, 92, 255, 0.25);
}

.billing-tier-card.featured:hover {
  border-color: var(--violet);
  box-shadow: 0 16px 36px -6px rgba(124, 92, 255, 0.4);
}

.tier-featured-pill {
  position: absolute;
  top: -10px;
  right: 14px;
  background: linear-gradient(135deg, var(--violet), var(--teal));
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(124, 92, 255, 0.4);
}

.tier-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.tier-name {
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.tier-price {
  font-size: 24px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  color: var(--text);
}

.tier-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 16px;
}

.tier-recharge-btn {
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

/* ==========================================================================
   3D POPPING TIER CAROUSEL
   ========================================================================== */
.tier-carousel-wrapper {
  margin-top: 14px;
  position: relative;
  width: 100%;
}

.tier-carousel-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 14px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.tier-carousel-pills::-webkit-scrollbar {
  display: none;
}

.tier-pill-btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.tier-pill-btn:hover {
  color: var(--text);
  border-color: rgba(0, 229, 201, 0.4);
}

.tier-pill-btn.active {
  background: rgba(0, 229, 201, 0.12);
  border-color: var(--teal);
  color: var(--teal);
  font-weight: 600;
}

.tier-carousel-stage {
  position: relative;
  width: 100%;
  min-height: 440px;
  perspective: 1200px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
  overflow: hidden;
}

.tier-carousel-viewport {
  position: relative;
  width: 100%;
  height: 440px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tier-carousel-card {
  position: absolute;
  width: 90%;
  max-width: 370px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg, 16px);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.45s ease, box-shadow 0.45s ease, filter 0.45s ease;
  will-change: transform, opacity;
  user-select: none;
}

.tier-carousel-card.active {
  transform: translateX(0) scale(1.02) translateZ(40px);
  opacity: 1;
  z-index: 10;
  pointer-events: auto;
  border-color: rgba(0, 229, 201, 0.45);
  box-shadow: 0 20px 48px -12px rgba(0, 229, 201, 0.2), 0 0 25px rgba(0, 229, 201, 0.08);
  filter: none;
}

.tier-carousel-card.prev {
  transform: translateX(-56%) scale(0.88) rotateY(10deg);
  opacity: 0.45;
  z-index: 4;
  pointer-events: auto;
  cursor: pointer;
  filter: blur(0.5px);
}

.tier-carousel-card.next {
  transform: translateX(56%) scale(0.88) rotateY(-10deg);
  opacity: 0.45;
  z-index: 4;
  pointer-events: auto;
  cursor: pointer;
  filter: blur(0.5px);
}

.tier-carousel-card.hidden {
  transform: scale(0.75);
  opacity: 0;
  z-index: 1;
  pointer-events: none;
  visibility: hidden;
}

.tier-carousel-card.popular.active {
  border-color: rgba(124, 92, 255, 0.6);
  background: linear-gradient(180deg, rgba(124, 92, 255, 0.1), var(--surface-2) 40%);
  box-shadow: 0 20px 48px -12px rgba(124, 92, 255, 0.28), 0 0 30px rgba(124, 92, 255, 0.12);
}

.tier-popular-badge {
  position: absolute;
  top: -12px;
  right: 20px;
  background: linear-gradient(135deg, var(--violet), var(--teal));
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 12px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(124, 92, 255, 0.45);
}

.tier-card-header {
  margin-bottom: 12px;
}

.tier-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.tier-card-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.tier-card-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.tier-gross-price {
  font-size: 32px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.tier-net-credit {
  font-size: 13px;
  font-weight: 600;
  color: var(--teal);
  margin-top: 4px;
}

.tier-fee-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.tier-card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 10px 0 14px;
  min-height: 36px;
}

.tier-card-features {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text);
}

.tier-card-features li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.feature-check {
  color: var(--teal);
  font-weight: 700;
  font-size: 12px;
}

.tier-recharge-action-btn {
  width: 100%;
  padding: 12px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  justify-content: center;
}

.carousel-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(20, 24, 33, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  transition: all 0.2s ease;
}

.carousel-nav-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: rgba(0, 229, 201, 0.1);
}

.carousel-nav-btn.prev {
  left: 6px;
}

.carousel-nav-btn.next {
  right: 6px;
}

.tier-carousel-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.tier-dot {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tier-dot:hover {
  background: var(--text-muted);
}

.tier-dot.active {
  width: 24px;
  background: var(--teal);
}

@media (max-width: 640px) {
  .tier-carousel-card.prev {
    transform: translateX(-85%) scale(0.85);
    opacity: 0.25;
  }
  .tier-carousel-card.next {
    transform: translateX(85%) scale(0.85);
    opacity: 0.25;
  }
}

/* ==========================================================================
   SESSIONS SECTION & RESPONSIVE HISTORY TABLE
   ========================================================================== */
#section-sessions .dashboard-card {
  max-width: 100%;
}

.sessions-table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 600px;
  width: 100%;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  position: relative;
}

.sessions-top-scroll-wrapper {
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  height: 10px;
  margin-bottom: 6px;
  -webkit-overflow-scrolling: touch;
}

.sessions-top-scroll-wrapper::-webkit-scrollbar,
.sessions-table-wrapper::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}

.sessions-top-scroll-wrapper::-webkit-scrollbar-track,
.sessions-table-wrapper::-webkit-scrollbar-track {
  background: var(--surface);
}

.sessions-top-scroll-wrapper::-webkit-scrollbar-thumb,
.sessions-table-wrapper::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.sessions-top-scroll-wrapper::-webkit-scrollbar-thumb:hover,
.sessions-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

#section-sessions table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

#section-sessions thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
  box-shadow: 0 1px 0 var(--line);
}

#section-sessions th,
#section-sessions td {
  vertical-align: middle;
}

.btn-download-model {
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
}

.btn-copy-job-id {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.btn-copy-job-id:hover {
  color: var(--teal) !important;
}



