@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
  --bg-base: #060913;
  --bg-surface: rgba(13, 20, 41, 0.65);
  --bg-card: rgba(22, 32, 64, 0.5);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(248, 149, 9, 0.15);
  
  --color-primary: #142B99;
  --color-primary-light: #2844d4;
  --color-secondary: #F89509;
  --color-secondary-light: #ffaa2b;
  
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #06b6d4;

  --text-main: #f3f4f6;
  --text-muted: #8fa0c2;
  
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Poppins', sans-serif;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Fondo decorativo con gradientes orbitales */
body::before, body::after {
  content: '';
  position: absolute;
  width: 50vw;
  height: 50vw;
  border-radius: 50%;
  filter: blur(150px);
  z-index: -1;
  opacity: 0.12;
}

body::before {
  background: radial-gradient(circle, var(--color-primary) 0%, transparent 70%);
  top: -10vw;
  left: -10vw;
}

body::after {
  background: radial-gradient(circle, var(--color-secondary) 0%, transparent 70%);
  bottom: -10vw;
  right: -10vw;
}

/* ----------------------------------------------------
   1. ESTILOS DE LOGIN (Glass Card)
   ---------------------------------------------------- */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  width: 100%;
  max-width: 420px;
  padding: 40px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 
              0 0 40px rgba(20, 43, 153, 0.1);
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.login-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--color-secondary), transparent);
  animation: borderGlow 4s infinite linear;
}

@keyframes borderGlow {
  0% { left: -100%; }
  100% { left: 100%; }
}

.brand-logo {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  display: inline-block;
}

.logo-servi { color: #ffffff; }
.logo-cargo { color: var(--color-secondary); }

.brand-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 30px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px;
  color: #ffffff;
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

.form-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--color-secondary);
  box-shadow: 0 0 15px rgba(248, 149, 9, 0.2);
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
  border: none;
  border-radius: 12px;
  padding: 14px;
  color: #ffffff;
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(20, 43, 153, 0.3);
  transition: var(--transition-smooth);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(20, 43, 153, 0.5), 0 0 15px rgba(248, 149, 9, 0.2);
  background: linear-gradient(135deg, var(--color-secondary) 0%, var(--color-secondary-light) 100%);
}

.btn-primary:active {
  transform: translateY(0);
}

/* ----------------------------------------------------
   2. ESTRUCTURA PRINCIPAL DEL DASHBOARD
   ---------------------------------------------------- */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Estilo Glass */
.sidebar {
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sidebar-header {
  margin-bottom: 40px;
  text-align: left;
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.menu-item svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  transition: var(--transition-smooth);
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #ffffff;
}

.menu-item.active {
  background: rgba(248, 149, 9, 0.1);
  border-left: 3px solid var(--color-secondary);
  color: var(--color-secondary-light);
}

.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-secondary) 0%, var(--color-primary) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  color: #ffffff;
  font-family: var(--font-title);
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-role {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.btn-logout {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--color-danger);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--font-title);
  transition: var(--transition-smooth);
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Área de contenido principal */
.main-content {
  margin-left: 260px;
  flex-grow: 1;
  padding: 40px;
  max-width: 1400px;
}

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

.page-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.8rem;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ----------------------------------------------------
   3. ESTILOS DE COMPONENTES: Tarjetas y Grid
   ---------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition-smooth);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(248, 149, 9, 0.3);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.icon-blue { background: rgba(20, 43, 153, 0.15); color: #60a5fa; }
.icon-orange { background: rgba(248, 149, 9, 0.15); color: var(--color-secondary); }
.icon-green { background: rgba(16, 185, 129, 0.15); color: var(--color-success); }
.icon-red { background: rgba(239, 68, 68, 0.15); color: var(--color-danger); }

.stat-value {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.2;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel-card {
  background: var(--bg-surface);
  backdrop-filter: blur(15px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 15px;
}

.panel-title {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ----------------------------------------------------
   4. ESTILOS DE COMPONENTES: Tablas Interactivas
   ---------------------------------------------------- */
.table-responsive {
  overflow-x: auto;
  width: 100%;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.custom-table th {
  padding: 14px 16px;
  font-family: var(--font-title);
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.custom-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  color: #e5e7eb;
}

.custom-table tbody tr {
  transition: var(--transition-smooth);
}

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

/* Checkbox personalizado */
.checkbox-container {
  display: block;
  position: relative;
  padding-left: 25px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 18px;
  width: 18px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  transition: var(--transition-smooth);
}

.checkbox-container:hover input ~ .checkmark {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: var(--color-secondary);
}

.checkbox-container input:checked ~ .checkmark {
  background-color: var(--color-secondary);
  border-color: var(--color-secondary);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
  display: block;
}

.checkbox-container .checkmark:after {
  left: 6px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Badges e Indicadores de estado */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-green { background: rgba(16, 185, 129, 0.12); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-orange { background: rgba(245, 158, 11, 0.12); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-red { background: rgba(239, 68, 68, 0.12); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-blue { background: rgba(6, 182, 212, 0.12); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.2); }

.thumbnail-grid {
  display: flex;
  gap: 4px;
}

.thumbnail {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.thumbnail:hover {
  transform: scale(1.5);
  z-index: 10;
}

.pdf-link {
  color: var(--color-secondary-light);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition-smooth);
}

.pdf-link:hover {
  text-decoration: underline;
  color: #ffffff;
}

/* ----------------------------------------------------
   5. ESTILOS DE COMPONENTES: Formularios e Drag & Drop
   ---------------------------------------------------- */
.btn-group {
  display: flex;
  gap: 12px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 12px;
  padding: 10px 20px;
  font-family: var(--font-title);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-muted);
}

/* Plantillas burbujas */
.templates-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.template-bubble {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  text-align: left;
}

.template-bubble input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.template-bubble:hover {
  border-color: rgba(248, 149, 9, 0.3);
  background: rgba(255, 255, 255, 0.05);
}

.template-bubble.selected {
  background: rgba(20, 43, 153, 0.15);
  border-color: var(--color-primary-light);
  box-shadow: 0 0 15px rgba(20, 43, 153, 0.2);
}

.template-name {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
  color: #ffffff;
}

.template-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Dropzone */
.drag-drop-zone {
  border: 2px dashed rgba(248, 149, 9, 0.3);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.01);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  margin-bottom: 20px;
}

.drag-drop-zone:hover, .drag-drop-zone.dragover {
  border-color: var(--color-secondary);
  background: rgba(248, 149, 9, 0.05);
  box-shadow: 0 0 20px rgba(248, 149, 9, 0.1);
}

.drag-drop-icon {
  width: 48px;
  height: 48px;
  stroke: var(--color-secondary);
  fill: none;
  stroke-width: 1.5;
  margin: 0 auto 15px;
}

.drag-drop-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.drag-drop-text strong {
  color: var(--color-secondary-light);
}

.drag-drop-subtext {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  margin-top: 15px;
}

.preview-item {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 8px;
}

/* ----------------------------------------------------
   6. MODAL DE PROCESANDO ENVÍOS (Progress system)
   ---------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 7, 18, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

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

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  width: 100%;
  max-width: 480px;
  padding: 35px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.modal-header {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.4rem;
  margin-bottom: 10px;
}

.modal-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 25px;
}

.progress-container {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  height: 10px;
  width: 100%;
  overflow: hidden;
  margin-bottom: 15px;
}

.progress-bar {
  background: linear-gradient(90deg, var(--color-primary-light), var(--color-secondary));
  height: 100%;
  width: 0%;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(248, 149, 9, 0.5);
  transition: width 0.4s ease;
}

.progress-text {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 30px;
}

.sending-logs {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  height: 150px;
  overflow-y: auto;
  padding: 15px;
  text-align: left;
  font-family: monospace;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #a7f3d0;
}

.log-entry {
  animation: logSlide 0.2s ease-out;
  line-height: 1.4;
}

@keyframes logSlide {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ----------------------------------------------------
   7. TOAST NOTIFICATIONS
   ---------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 20px;
  color: #ffffff;
  min-width: 300px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transition: var(--transition-smooth);
}

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

.toast-success { border-left: 4px solid var(--color-success); }
.toast-error { border-left: 4px solid var(--color-danger); }
.toast-info { border-left: 4px solid var(--color-info); }

.toast-text {
  font-size: 0.85rem;
  font-weight: 500;
}

/* ----------------------------------------------------
   8. DISEÑO RESPONSIVE Y VISTAS ALTERNATIVAS
   ---------------------------------------------------- */
.search-container {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.search-input {
  flex-grow: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 16px;
  color: #ffffff;
  font-family: var(--font-body);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-secondary);
}

.csv-paste-area {
  width: 100%;
  height: 150px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  color: #ffffff;
  font-family: monospace;
  font-size: 0.85rem;
  resize: none;
  margin-bottom: 15px;
}

.csv-paste-area:focus {
  outline: none;
  border-color: var(--color-secondary);
}
