:root {
  --bg-dark: #0b0f19;
  --bg-sidebar: #111827;
  --bg-card: #1f2937;
  --bg-input: #374151;
  --border-color: #374151;
  
  --primary: #38bdf8;
  --primary-hover: #0284c7;
  --accent-purple: #a855f7;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-inverse: #111827;
  
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --shadow-main: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

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

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  height: 100vh;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding-left: 8px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.brand-text h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-text h2 span {
  color: var(--primary);
}

.brand-text p {
  font-size: 11px;
  color: var(--text-muted);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.nav-btn i {
  font-size: 16px;
  width: 20px;
}

.nav-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.nav-btn.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(168, 85, 247, 0.15));
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--primary);
}

.bot-status-card {
  background-color: rgba(31, 41, 55, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-indicator.online {
  width: 10px;
  height: 10px;
  background-color: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-green);
}

.status-info h4 {
  font-size: 12px;
  font-weight: 600;
}

.status-info p {
  font-size: 10px;
  color: var(--text-muted);
}

/* Main Content */
.main-content {
  margin-left: 260px;
  flex: 1;
  padding: 32px 40px;
  max-width: 1400px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.page-title h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 700;
}

.page-title p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

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

.user-pill {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

/* Tab Contents */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Grid Cards & Dashboard */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-main);
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-card.border-blue { border-left: 4px solid var(--primary); }
.stat-card.border-purple { border-left: 4px solid var(--accent-purple); }
.stat-card.border-green { border-left: 4px solid var(--accent-green); }
.stat-card.border-amber { border-left: 4px solid var(--accent-amber); }

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.card-icon.blue { background-color: rgba(56, 189, 248, 0.15); color: var(--primary); }
.card-icon.purple { background-color: rgba(168, 85, 247, 0.15); color: var(--accent-purple); }
.card-icon.green { background-color: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.card-icon.amber { background-color: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }

.card-data h3 {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-number {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  margin-top: 4px;
}

.dashboard-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.card-header {
  margin-bottom: 20px;
}

.card-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Preview Simulador Dashboard */
.dash-robot-preview {
  display: flex;
  align-items: center;
  gap: 20px;
  background-color: rgba(17, 24, 39, 0.6);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.mini-oled {
  width: 128px;
  height: 64px;
  background-color: #000;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dash-bot-info h4 {
  font-size: 15px;
  color: var(--primary);
  font-weight: 600;
}

.dash-bot-info p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

/* Timeline */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background-color: rgba(17, 24, 39, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.time-badge {
  background-color: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.timeline-info h5 {
  font-size: 14px;
  font-weight: 600;
}

.timeline-info p {
  font-size: 12px;
  color: var(--text-muted);
}

/* Simulador Tab Completo */
.sim-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 24px;
  background-color: rgba(17, 24, 39, 0.5);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.sim-oled-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sim-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.main-oled-frame {
  width: 256px;
  height: 128px;
  background-color: #000;
  border: 4px solid #4b5563;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
}

.sim-state-tag {
  background-color: var(--primary-hover);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.sim-servos-quad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  width: 100%;
}

.servo-item {
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.servo-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.servo-dial {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background-color: #1f2937;
  border: 2px solid #4b5563;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.servo-pointer {
  width: 4px;
  height: 30px;
  background-color: var(--accent-amber);
  position: absolute;
  bottom: 50%;
  transform-origin: bottom center;
  border-radius: 2px;
  transition: transform 0.1s linear;
}

.servo-deg {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

.sim-controls-bar {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.sim-footnote {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.sim-footnote code {
  background-color: rgba(255, 255, 255, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--primary);
}

/* Tables & Forms */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.data-table th, .data-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}

.data-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

.badge.blue { background-color: rgba(56, 189, 248, 0.15); color: var(--primary); }
.badge.green { background-color: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.badge.amber { background-color: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }

/* Reminders Grid */
.reminders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.reminder-card {
  background-color: rgba(17, 24, 39, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  transition: transform 0.2s, border-color 0.2s;
}

.reminder-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-purple);
}

.reminder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.reminder-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.reminder-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Form Styling */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-control {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: white;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

.range-val {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

/* Manual Tab */
.manual-box {
  background-color: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
}

.manual-box h4 {
  color: var(--primary);
  font-size: 16px;
  margin-bottom: 8px;
}

.manual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.manual-card {
  background-color: rgba(17, 24, 39, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.manual-card h5 {
  font-size: 14px;
  color: var(--accent-green);
  margin-bottom: 6px;
}

.manual-card p {
  font-size: 13px;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--primary-hover);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary);
}

.btn-secondary {
  background-color: var(--bg-input);
  color: white;
}

.btn-secondary:hover {
  background-color: #4b5563;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

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

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal.active {
  display: flex;
}

.modal-content {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

/* Toast Popup */
/* Sello de versión (esquina inferior derecha) */
.version-badge {
  position: fixed;
  bottom: 14px;
  right: 18px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(400px, calc(100vw - 36px));
  padding: 6px 12px;
  background-color: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  backdrop-filter: blur(6px);
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
  user-select: none;
}

.version-tag {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.3px;
}

.version-note {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* El toast se apoya arriba del sello para no taparlo */
.toast-popup {
  position: fixed;
  bottom: 76px;
  right: 30px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: white;
  padding: 14px 22px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-popup.show {
  opacity: 1;
  transform: translateY(0);
}

/* Responsive */
@media (max-width: 900px) {
  .app-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  .main-content {
    margin-left: 0;
    padding: 20px;
  }
  .dashboard-split {
    grid-template-columns: 1fr;
  }
  .sim-servos-quad {
    grid-template-columns: 1fr 1fr;
  }
  .version-note {
    display: none;
  }
}
