/* ==========================================================================
   CLOUDFLARE DASHBOARD DESIGN SYSTEM - MAIN THEME & GLOBAL STYLES
   ========================================================================== */

:root {
  /* Brand Colors */
  --cf-orange: #F38020;
  --cf-orange-hover: #E56A00;
  --cf-orange-light: rgba(243, 128, 32, 0.12);
  --cf-orange-border: rgba(243, 128, 32, 0.35);
  --cf-blue: #0051C3;
  --cf-blue-hover: #003E99;
  --cf-blue-light: rgba(0, 81, 195, 0.12);
  --cf-green: #00A65A;
  --cf-green-light: rgba(0, 166, 90, 0.12);
  --cf-red: #E03E3E;
  --cf-red-light: rgba(224, 62, 62, 0.12);
  --cf-yellow: #F5A623;
  --cf-purple: #8A2BE2;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, Monaco, monospace;

  /* Layout dimensions */
  --top-nav-height: 56px;
  --sidebar-width: 256px;
  --sidebar-collapsed-width: 64px;
  --max-content-width: 1400px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 9999px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Theme (Default) */
[data-theme="dark"] {
  --bg-app: #0E0F12;
  --bg-surface: #17181D;
  --bg-surface-elevated: #202229;
  --bg-surface-active: #2B2E38;
  --bg-sidebar: #131418;
  --bg-topbar: #17181D;
  
  --border-subtle: #242731;
  --border-default: #2F3340;
  --border-focus: #F38020;

  --text-primary: #F3F4F6;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  --text-inverse: #0E0F12;

  --badge-bg: #242731;
  --code-bg: #111216;
  --input-bg: #111216;
  --hover-overlay: rgba(255, 255, 255, 0.04);
}

/* Light Theme */
[data-theme="light"] {
  --bg-app: #F4F5F7;
  --bg-surface: #FFFFFF;
  --bg-surface-elevated: #FFFFFF;
  --bg-surface-active: #EAECEF;
  --bg-sidebar: #FAFAFB;
  --bg-topbar: #FFFFFF;

  --border-subtle: #EBEEF2;
  --border-default: #D8DCE3;
  --border-focus: #F38020;

  --text-primary: #1A1D20;
  --text-secondary: #565D69;
  --text-muted: #8F97A3;
  --text-inverse: #FFFFFF;

  --badge-bg: #EBEEF2;
  --code-bg: #F8F9FA;
  --input-bg: #FFFFFF;
  --hover-overlay: rgba(0, 0, 0, 0.03);
}

/* Reset & Global */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  height: 100vh;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

/* App Layout Container */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ==========================================================================
   TOP NAVIGATION BAR
   ========================================================================== */

.top-nav {
  height: var(--top-nav-height);
  background-color: var(--bg-topbar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  position: relative;
  flex-shrink: 0;
}

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

.mobile-toggle-btn {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  align-items: center;
  justify-content: center;
}
.mobile-toggle-btn:hover {
  background-color: var(--hover-overlay);
  color: var(--text-primary);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 12px;
  border-right: 1px solid var(--border-subtle);
}

.cf-logo-icon {
  width: 28px;
  height: 28px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23F38020'%3E%3Cpath d='M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.cf-logo-text {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.8px;
  color: var(--text-primary);
}

.account-selector-container {
  position: relative;
}

.account-selector-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  color: var(--text-primary);
  transition: var(--transition-fast);
}

.account-selector-btn:hover {
  background-color: var(--hover-overlay);
  border-color: var(--border-subtle);
}

.account-avatar {
  width: 26px;
  height: 26px;
  background-color: var(--cf-orange);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
}

.account-avatar.bg-purple { background-color: var(--cf-purple); }
.account-avatar.bg-blue { background-color: var(--cf-blue); }

.account-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.account-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.account-id {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chevron-down-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%239CA3AF'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Nav Center / Search */
.nav-center {
  flex: 1;
  max-width: 480px;
  margin: 0 24px;
}

.global-search-trigger {
  width: 100%;
  height: 36px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.global-search-trigger:hover {
  border-color: var(--cf-orange);
  background-color: var(--bg-surface-elevated);
}

.search-placeholder {
  flex: 1;
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-kbd {
  font-size: 10px;
  font-family: var(--font-mono);
  background-color: var(--badge-bg);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--text-secondary);
}

/* Nav Right */
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-indicator-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background-color: var(--cf-green-light);
  border: 1px solid rgba(0, 166, 90, 0.25);
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--cf-green);
  font-weight: 500;
  transition: var(--transition-fast);
}

.status-indicator-badge:hover {
  background-color: rgba(0, 166, 90, 0.2);
}

.status-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--cf-green);
  box-shadow: 0 0 6px var(--cf-green);
  animation: pulse-green 2s infinite ease-in-out;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition-fast);
  position: relative;
}

.icon-button:hover {
  background-color: var(--hover-overlay);
  color: var(--text-primary);
}

.profile-container {
  position: relative;
  margin-left: 4px;
}

.profile-avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F38020, #FA8B28);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  transition: var(--transition-fast);
}

.profile-avatar-btn:hover {
  border-color: #fff;
  transform: scale(1.05);
}

.badge-count {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  background-color: var(--cf-orange);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   WORKSPACE & SIDEBAR
   ========================================================================== */

.workspace-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.sidebar-nav {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
  height: calc(100vh - var(--top-nav-height));
  z-index: 50;
  transition: var(--transition-normal);
}

.sidebar-scroll-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  padding: 8px 12px 6px;
  margin-top: 8px;
}

.sidebar-menu-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition-fast);
  text-decoration: none;
}

.sidebar-link:hover {
  background-color: var(--hover-overlay);
  color: var(--text-primary);
}

.sidebar-link.active {
  background-color: var(--cf-orange-light);
  color: var(--cf-orange);
  font-weight: 600;
}

.sidebar-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  background-color: var(--badge-bg);
  color: var(--text-secondary);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}

.sidebar-badge-new {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  background-color: var(--cf-orange);
  color: #fff;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.5px;
}

.sidebar-pill {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  background-color: var(--badge-bg);
  color: var(--cf-blue);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* Domain context sidebar */
.domain-context-header {
  padding: 4px 8px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.back-to-sites-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  transition: var(--transition-fast);
}

.back-to-sites-link:hover {
  color: var(--cf-orange);
}

.active-zone-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.active-zone-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--cf-green);
}

.active-zone-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Footer & Upgrade Card */
.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-upgrade-card {
  background: linear-gradient(145deg, var(--bg-surface-elevated), var(--bg-surface));
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upgrade-card-icon {
  font-size: 16px;
}

.upgrade-card-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--text-secondary);
}

.upgrade-card-text strong {
  color: var(--text-primary);
  font-size: 12px;
}

.btn-upgrade-plan {
  width: 100%;
  padding: 6px 0;
  background-color: var(--cf-orange);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  transition: var(--transition-fast);
}

.btn-upgrade-plan:hover {
  background-color: var(--cf-orange-hover);
}

/* ==========================================================================
   MAIN CONTENT VIEWPORT
   ========================================================================== */

.main-content-viewport {
  flex: 1;
  overflow-y: auto;
  background-color: var(--bg-app);
  padding: 24px 32px 64px;
  height: calc(100vh - var(--top-nav-height));
  display: flex;
  flex-direction: column;
}

.content-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 16px;
  color: var(--text-secondary);
}

.cf-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-default);
  border-top-color: var(--cf-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
