/* =============================================
   ML-MANAGER - Estilos principales
   ============================================= */

:root {
  --ml-yellow: #FFE600;
  --ml-blue: #3483FA;
  --ml-dark: #1a1a2e;
  --ml-sidebar: #16213e;
  --ml-card: #ffffff;
  --ml-bg: #f0f2f5;
  --ml-success: #00a650;
  --ml-warning: #ff7733;
  --ml-danger: #f23d4f;
  --ml-text: #333333;
  --ml-text-light: #999999;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--ml-bg);
  color: var(--ml-text);
  margin: 0;
}

/* --- Login / Registro --- */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--ml-dark) 0%, var(--ml-sidebar) 100%);
}

.auth-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-card h1 {
  text-align: center;
  color: var(--ml-dark);
  margin-bottom: 8px;
  font-size: 28px;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--ml-text-light);
  margin-bottom: 30px;
}

.auth-card .logo {
  text-align: center;
  font-size: 48px;
  margin-bottom: 10px;
}

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

/* --- Sidebar --- */
.sidebar {
  width: 260px;
  background: var(--ml-dark);
  color: white;
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header .logo-icon {
  font-size: 32px;
}

.sidebar-header h2 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

.sidebar-header small {
  display: block;
  font-size: 11px;
  color: var(--ml-text-light);
}

.sidebar-nav {
  padding: 16px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: white;
  background: rgba(255,255,255,0.08);
  border-left-color: var(--ml-yellow);
}

.sidebar-nav a .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sidebar-nav .nav-section {
  padding: 16px 20px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.3);
}

.sidebar-user {
  display: none;
}

.sidebar-user .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sidebar-user .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ml-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.sidebar-user .user-name {
  font-size: 13px;
  font-weight: 600;
}

.sidebar-user .user-email {
  font-size: 11px;
  color: var(--ml-text-light);
}

/* --- Contenido principal --- */
.main-content {
  margin-left: 260px;
  padding: 24px;
  flex: 1;
  min-height: 100vh;
}

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

.page-header h1 {
  font-size: 24px;
  margin: 0;
  color: var(--ml-dark);
}

/* --- Tarjetas de estadísticas --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-card .stat-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--ml-dark);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--ml-text-light);
  margin-top: 4px;
}

/* --- Tarjetas genéricas --- */
.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 16px;
}

.card-body {
  padding: 20px;
}

/* --- Tablas --- */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: var(--ml-bg);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--ml-text-light);
  font-weight: 600;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}

.data-table tr:hover {
  background: #fafafa;
}

.data-table .item-thumb {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  object-fit: cover;
}

/* --- Badges/Etiquetas --- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-active { background: #e6f9ed; color: var(--ml-success); }
.badge-paused { background: #fff3e0; color: var(--ml-warning); }
.badge-closed { background: #fde8ea; color: var(--ml-danger); }
.badge-info { background: #e3f2fd; color: var(--ml-blue); }

/* --- Botones --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary { background: var(--ml-blue); color: white; }
.btn-primary:hover { background: #2968c8; }
.btn-success { background: var(--ml-success); color: white; }
.btn-success:hover { background: #008a43; }
.btn-warning { background: var(--ml-warning); color: white; }
.btn-warning:hover { background: #e66a2a; }
.btn-danger { background: var(--ml-danger); color: white; }
.btn-danger:hover { background: #d32f3f; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--ml-blue);
  color: var(--ml-blue);
}
.btn-outline:hover { background: var(--ml-blue); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Formularios --- */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ml-dark);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

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

select.form-control {
  appearance: auto;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

/* --- Selector de cuentas --- */
.account-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 20px;
  border: 2px solid #e0e0e0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  background: white;
}

.account-chip:hover { border-color: var(--ml-blue); }
.account-chip.selected {
  background: var(--ml-blue);
  color: white;
  border-color: var(--ml-blue);
}

.account-chip input { display: none; }

/* --- Alertas --- */
.alert {
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.alert-info { background: #e3f2fd; color: #1565c0; }
.alert-success { background: #e6f9ed; color: #2e7d32; }
.alert-warning { background: #fff3e0; color: #e65100; }
.alert-danger { background: #fde8ea; color: #c62828; }

/* --- Preguntas --- */
.question-card {
  padding: 16px;
  border: 1px solid #eee;
  border-radius: 10px;
  margin-bottom: 12px;
  transition: box-shadow 0.2s;
}

.question-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.question-card .q-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--ml-text-light);
}

.question-card .q-text {
  font-size: 15px;
  margin-bottom: 12px;
  line-height: 1.5;
}

.question-card .q-item {
  font-size: 12px;
  color: var(--ml-blue);
}

/* --- Notificaciones --- */
.notification-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ml-danger);
  display: inline-block;
}

.notification-count {
  background: var(--ml-danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* --- Spinner de carga --- */
.spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-top-color: var(--ml-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

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

.modal {
  background: white;
  border-radius: 16px;
  padding: 24px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

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

.modal-header h3 { margin: 0; }

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

/* --- Toast notifications --- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: 10px;
  color: white;
  font-weight: 500;
  font-size: 14px;
  animation: slideIn 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.toast-success { background: var(--ml-success); }
.toast-error { background: var(--ml-danger); }
.toast-warning { background: var(--ml-warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- Responsive --- */
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--ml-dark);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 20px;
  cursor: pointer;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .menu-toggle {
    display: block;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ml-text-light);
}

.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-state h3 {
  color: var(--ml-text);
  margin-bottom: 8px;
}
