/* ============================================================
   PlugAI Design System — CVI Tecnologias
   Core styles shared across all dashboard pages
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=JetBrains+Mono:wght@400;500&family=Playfair+Display:wght@700;800&display=swap');

/* --- Design Tokens --- */
:root {
  --navy-950: #050A18;
  --navy-900: #0A1128;
  --navy-800: #0D1B3E;
  --navy-700: #112A5C;
  --navy-600: #1A3A7A;
  --accent-blue: #3B6EFF;
  --accent-blue-hover: #2B5AE0;
  --accent-purple: #7C3BFF;
  --accent-teal: #00D4AA;
  --accent-green: #00D084;
  --accent-amber: #FFB800;
  --accent-red: #FF4B6A;
  --accent-coral: #FF6B4A;
  --text-primary: #E8EAF2;
  --text-secondary: #8B92B0;
  --text-tertiary: #5A6180;
  --surface-0: rgba(255,255,255,0.02);
  --surface-1: rgba(255,255,255,0.04);
  --surface-2: rgba(255,255,255,0.07);
  --surface-3: rgba(255,255,255,0.10);
  --border-subtle: rgba(255,255,255,0.06);
  --border-default: rgba(255,255,255,0.10);
  --border-strong: rgba(255,255,255,0.18);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-display: 'Playfair Display', serif;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  background: var(--navy-950);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent-blue); text-decoration: none; transition: color var(--transition); }
a:hover { color: #5B8AFF; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* --- Layout Shell --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy-900);
  border-right: 1px solid var(--border-subtle);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.4px;
}
.logo-sub {
  font-size: 9px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 1px;
}

/* Navigation */
.nav-group {
  padding: 16px 12px 8px;
}
.nav-group-label {
  font-size: 9px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 2px;
  padding: 0 10px;
  margin-bottom: 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.nav-item.active {
  background: rgba(59,110,255,0.12);
  color: var(--accent-blue);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent-blue);
  border-radius: 0 3px 3px 0;
}
.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  flex-shrink: 0;
}
.nav-item.active .nav-dot { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--accent-blue);
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.6;
}
.nav-badge.green { background: var(--accent-green); color: #000; }

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.user-name { font-size: 12px; font-weight: 600; }
.user-role { font-size: 10px; color: var(--text-tertiary); }

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

/* Topbar */
.topbar {
  height: var(--topbar-h);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(5,10,24,0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.breadcrumb {
  font-size: 11px;
  color: var(--text-tertiary);
}
.breadcrumb span { color: var(--text-secondary); }
.topbar-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

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

/* --- Reusable Components --- */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent-blue);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-blue-hover); transform: translateY(-1px); }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}
.btn-ghost:hover { background: var(--surface-1); color: var(--text-primary); }
.btn-danger {
  background: rgba(255,75,106,0.12);
  color: var(--accent-red);
  border: 1px solid rgba(255,75,106,0.2);
}
.btn-danger:hover { background: rgba(255,75,106,0.2); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--surface-2); color: var(--text-primary); }

/* Cards */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
}
.card:hover { border-color: var(--border-default); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
}

/* Metric cards */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: all var(--transition);
}
.metric-card:hover { border-color: var(--border-default); background: var(--surface-2); }
.metric-label {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  font-weight: 600;
}
.metric-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.5px;
}
.metric-delta {
  font-size: 11px;
  margin-top: 6px;
  font-weight: 500;
}
.delta-up { color: var(--accent-green); }
.delta-down { color: var(--accent-red); }
.delta-neutral { color: var(--text-tertiary); }

/* Tables */
.table-wrap {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.table-title { font-size: 14px; font-weight: 600; }
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  padding: 10px 16px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  font-weight: 600;
  text-align: left;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border-subtle);
}
tbody td {
  padding: 12px 16px;
  font-size: 12px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

/* Status pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.pill-active { background: rgba(0,208,132,0.12); color: var(--accent-green); }
.pill-beta { background: rgba(255,184,0,0.12); color: var(--accent-amber); }
.pill-new { background: rgba(124,59,255,0.12); color: var(--accent-purple); }
.pill-inactive { background: var(--surface-2); color: var(--text-tertiary); }
.pill-pro { background: rgba(59,110,255,0.12); color: var(--accent-blue); }
.pill-enterprise { background: rgba(124,59,255,0.12); color: var(--accent-purple); }
.pill-free { background: var(--surface-2); color: var(--text-tertiary); }
.pill-danger { background: rgba(255,75,106,0.1); color: var(--accent-red); }

/* Status dots */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.status-live { background: var(--accent-green); box-shadow: 0 0 6px rgba(0,208,132,0.4); }
.status-trial { background: var(--accent-amber); }
.status-setup { background: var(--text-tertiary); }
.status-error { background: var(--accent-red); }

/* Forms */
.form-group {
  margin-bottom: 18px;
}
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--navy-950);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  transition: all var(--transition);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59,110,255,0.15);
}
.form-input::placeholder { color: var(--text-tertiary); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235A6180' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-hint {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0 12px;
  width: 260px;
  transition: all var(--transition);
}
.search-bar:focus-within { border-color: var(--accent-blue); }
.search-bar input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 8px 0;
  font-size: 12px;
  outline: none;
}
.search-bar input::placeholder { color: var(--text-tertiary); }
.search-icon { color: var(--text-tertiary); font-size: 14px; }

/* Section headers */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  margin-top: 28px;
}
.section-head:first-child { margin-top: 0; }
.section-title {
  font-size: 14px;
  font-weight: 600;
}
.section-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

/* Code blocks */
.code-block {
  background: var(--navy-950);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.8;
  overflow-x: auto;
}
.code-kw { color: #79B8FF; }
.code-str { color: #9ECE6A; }
.code-attr { color: #E06C75; }
.code-cmt { color: #4A5278; }
.code-fn { color: var(--accent-amber); }
.code-val { color: #D19A66; }

/* Chart placeholder */
.chart-placeholder {
  background: var(--surface-1);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
}
.chart-placeholder-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state-desc { font-size: 12px; max-width: 400px; margin: 0 auto 16px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--navy-800);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 520px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 0;
}
.page-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}
.page-btn:hover { background: var(--surface-2); }
.page-btn.active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }

/* Toggle switch */
.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  display: inline-block;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-track::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-track { background: var(--accent-blue); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in {
  animation: fadeInUp 0.4s ease forwards;
  opacity: 0;
}
.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }

/* Mobile hamburger */
.hamburger {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-primary);
  font-size: 18px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* TensorFlow.js / CVITEC integration placeholders */
.tfjs-container {
  border: 1px dashed rgba(59,110,255,0.3);
  border-radius: var(--radius-lg);
  padding: 20px;
  background: rgba(59,110,255,0.03);
  margin-top: 14px;
}
.tfjs-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-blue);
  margin-bottom: 8px;
  font-weight: 600;
}
.cvitec-embed-slot {
  border: 1px dashed rgba(124,59,255,0.3);
  border-radius: var(--radius-lg);
  padding: 20px;
  background: rgba(124,59,255,0.03);
  text-align: center;
  color: var(--text-tertiary);
  font-size: 11px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); }

/* Footer */
.page-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border-subtle);
  font-size: 10px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .hamburger { display: flex; }
  .main-content { margin-left: 0; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .search-bar { width: 180px; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }
}
@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .search-bar { display: none; }
}
