/* Stylesheet for GoldFlow AI - Flotation Plant Optimizer Dashboard */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  /* Color Palette */
  --bg-darkest: #07090e;
  --bg-card: rgba(15, 22, 39, 0.75);
  --bg-card-hover: rgba(22, 32, 58, 0.9);
  --border-color: rgba(255, 255, 255, 0.07);
  --border-color-glow: rgba(243, 198, 35, 0.3);
  
  --gold: #f3c623;
  --gold-glow: rgba(243, 198, 35, 0.4);
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.4);
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.4);
  --rose: #f43f5e;
  --rose-glow: rgba(244, 63, 94, 0.4);
  --orange: #f97316;
  --orange-glow: rgba(249, 115, 22, 0.4);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-dark: #64748b;
  
  /* Fonts */
  --font-sans: 'Inter', sans-serif;
  --font-title: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Transitions */
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

/* Reset & Scrollbar */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
}

body {
  background-color: var(--bg-darkest);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow-x: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-darkest);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* App Wrapper */
.app-container {
  display: grid;
  grid-template-rows: 70px 1fr;
  height: 100vh;
}

/* Header Section */
header {
  background: rgba(10, 15, 26, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
}

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

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--gold), #d4af37);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-family: var(--font-title);
  color: #000;
  box-shadow: 0 0 15px var(--gold-glow);
  animation: pulse-glow 3s infinite alternate;
}

.brand-name {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.5px;
}

.brand-name span {
  color: var(--gold);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Hardware Selector Toggle */
.hardware-profile-selector {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  display: flex;
  padding: 3px;
  position: relative;
  cursor: pointer;
}

.profile-option {
  padding: 6px 16px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition-smooth);
}

.profile-option.active {
  background: var(--cyan);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 10px var(--cyan-glow);
}

.profile-option.active.arduino {
  background: #00979d; /* Arduino Teal */
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 151, 157, 0.5);
}

/* Global Health Banner */
.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--emerald);
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: var(--emerald);
  border-radius: 50%;
  animation: blink 1.5s infinite;
  box-shadow: 0 0 8px var(--emerald);
}

/* Dashboard Body */
main {
  display: grid;
  grid-template-columns: 280px 1fr 340px;
  overflow: hidden;
  height: 100%;
}

/* Panels (Common) */
.panel {
  background: rgba(10, 15, 26, 0.5);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-left {
  border-right: 1px solid var(--border-color);
}

.panel-right {
  border-left: 1px solid var(--border-color);
  border-right: none;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Scrollable Form Sections */
.sim-section {
  margin-bottom: 24px;
}

.sim-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

/* Parameter Sliders */
.control-group {
  margin-bottom: 16px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.control-value {
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  background: #1e293b;
  height: 6px;
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  box-shadow: 0 0 8px var(--gold-glow);
  transition: var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Select element styling */
.custom-select {
  width: 100%;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  outline: none;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.custom-select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.2);
}

/* Center Dashboard Workspace */
.dashboard-center {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px;
  gap: 20px;
  background: radial-gradient(circle at 50% 30%, #0c1220 0%, #07090e 70%);
}

/* Glassmorphism Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  padding: 16px;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
  pointer-events: none;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

/* Interactive SVG Flowsheet */
.flowsheet-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 300px;
  padding: 10px;
}

.flowsheet-title {
  align-self: flex-start;
  font-family: var(--font-title);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.flowsheet-svg-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* P&ID SVG Classes */
.p-node {
  cursor: pointer;
  transition: var(--transition-smooth);
}

.p-node:hover {
  filter: brightness(1.2) drop-shadow(0px 0px 8px rgba(6, 182, 212, 0.5));
}

.p-node.active rect, .p-node.active ellipse {
  stroke: var(--cyan);
  stroke-width: 2px;
  filter: drop-shadow(0px 0px 6px var(--cyan-glow));
}

.p-flow-line {
  stroke: var(--text-dark);
  stroke-width: 2;
  fill: none;
  stroke-dasharray: 5, 5;
  animation: dash-flow 10s linear infinite;
}

.p-flow-line.active {
  stroke: var(--cyan);
  animation: dash-flow 5s linear infinite;
}

/* Metric Display Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.metric-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

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

.metric-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.metric-icon {
  font-size: 1.1rem;
}

.metric-value {
  font-family: var(--font-title);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.metric-trend {
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.metric-trend.up { color: var(--emerald); }
.metric-trend.down { color: var(--rose); }
.metric-trend.stable { color: var(--text-secondary); }

/* Recovery Main Gauge (Special Card) */
.recovery-gauge-card {
  grid-column: span 1;
  background: linear-gradient(135deg, rgba(20, 27, 49, 0.8) 0%, rgba(10, 15, 27, 0.8) 100%);
  border-color: rgba(243, 198, 35, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gauge-circular-container {
  position: relative;
  width: 90px;
  height: 90px;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg-circle {
  fill: none;
  stroke: rgba(255, 255, 255, 0.05);
  stroke-width: 8;
}

.gauge-value-circle {
  fill: none;
  stroke: var(--gold);
  stroke-width: 8;
  stroke-dasharray: 251.2;
  stroke-dashoffset: 87; /* 65% */
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0px 0px 5px var(--gold-glow));
}

.gauge-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--gold);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-label {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.gauge-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  flex: 1;
  padding-left: 15px;
}

/* Analytics section (Real-time chart) */
.analytics-card {
  grid-column: span 1;
  display: flex;
  flex-direction: column;
  padding: 12px;
  height: 100%;
}

.chart-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 150px;
}

/* AI Brain Side Panel (Right) */
.ai-status-card {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.05) 0%, rgba(10, 15, 26, 0.7) 100%);
  border: 1px solid rgba(6, 182, 212, 0.15);
  padding: 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-avatar {
  width: 44px;
  height: 44px;
  background: rgba(6, 182, 212, 0.1);
  border: 1.5px solid var(--cyan);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cyan);
  font-size: 1.25rem;
  box-shadow: 0 0 10px var(--cyan-glow);
  animation: pulse-glow-cyan 2.5s infinite alternate;
}

.ai-meta {
  flex: 1;
}

.ai-name {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--cyan);
}

.ai-status-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-status-pulse {
  width: 6px;
  height: 6px;
  background: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--cyan);
  animation: blink 1.2s infinite;
}

.ai-mode-control {
  margin-bottom: 16px;
}

.switch-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,0.03);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
}

/* Live Action Log Feed */
.log-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 16px;
  background: rgba(5, 7, 13, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.log-header {
  padding: 8px 12px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.log-feed {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.log-entry {
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(255,255,255,0.04);
  line-height: 1.35;
}

.log-time {
  color: var(--text-dark);
  margin-right: 4px;
}

.log-tag {
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  margin-right: 4px;
  text-transform: uppercase;
}

.log-tag.iot { background: rgba(0, 151, 157, 0.15); color: #00b9c0; border: 1px solid rgba(0, 151, 157, 0.2); }
.log-tag.dcs { background: rgba(6, 182, 212, 0.15); color: var(--cyan); border: 1px solid rgba(6, 182, 212, 0.2); }
.log-tag.action { background: rgba(16, 185, 129, 0.15); color: var(--emerald); border: 1px solid rgba(16, 185, 129, 0.2); }
.log-tag.warning { background: rgba(244, 63, 94, 0.15); color: var(--rose); border: 1px solid rgba(244, 63, 94, 0.2); }
.log-tag.info { background: rgba(249, 115, 22, 0.15); color: var(--orange); border: 1px solid rgba(249, 115, 22, 0.2); }

.log-msg {
  color: var(--text-primary);
}

/* Camera Monitor View */
.camera-card {
  margin-bottom: 16px;
}

.camera-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.camera-feed-box {
  width: 100%;
  aspect-ratio: 3/2;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.07);
}

/* Chat Prompting Area */
.chat-area {
  display: flex;
  flex-direction: column;
  height: 200px;
  background: rgba(5, 7, 13, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.4;
}

.chat-bubble.user {
  align-self: flex-end;
  background: #1e293b;
  color: var(--text-primary);
  border-bottom-right-radius: 2px;
}

.chat-bubble.ai {
  align-self: flex-start;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.15);
  color: var(--text-primary);
  border-bottom-left-radius: 2px;
}

.chat-input-bar {
  display: flex;
  border-top: 1px solid var(--border-color);
  background: rgba(10, 15, 26, 0.8);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: var(--font-sans);
}

.chat-submit {
  background: transparent;
  border: none;
  color: var(--cyan);
  padding: 0 16px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  transition: var(--transition-fast);
}

.chat-submit:hover {
  color: #fff;
  background: rgba(6, 182, 212, 0.15);
}

/* Tooltip on SVG Nodes */
.stage-tooltip {
  position: absolute;
  background: rgba(10, 15, 27, 0.95);
  border: 1px solid var(--cyan);
  border-radius: 6px;
  padding: 10px;
  font-size: 0.75rem;
  pointer-events: none;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  display: none;
  z-index: 1000;
  width: 220px;
  backdrop-filter: blur(8px);
}

.tooltip-header {
  font-family: var(--font-title);
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 4px;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
  color: var(--text-secondary);
}

.tooltip-row span {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* Cost & Profile Compare Card */
.cost-compare-card {
  background: rgba(6, 182, 212, 0.03);
  border-color: rgba(6, 182, 212, 0.1);
  margin-bottom: 16px;
}

.cost-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cost-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
}

.cost-value {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 800;
}

.cost-value.dcs { color: var(--cyan); }
.cost-value.arduino { color: #00b9c0; }

/* Custom Switch styling (for Autonomy Mode) */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #1e293b;
  transition: .3s;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--emerald);
}

input:checked + .slider:before {
  transform: translateX(16px);
  background-color: #fff;
}

/* Keyframes Animations */
@keyframes blink {
  0% { opacity: 0.3; }
  50% { opacity: 1; }
  100% { opacity: 0.3; }
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 10px rgba(243, 198, 35, 0.3); }
  100% { box-shadow: 0 0 20px rgba(243, 198, 35, 0.6); }
}

@keyframes pulse-glow-cyan {
  0% { box-shadow: 0 0 8px rgba(6, 182, 212, 0.3); }
  100% { box-shadow: 0 0 18px rgba(6, 182, 212, 0.6); }
}

@keyframes dash-flow {
  to {
    stroke-dashoffset: -100;
  }
}

/* Tab Buttons */
.tab-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  outline: none;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-card);
  border-bottom-color: transparent;
  color: var(--gold);
  border-top: 2px solid var(--gold);
  box-shadow: 0 -4px 10px rgba(243, 198, 35, 0.05);
}

/* Responsive constraints */
@media(max-width: 1200px) {
  main {
    grid-template-columns: 240px 1fr;
  }
  .panel-right {
    grid-column: span 2;
    border-left: none;
    border-top: 1px solid var(--border-color);
    height: auto;
  }
}

/* Control de Gestión Grid at Top */
.control-gestion-container {
  width: 100%;
}

.control-gestion-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.kpi-card-top {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 90px;
}

.kpi-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.kpi-title-top {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.kpi-icon-top {
  font-size: 0.9rem;
}

.kpi-value-top {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.kpi-unit-top {
  font-size: 0.75rem;
  font-weight: normal;
  color: var(--text-secondary);
  margin-left: 2px;
}

.kpi-desc-top {
  font-size: 0.6rem;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1400px) {
  .control-gestion-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 800px) {
  .control-gestion-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
