/**
 * @file prod/css/global-styles.css
 * @description Design system tokens, header typography hierarchy, fixed bottom bar, sidebar drawer, and toasts.
 * @dependencies None
 * @status Active
 */

:root {
  --bg: #0b1120;
  --card-bg: #131d31;
  --card-inner: #0b1329;
  --card-highlight: #1e2c4a;
  --accent: #38bdf8;
  --accent-hover: #0284c7;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: #243452;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --benchmark: #a78bfa;
  --category: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body {
  padding: 0.75rem 0.5rem 80px 0.5rem;
  display: flex;
  justify-content: center;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

/* App Header & Typography Scale */
header {
  padding: 0.85rem 0.95rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.header-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Primary Website Name: Big & Bold */
.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

/* Active Tab Name: Secondary Subtitle */
.active-tab-subtitle {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.1px;
}

.nav-meta-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.live-dot {
  height: 7px;
  width: 7px;
  background-color: var(--success);
  border-radius: 50%;
  display: inline-block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-icon-btn, .menu-btn {
  background: var(--card-inner);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 1.05rem;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.header-icon-btn:hover, .menu-btn:hover {
  background: var(--card-highlight);
}

.header-icon-btn.rotating {
  animation: spin 1s linear infinite;
}

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

/* Contextual Sub-Tabs Bar */
.sub-tabs {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding: 4px 0;
  margin-bottom: 0.75rem;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.sub-tabs button {
  padding: 6px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sub-tabs button.active {
  background: var(--accent);
  color: #0b1120;
  border-color: var(--accent);
  font-weight: bold;
}

/* Base Content Layout & Cards */
.content-container {
  width: 100%;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

/* Standard Buttons & Form Inputs */
button.btn {
  background: var(--accent);
  color: #0f172a;
  border: none;
  padding: 0.6rem 1.1rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  font-size: 0.82rem;
  white-space: nowrap;
}

button.btn:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--card-inner) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}

.btn-secondary:hover {
  background: var(--card-highlight) !important;
}

.btn-full {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

input[type="text"], input[type="search"], select {
  background: var(--card-inner);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  color: var(--text);
  outline: none;
  font-size: 0.85rem;
}

input[type="text"]:focus, input[type="search"]:focus, select:focus {
  border-color: var(--accent);
}

/* Sidebar Drawer */
.sidebar {
  position: fixed;
  top: 0;
  right: -280px;
  width: 280px;
  height: 100%;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10000;
  padding: 1.25rem;
  box-sizing: border-box;
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

.sidebar.open {
  right: 0 !important;
}

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

.sidebar-brand-title {
  font-size: 1rem;
  color: var(--accent);
  margin: 0;
}

.close-sidebar {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}

.sidebar-links-list {
  line-height: 2.4rem;
  list-style: none;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

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

.sync-meta-text {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.5rem;
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 9999;
  display: none;
}

.sidebar-overlay.active {
  display: block;
}

/* Fixed Bottom Navigation */
.bottom-nav {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100vw !important;
  height: 60px !important;
  background: var(--card-bg) !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-around !important;
  border-top: 1px solid var(--border) !important;
  z-index: 9990 !important;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5) !important;
  margin: 0 !important;
  padding: 0 !important;
}

.bottom-nav a {
  flex: 1 !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  color: var(--text-muted) !important;
  text-decoration: none !important;
  font-size: 0.72rem !important;
  gap: 2px !important;
  cursor: pointer !important;
  user-select: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

.bottom-nav a.active {
  color: var(--accent) !important;
  font-weight: 700 !important;
}

.bottom-nav a .nav-icon {
  font-size: 1.2rem !important;
  line-height: 1 !important;
}

/* Sync Toast Notification */
.sync-toast {
  position: fixed;
  bottom: 75px;
  right: 15px;
  left: 15px;
  max-width: 400px;
  margin: 0 auto;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent);
  backdrop-filter: blur(8px);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  z-index: 10000;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  font-size: 0.78rem;
}

.sync-toast-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: space-between;
}

.sync-pct-badge {
  font-weight: bold;
  color: var(--accent);
}

.progress-bar-bg {
  width: 100%;
  height: 4px;
  background: var(--card-inner);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.4rem;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

/* Mobile Media Queries */
@media (max-width: 640px) {
  body { padding: 0.35rem 0.2rem 80px 0.2rem; }
  .card { padding: 0.85rem 0.5rem !important; border-radius: 6px !important; margin-bottom: 0.75rem !important; }
  .brand-title { font-size: 1.05rem; }
  .active-tab-subtitle { font-size: 0.8rem; }
}
