/* ========================================
   OPTOPUS ADMIN - Estilos v1.0.0
   Proyecto independiente
   ======================================== */

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

:root {
  --bg-main:       #f8fafc;
  --bg-card:       #ffffff;
  --bg-elevated:   #f1f5f9;
  --border:        #e2e8f0;
  --text-primary:  #0f172a;
  --text-secondary:#64748b;
  --accent:        #06b6d4;
  --accent-hover:  #0891b2;
  --admin-color:   #f59e0b;
  --admin-dark:    #d97706;
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --shadow:        0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:     0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:     0 20px 40px rgba(0,0,0,0.1);
}

body {
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

/* ========================================
   LOGIN OVERLAY
   ======================================== */

.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.login-modal {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  font-size: 48px;
  text-align: center;
  margin-bottom: 8px;
}

.login-title {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}

.login-badge {
  background: var(--admin-color);
  color: #422006;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.login-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.login-field {
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.login-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color 0.2s;
}

.login-field input:focus {
  outline: none;
  border-color: var(--admin-color);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.login-error {
  background: #fef2f2;
  color: #991b1b;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  border-left: 4px solid var(--danger);
}

.login-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-borrar, .btn-acceder {
  padding: 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-borrar {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}
.btn-borrar:hover { background: var(--border); }

.btn-acceder {
  background: var(--admin-color);
  color: #422006;
}
.btn-acceder:hover { background: var(--admin-dark); color: white; }

.login-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 1px;
  font-weight: 600;
}

/* ========================================
   HEADER (Dashboard)
   ======================================== */

.admin-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: white;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
}

.admin-header h1 {
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-admin {
  background: var(--admin-color);
  color: #422006;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.admin-subtitle {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.admin-user span:first-child {
  font-weight: 600;
}

.admin-role {
  font-size: 11px;
  color: #fbbf24;
}

.btn-salir {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}
.btn-salir:hover { background: rgba(239, 68, 68, 0.25); }

/* ========================================
   MAIN (Dashboard)
   ======================================== */

.admin-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

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

.admin-fecha {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 500;
}

.btn-refresh {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s;
}
.btn-refresh:hover { background: var(--accent-hover); }

.modo-banner {
  background: #fef3c7;
  color: #78350f;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 24px;
  font-weight: 600;
  font-size: 13px;
  text-align: center;
}

.seccion-titulo {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 32px 0 16px;
}

.seccion-titulo:first-child { margin-top: 0; }

/* ========================================
   CARDS DE AGENCIA
   ======================================== */

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

.agencia-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}
.agencia-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.agencia-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.agencia-codigo {
  font-size: 18px;
  font-weight: 700;
}

.estado-badge {
  background: var(--success);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.estado-badge.warning { background: var(--warning); }
.estado-badge.empty   { background: var(--text-secondary); }

.agencia-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.stat-item {
  background: var(--bg-elevated);
  padding: 8px 12px;
  border-radius: 6px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
}

.stat-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-detalle {
  width: 100%;
  background: var(--bg-elevated);
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s;
}
.btn-detalle:hover {
  background: var(--accent);
  color: white;
}

/* ========================================
   TOTALES GLOBALES
   ======================================== */

.totales-globales {
  background: linear-gradient(135deg, var(--accent) 0%, #0891b2 100%);
  color: white;
  border-radius: 16px;
  padding: 32px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  box-shadow: var(--shadow-md);
}

.total-item { display: flex; flex-direction: column; gap: 4px; }

.total-label { font-size: 12px; opacity: 0.9; font-weight: 500; }

.total-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* ========================================
   ACCIONES
   ======================================== */

.acciones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.accion-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  transition: all 0.2s;
}
.accion-card:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.accion-card:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========================================
   LOADING
   ======================================== */

.loading-panel {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-elevated);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

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

/* ========================================
   FOOTER
   ======================================== */

.admin-footer {
  margin-top: 48px;
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 640px) {
  .admin-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .admin-header-right { width: 100%; justify-content: space-between; }
  .admin-toolbar { flex-direction: column; gap: 12px; align-items: stretch; }
  .totales-globales { padding: 20px; }
  .total-value { font-size: 22px; }
  .login-modal { padding: 24px; }
}
