/* Reset y Variables */
:root {
  --sidebar-bg: #1a1c3d;
  --sidebar-text: #b1b4db;
  --sidebar-active: #ffffff;
  --dashboard-bg: #f4f7fe;
  --card-dark-bg: #1a1c3d;
  --card-light-bg: #ffffff;
  --accent-blue: #1e3a8a;
  --accent-orange: #ff6600;
  --accent-cyan: #00d2ff;
  --text-main: #333333;
  --text-muted: #8898aa;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--dashboard-bg);
  color: var(--text-main);
  margin: 0;
  overflow-x: hidden;
}

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

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  transition: all 0.3s;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  overflow-y: auto; /* Scroll en el sidebar */
}

/* Scrollbar personalizado para el sidebar */
.sidebar::-webkit-scrollbar {
  width: 5px;
}
.sidebar::-webkit-scrollbar-track {
  background: var(--sidebar-bg);
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.sidebar-header {
  padding: 20px 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white; /* Logo area white to match brand */
  border-bottom: 1px solid #f0f2f5;
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 90px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  padding: 10px 15px;
  display: flex;
  flex-direction: column;
}

.nav-group {
  margin-bottom: 5px;
}

.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  color: var(--sidebar-text);
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
}

.nav-group-header:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--sidebar-active);
}

.nav-group-header .chevron {
  width: 14px;
  height: 14px;
  transition: transform 0.3s;
}

.nav-group-header.collapsed .chevron {
  transform: rotate(-90deg);
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 10px;
  margin-bottom: 2px;
  transition: all 0.2s;
  gap: 12px;
  font-size: 14px;
}

.nav-item i, .nav-item svg {
  width: 20px;
  height: 20px;
}

.nav-item:hover, .nav-item.active {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-active);
}

.nav-item-sub {
  padding-left: 40px !important;
  font-size: 13.5px !important;
  opacity: 0.85;
}

.nav-item-sub:hover {
  opacity: 1;
}

/* DataTables Custom Column Visibility */
.column-toggle-btn {
  background: white;
  border: 1px solid #e0e6ed;
  padding: 5px 15px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.column-toggle-btn:hover {
  background: #f8fafc;
  border-color: var(--sidebar-bg);
}

.dropdown-menu-custom {
  padding: 15px;
  min-width: 200px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.form-check-input:checked {
  background-color: var(--accent-orange);
  border-color: var(--accent-orange);
}

/* Override DT buttons to match brand */
.dt-buttons .btn-secondary {
  background-color: white !important;
  color: var(--sidebar-bg) !important;
  border: 1px solid #e0e6ed !important;
}

.dt-buttons .btn-secondary:hover {
  background-color: #f8fafc !important;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 260px; /* Ancho del sidebar */
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Evita scroll global */
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background-color: var(--sidebar-bg); /* Barra superior azul */
  z-index: 900;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.content-body {
  padding: 30px;
  flex: 1;
  overflow-y: auto; /* Scroll solo en la sección de datos */
  background-color: var(--dashboard-bg);
}

/* Cards */
.card-custom {
  border-radius: 20px;
  border: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  margin-bottom: 25px;
  overflow: hidden;
}

.card-dark {
  background-color: var(--card-dark-bg);
  color: white;
}

.card-light {
  background-color: var(--card-light-bg);
}

.card-header-custom {
  padding: 20px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card-body-custom {
  padding: 25px;
}

/* Dashboard Widgets */
.stat-widget {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat-label {
  font-size: 13px;
  color: var(--sidebar-text);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
}

.stat-trend {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* DataTables Overrides */
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--sidebar-bg) !important;
  color: white !important;
  border: none !important;
  border-radius: 8px !important;
}

table.dataTable {
  border-collapse: separate !important;
  border-spacing: 0 10px !important;
}

table.dataTable tbody tr {
  background-color: white !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02) !important;
}

table.dataTable tbody td {
  padding: 15px !important;
  border: none !important;
}

table.dataTable tbody td:first-child { border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
table.dataTable tbody td:last-child { border-top-right-radius: 10px; border-bottom-right-radius: 10px; }

/* Modals */
.modal-content {
  border-radius: 20px;
  border: none;
}

.modal-header {
  border-bottom: 1px solid #f0f2f5;
  padding: 25px;
}

.modal-body {
  padding: 25px;
}

/* Forms */
.form-control, .form-select {
  border-radius: 10px;
  padding: 12px 15px;
  border: 1px solid #e0e6ed;
}

.btn-primary {
  background-color: var(--sidebar-bg);
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
}

/* Login Page */
.login-page {
  background: linear-gradient(135deg, #1e3a8a 0%, #1a1c3d 100%);
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 420px;
  background: white;
  padding: 50px 40px;
  border-radius: 30px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.3);
}

.badge-active { background: #e6f9f0; color: #00c853; padding: 5px 12px; border-radius: 20px; font-weight: 600; font-size: 12px; }
.badge-inactive { background: #fff2f2; color: #ff5252; padding: 5px 12px; border-radius: 20px; font-weight: 600; font-size: 12px; }

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(255, 255, 255, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.border-white-10 { border-color: rgba(255,255,255,0.1) !important; }

.bg-gradient-purple { background: linear-gradient(135deg, #6f42c1 0%, #4e2b8a 100%); }

.agent-list {
  overflow-x: hidden !important;
}

.agent-row-card {
  transition: all 0.2s;
  border-left: 4px solid transparent;
  width: 100%;
}
.agent-row-card:hover { background-color: rgba(78, 115, 223, 0.05) !important; }
.agent-status-live { border-left-color: #1cc88a; }

.circular-progress-small {
  width: 40px;
  height: 40px;
}
