@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  /* ELITE LIGHT PORTAL - Based on SIGN_ONE_GUIDELINES.md */
  
  /* Accent - Electric Blue (Primary Only) */
  --primary-blue: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-active: #1E40AF;
  
  /* Structure - Deep Slate */
  --sidebar-bg: #1F2933;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-text: #94A3B8;
  --sidebar-text-hover: #ffffff;
  --sidebar-active-bg: rgba(37, 99, 235, 0.1);
  --sidebar-active-text: #2563EB;
  --sidebar-active-border: #2563EB;
  
  /* Base / Surface */
  --topbar-bg: #ffffff;
  --topbar-border: #E2E8F0;
  --topbar-text: #1F2933;
  --topbar-muted: #64748B;
  --main-bg: #F7F9FC;
  --card-bg: #ffffff;
  --border-color: #E2E8F0;
  
  /* Status Colors */
  --status-green: #22c55e;
  --status-yellow: #f59e0b;
  --status-red: #ef4444;
  
  /* Shadows - Minimal, 1px focused */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.08);
  
  /* Layout */
  --sidebar-width: 220px;
  --topbar-height: 72px;
}

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

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--topbar-text);
  background: var(--main-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  opacity: 1;
  animation: none;
}

@keyframes fadeInBody {
  to { opacity: 1; }
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  transition: all 0.15s ease;
  position: relative;
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.hidden {
  display: none !important;
}

/* ============================== SIDEBAR ============================== */

.sidebar, #sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  z-index: 1000;
}

.sidebar-header {
  padding: 28px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-direction: column;
}

.sidebar-logo {
  max-width: 120px;
  height: auto;
}

.logo-text {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
}

.sidebar-nav, #navbar {
  flex: 1;
  padding: 20px 0;
  overflow-y: auto;
  list-style: none;
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
}

#navbar > li {
  padding: 0;
  margin-bottom: 0;
}

.sidebar-nav-button {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  position: relative;
  background: transparent;
  width: 100%;
  text-align: left;
}

.sidebar-nav-button:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-hover);
}

.sidebar-nav-button:active {
  transform: translateX(2px);
}

.sidebar-nav-button.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: var(--sidebar-active-border);
}

.sidebar-nav-icon {
  width: 20px;
  height: 20px;
  font-size: 20px;
  flex-shrink: 0;
}

/* SIDEBAR FOOTER */

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0, 0, 0, 0.2);
}

.status-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: all 0.2s ease;
  position: relative;
  cursor: help;
}

.status-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.status-card::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.95);
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.status-card::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.95);
  pointer-events: none;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 10000;
}

.status-card:hover::after,
.status-card:hover::before {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.status-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.7);
  flex: 1;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
  animation: pulse 2s ease-in-out infinite;
}

.status-dot-green {
  background: var(--status-green);
  color: var(--status-green);
}

.status-dot-yellow {
  background: var(--status-yellow);
  color: var(--status-yellow);
}

.status-dot-red {
  background: var(--status-red);
  color: var(--status-red);
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

.sidebar-settings-button {
  margin-top: 6px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: var(--sidebar-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
  width: 100%;
}

.sidebar-settings-button svg {
  width: 16px;
  height: 16px;
}

.sidebar-settings-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
}

/* ============================== TOPBAR ============================== */

.topbar, #topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  z-index: 999;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topbar-meta-row {
  font-size: 13px;
  color: var(--topbar-muted);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.topbar-select-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topbar-select-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--topbar-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.topbar-select {
  padding: 10px 36px 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--topbar-bg);
  color: var(--topbar-text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 20px;
  min-width: 180px;
  transition: all 0.2s ease;
}

.topbar-select:hover:not(:disabled) {
  border-color: #d1d5db;
  background-color: #f9fafb;
}

.topbar-select:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.topbar-select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background-color: #f3f4f6;
  border-style: dashed;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-button {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}

.topbar-button:hover {
  background: #e5e7eb;
  transform: translateY(-1px);
}

.topbar-button:active {
  transform: translateY(0) scale(0.95);
}

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

#main-content, .main-content, .app-shell {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 32px;
  background: var(--main-bg);
  min-height: calc(100vh - var(--topbar-height));
}

.view {
  display: none;
  opacity: 0;
  animation: fadeInView 0.4s ease forwards;
}

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

@keyframes fadeInView {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================== MODAL ============================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.is-active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 32px;
  max-width: 520px;
  width: 92%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

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

.modal-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--topbar-text);
}

.modal-close-button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--topbar-muted);
  transition: all 0.2s ease;
}

.modal-close-button:hover {
  background: #f3f4f6;
  color: var(--topbar-text);
}

.modal-body {
  font-size: 14px;
  color: var(--topbar-muted);
  line-height: 1.6;
}

/* ============================== TOAST SYSTEM ============================== */

#toastContainer {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 10000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
}

.toast {
  min-width: 360px;
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  font-size: 14px;
  font-weight: 600;
  color: var(--topbar-text);
  opacity: 0;
  transform: translateX(450px) scale(0.9);
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  transition: all 0.3s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.toast.success::before {
  background: var(--status-green);
}

.toast.error::before {
  background: var(--status-red);
}

.toast.info::before {
  background: var(--primary-blue);
}

.toast.warning::before {
  background: var(--status-yellow);
}

.toast-icon {
  font-size: 24px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.toast.success .toast-icon::before {
  content: '✅';
}

.toast.error .toast-icon::before {
  content: '❌';
}

.toast.info .toast-icon::before {
  content: '💡';
}

.toast.warning .toast-icon::before {
  content: '⚠️';
}

.toast-content {
  flex: 1;
  line-height: 1.5;
}

/* ============================== GLOBAL LOADER ============================== */

.global-loader {
  position: fixed;
  inset: 0;
  background: rgba(249, 250, 251, 0.98);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.global-loader.is-active {
  opacity: 1;
  pointer-events: all;
}

.global-loader-inner {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 40px 56px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  animation: loaderFloat 3s ease-in-out infinite;
}

@keyframes loaderFloat {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-8px) scale(1.01);
  }
}

.loader-dots {
  display: flex;
  gap: 12px;
}

.loader-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-blue);
  animation: loaderDot 1s ease-in-out infinite;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.loader-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loader-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes loaderDot {
  0%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.7;
  }
  50% {
    transform: translateY(-16px) scale(1.15);
    opacity: 1;
  }
}

#globalLoaderLabel {
  font-size: 16px;
  font-weight: 700;
  color: var(--topbar-text);
  letter-spacing: 0.01em;
  animation: loaderTextPulse 2s ease-in-out infinite;
}

@keyframes loaderTextPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* ============================== UTILITIES ============================== */

.text-muted {
  color: var(--topbar-muted);
}

.text-good {
  color: var(--status-green);
}

.text-warning {
  color: var(--status-yellow);
}

.text-critical {
  color: var(--status-red);
}
