/* Self-Host Studio Demo - Matching App Design */

:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #dbeafe;
  --success: #22c55e;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --bg-white: #ffffff;
  --sidebar-width: 220px;
  --header-height: 56px;
  --demo-banner-height: 40px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Demo Banner */
.demo-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: white;
  height: var(--demo-banner-height);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  font-size: 13px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.demo-banner a {
  color: white;
  font-weight: 600;
  text-decoration: underline;
}

.demo-banner .back-link {
  position: absolute;
  left: 16px;
  text-decoration: none;
  opacity: 0.9;
  font-weight: 500;
}

.demo-banner .back-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.role-switcher {
  display: flex;
  gap: 8px;
  align-items: center;
}

.role-switcher span {
  opacity: 0.9;
}

.role-btn {
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,0.3);
  background: transparent;
  color: white;
  transition: all 0.2s;
  text-decoration: none !important;
}

.role-btn:hover {
  background: rgba(255,255,255,0.15);
}

.role-btn.active {
  background: white;
  color: var(--primary);
  border-color: white;
}

/* App Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
  padding-top: var(--demo-banner-height);
}

/* Sidebar - Exact match to studio-web Sidebar.tsx */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--demo-banner-height);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.sidebar-header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-size: 20px;
  font-weight: 700;
  color: #2563eb; /* blue-600 */
  letter-spacing: -0.5px;
}

.sidebar-logo.org-logo {
  color: #059669; /* emerald-600 for org admin */
}

.sidebar-toggle {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-white);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-toggle:hover {
  background: var(--bg);
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  color: #374151; /* gray-700 */
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
  margin: 1px 0;
}

.nav-item:hover {
  background: #f3f4f6; /* gray-100 */
  color: #1f2937; /* gray-800 */
  text-decoration: none;
}

.nav-item.active {
  background: #2563eb; /* blue-600 */
  color: white;
}

.nav-item.active:hover {
  background: #1d4ed8; /* blue-700 */
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke-width: 2;
}

.nav-item .chevron {
  margin-left: auto;
  width: 16px;
  height: 16px;
  transition: transform 0.2s;
}

.nav-item .chevron.expanded {
  transform: rotate(180deg);
}

/* Submenu styling - matches pl-10 in React */
.nav-submenu {
  margin-left: 8px;
  padding-left: 24px;
  border-left: 1px solid var(--border);
  margin-top: 2px;
  margin-bottom: 2px;
}

.nav-submenu .nav-item {
  padding: 8px 12px;
  font-size: 13px;
  gap: 10px;
}

.nav-submenu .nav-item svg {
  width: 18px;
  height: 18px;
}

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.sidebar-footer .nav-item {
  color: var(--text-muted);
}

.sidebar-footer .nav-item:hover {
  color: var(--text);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--demo-banner-height));
}

/* Header */
.header {
  height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 24px;
  gap: 16px;
}

.header-icons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.header-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.header-icon:hover {
  background: var(--bg);
  color: var(--text);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.header-user:hover {
  background: var(--bg);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}

.user-name {
  font-weight: 500;
  color: var(--text);
}

/* Page Content */
.page-content {
  flex: 1;
  padding: 24px;
}

.page-header {
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Cards */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.stat-content h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.stat-link {
  font-size: 13px;
  color: var(--primary);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.blue {
  background: var(--primary-light);
  color: var(--primary);
}

.stat-icon.green {
  background: var(--success-light);
  color: var(--success);
}

.stat-icon.orange {
  background: var(--warning-light);
  color: var(--warning);
}

/* Infrastructure Cards */
.infra-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.infra-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.infra-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.infra-content {
  flex: 1;
}

.infra-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.infra-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.infra-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.infra-status.connected {
  color: var(--success);
}

.infra-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* Tables */
.table-container {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-input {
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  width: 300px;
  background: var(--bg-white);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover {
  background: var(--bg);
}

.table-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge.basic {
  background: var(--bg);
  color: var(--text-secondary);
}

.badge.advanced {
  background: var(--warning-light);
  color: #b45309;
}

.badge.ready {
  background: var(--success-light);
  color: #15803d;
}

.badge.published {
  background: var(--success-light);
  color: #15803d;
}

.badge.draft {
  background: var(--bg);
  color: var(--text-secondary);
}

.badge.running {
  background: var(--success-light);
  color: #15803d;
}

.badge.stopped {
  background: var(--bg);
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
  text-decoration: none;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
  text-decoration: none;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Footer */
.footer {
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  padding: 40px 24px;
  margin-top: auto;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
}

.footer-brand h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

.footer-brand p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.footer-section h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.footer-section a {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.footer-section a:hover {
  color: var(--primary);
}

.footer-bottom {
  max-width: 1200px;
  margin: 24px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 1024px) {
  .stats-grid,
  .infra-grid {
    grid-template-columns: 1fr;
  }

  .footer-content {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .demo-banner {
    flex-direction: column;
    height: auto;
    padding: 8px 16px;
    gap: 8px;
  }

  :root {
    --demo-banner-height: 70px;
  }

  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .footer-content {
    grid-template-columns: 1fr;
  }

  /* Hide demo on mobile and show message */
  .app-layout,
  .screenshot-container,
  .quick-nav {
    display: none !important;
  }

  .mobile-demo-notice {
    display: flex !important;
  }
}

/* Mobile notice - hidden by default */
.mobile-demo-notice {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  text-align: center;
  background: var(--bg);
}

.mobile-demo-notice svg {
  width: 64px;
  height: 64px;
  color: var(--primary);
  margin-bottom: 24px;
}

.mobile-demo-notice h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.mobile-demo-notice p {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  max-width: 400px;
  line-height: 1.6;
}

.mobile-demo-notice .btn {
  padding: 12px 24px;
  font-size: 16px;
}

/* Screenshot-based Demo Styles */
.screenshot-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  padding-top: calc(var(--demo-banner-height) + 20px);
}

.screenshot-wrapper {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.screenshot-wrapper img {
  width: 100%;
  height: auto;
  display: block;
}

/* Clickable hotspots on screenshots */
.hotspot {
  position: absolute;
  cursor: pointer;
  transition: background-color 0.2s;
  border-radius: 4px;
}

.hotspot:hover {
  background-color: rgba(59, 130, 246, 0.15);
}

/* Quick navigation bar below screenshots */
.quick-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  z-index: 100;
}

.quick-nav a {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  transition: all 0.15s;
  text-decoration: none;
}

.quick-nav a:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.quick-nav a.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.quick-nav-divider {
  width: 1px;
  background: var(--border);
  margin: 0 8px;
}

/* Hybrid Layout: HTML Sidebar + Screenshot Content */
.content-screenshot {
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
}

.content-screenshot img {
  width: 100%;
  height: auto;
  display: block;
}
