/* =========================================================================
   Estilos de Autenticación, Splash Screen y Gestión de Accesos CCU
   ========================================================================= */

/* ---- Vista de Login ---- */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--plane);
  position: relative;
  z-index: 10;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: 14px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  position: relative;
}

.auth-topbar {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px 0;
}

.auth-body {
  padding: 20px 28px 32px;
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo {
  height: 52px;
  width: auto;
  margin: 0 auto 12px;
  display: block;
}

.auth-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--brand);
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* Alertas de Login */
.auth-alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.4;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.auth-alert.error {
  background: rgba(166, 9, 61, 0.1);
  color: var(--crit);
  border: 1px solid rgba(166, 9, 61, 0.25);
}

.auth-alert.info {
  background: rgba(0, 125, 186, 0.1);
  color: var(--s2t);
  border: 1px solid rgba(0, 125, 186, 0.25);
}

.auth-alert.success {
  background: rgba(0, 168, 107, 0.1);
  color: #008a55;
  border: 1px solid rgba(0, 168, 107, 0.25);
}

/* Botón Google */
.google-btn-container {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
  min-height: 44px;
}

.btn-google-auth,
.btn-google-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 42px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--axis);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.btn-google-auth:hover,
.btn-google-custom:hover {
  background: var(--chip);
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 18px 0;
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--grid);
}

.auth-divider span {
  padding: 0 12px;
}

/* Formulario tradicional */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.auth-field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.auth-field input {
  background: var(--plane);
  color: var(--ink);
  border: 1px solid var(--axis);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  font-size: 13.5px;
  transition: border-color 0.2s;
  width: 100%;
  box-sizing: border-box;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--acento);
  box-shadow: 0 0 0 2px rgba(100, 167, 11, 0.2);
}

.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-input-wrap input {
  padding-right: 40px !important;
  width: 100%;
}

.btn-toggle-pass {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent !important;
  border: none !important;
  color: var(--muted) !important;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  width: 28px;
  height: 28px;
}

.btn-toggle-pass:hover {
  color: var(--brand) !important;
  background: var(--ring) !important;
}

.turnstile-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  width: 100%;
}

.btn-submit-auth {
  margin-top: 6px;
  background: var(--brand) !important;
  color: #ffffff !important;
  border: 1px solid var(--brand) !important;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-submit-auth:hover {
  background: var(--brand-soft) !important;
  color: #ffffff !important;
  border-color: var(--acento) !important;
  box-shadow: 0 4px 14px rgba(32, 92, 64, 0.25);
}

.btn-submit-auth:active {
  transform: translateY(1px);
}

.auth-footer-note {
  margin-top: 20px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ---- Pantalla de Carga de Transición (Splash) ---- */
.auth-splash-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--plane);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.35s ease-out, visibility 0.35s;
}

.auth-splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.splash-isotype-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.splash-spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--acento);
  border-right-color: var(--brand);
  animation: spin 1s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
}

.splash-isotype {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.12));
  animation: pulseIsotipo 1.8s ease-in-out infinite;
}

@keyframes pulseIsotipo {
  0% { transform: scale(0.96); opacity: 0.9; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(0.96); opacity: 0.9; }
}

.splash-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--brand);
  margin: 0 0 6px;
}

.splash-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

/* ---- Header: Perfil de Usuario y Botón Admin ---- */
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--chip);
  border: 1px solid var(--axis);
  border-radius: 20px;
  font-size: 12px;
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--sobre-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-weight: 600;
  color: var(--ink);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 9.5px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.btn-logout {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--axis);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-logout:hover {
  background: var(--surface);
  color: var(--crit);
  border-color: var(--crit);
}

.btn-admin-config {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-admin-config:hover {
  background: var(--brand);
  color: var(--sobre-brand);
}

/* ---- Modal de Gestión de Accesos (Administrador) ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-dialog {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: 14px;
  width: 96%;
  max-width: 960px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 45px -12px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.modal-dialog.modal-dialog-sm {
  max-width: 480px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--grid);
}

.modal-header h2 {
  margin: 0;
  font-size: 17px;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.modal-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  background: var(--chip);
  padding: 18px;
  border-radius: 10px;
  border: 1px solid var(--axis);
  align-items: start;
}

.auth-field-pass {
  display: flex;
  flex-direction: column;
}

.auth-field-action-group {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.users-table-wrap {
  border: 1px solid var(--grid);
  border-radius: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  background: var(--surface);
}

.users-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.users-table th {
  background: var(--chip);
  color: var(--ink2);
  padding: 10px 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}

.users-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--grid);
  color: var(--ink);
  vertical-align: middle;
  white-space: nowrap;
}

.users-table tr:last-child td {
  border-bottom: none;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.status-badge.active {
  background: rgba(78, 132, 9, 0.15);
  color: var(--good);
}

.status-badge.inactive {
  background: rgba(166, 9, 61, 0.15);
  color: var(--crit);
}

.table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

.btn-table-action {
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
  border: 1px solid var(--axis);
  background: var(--chip);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-table-action:hover:not(:disabled) {
  background: var(--ring);
  border-color: var(--brand);
}

.btn-table-action[data-action="delete"] {
  color: var(--crit);
  border-color: rgba(166, 9, 61, 0.25);
}

.btn-table-action[data-action="delete"]:hover:not(:disabled) {
  background: rgba(166, 9, 61, 0.12);
  border-color: var(--crit);
}

.btn-table-action.btn-action-delete {
  background: var(--crit) !important;
  color: #ffffff !important;
  border-color: var(--crit) !important;
}

.btn-table-action.btn-action-delete:hover:not(:disabled) {
  background: #8b0732 !important;
  border-color: #8b0732 !important;
}

.btn-table-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ---- Recomendaciones de Seguridad para Contraseñas ---- */
.password-policy-box {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--axis);
  border-radius: 6px;
  font-size: 11px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.password-policy-box.all-valid {
  border-color: rgba(78, 132, 9, 0.4);
  background: rgba(78, 132, 9, 0.05);
}

.policy-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--brand);
  margin-bottom: 5px;
  font-size: 11px;
}

.policy-requirements-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.policy-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  transition: color 0.2s ease;
}

.policy-item .req-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  min-width: 14px;
  border-radius: 50%;
  background: var(--chip);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.policy-item.valid {
  color: var(--good);
  font-weight: 600;
}

.policy-item.valid .req-icon {
  background: var(--good);
  color: #ffffff;
}

/* ---- Responsividad para Celulares y Tablets ---- */
@media (max-width: 768px) {
  .modal-backdrop {
    padding: 8px;
  }

  .modal-dialog {
    width: 100%;
    max-height: 95vh;
    border-radius: 12px;
  }

  .modal-header {
    padding: 12px 14px;
  }

  .modal-header h2 {
    font-size: 15px;
  }

  .modal-body {
    padding: 12px;
    gap: 16px;
  }

  .user-add-grid {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 12px;
  }

  .auth-card {
    padding: 24px 20px;
    margin: 12px;
    max-width: 100%;
  }

  .auth-title {
    font-size: 19px;
  }

  .btn-submit-auth {
    height: 40px;
    font-size: 12px;
  }

  .table-actions {
    gap: 4px;
  }

  .btn-table-action {
    padding: 4px 6px;
    font-size: 10px;
  }
}

