/* =============================================================
   LOGIN.CSS — Estilos específicos da tela de login
   Depende de: variables.css, Bootstrap 5
============================================================= */

/* -------------------------------------------------------------
   RESET COMPLEMENTAR
------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

/* -------------------------------------------------------------
   BODY — fundo escuro e centralização
------------------------------------------------------------- */
body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  position: relative;
  overflow: hidden;
}

/* Gradiente de fundo */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    var(--gradient-glow),
    radial-gradient(ellipse 80% 60% at 80% 100%, rgba(29,75,155,.10) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* Grade decorativa */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(29,75,155,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29,75,155,.04) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* -------------------------------------------------------------
   SKIP LINK (acessibilidade)
------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  background: var(--gradient-brand);
  color: #fff;
  padding: var(--space-sm) var(--space-md);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-decoration: none;
  z-index: 200;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
}

/* -------------------------------------------------------------
   BARRA DE PROGRESSO
------------------------------------------------------------- */
.progress-bar-top {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--gradient-brand);
  box-shadow: 0 0 8px rgba(29,75,155,.6);
  z-index: 100;
  transition: width 0.15s ease, opacity 0.3s ease;
  opacity: 0;
}

.progress-bar-top.is-active {
  opacity: 1;
}

/* -------------------------------------------------------------
   WRAPPER PRINCIPAL
------------------------------------------------------------- */
.login-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
}

/* -------------------------------------------------------------
   CARD
------------------------------------------------------------- */
.login-card {
  background: var(--color-surface) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-lg) !important;
  padding: var(--space-xl) var(--space-xl) var(--space-2xl) !important;
  box-shadow:
    0 0 0 1px rgba(29,75,155,.06),
    0 24px 64px rgba(0,0,0,.55),
    0 8px 24px rgba(0,0,0,.40) !important;
  animation: cardIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* -------------------------------------------------------------
   HEADER / LOGO
------------------------------------------------------------- */
.login-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--gradient-brand);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  box-shadow: 0 0 20px rgba(29,75,155,.40);
}

.logo-mark svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: #fff;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logo-name {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.logo-tagline {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  letter-spacing: 0.4px;
  margin-bottom: 0;
}

/* -------------------------------------------------------------
   TÍTULO DA SEÇÃO
------------------------------------------------------------- */
.login-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-xs);
}

.login-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xl);
}

/* -------------------------------------------------------------
   RÓTULOS DE CAMPO
------------------------------------------------------------- */
.field-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.field-label .required {
  color: var(--color-text-error);
  font-size: var(--font-size-xs);
  line-height: 1;
}

/* -------------------------------------------------------------
   INPUT WRAPPER — ícone + campo + toggle
------------------------------------------------------------- */
.input-wrapper {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-placeholder);
  pointer-events: none;
  transition: color var(--transition-fast);
  z-index: 5;
}

.input-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Sobrescreve Bootstrap para aplicar tema escuro */
.field-input {
  width: 100%;
  height: 46px;
  padding: 0 44px 0 42px !important;
  background: var(--color-surface-alt) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md) !important;
  color: var(--color-text-primary) !important;
  font-family: var(--font-family);
  font-size: var(--font-size-md) !important;
  outline: none;
  transition:
    border-color var(--transition-fast),
    box-shadow   var(--transition-fast),
    background   var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

.field-input::placeholder {
  color: var(--color-text-placeholder) !important;
}

.field-input:focus {
  border-color: var(--color-border-focus) !important;
  box-shadow: 0 0 0 3px rgba(29,75,155,.18) !important;
  background: #1c2035 !important;
}

.input-wrapper:focus-within .input-icon {
  color: var(--color-border-focus);
}

/* Estado de erro */
.field-group.is-error .field-input {
  border-color: var(--color-border-error) !important;
  box-shadow: 0 0 0 3px rgba(255,77,109,.15) !important;
}

.field-group.is-error .input-icon {
  color: var(--color-text-error);
}

/* Estado de sucesso */
.field-group.is-success .field-input {
  border-color: var(--color-border-success) !important;
  box-shadow: 0 0 0 3px rgba(34,197,94,.12) !important;
}

/* Mensagem de erro do campo */
.field-message {
  display: none;
  font-size: var(--font-size-xs);
  gap: 4px;
  align-items: center;
  margin-top: var(--space-xs);
}

.field-group.is-error .field-message {
  display: flex;
  color: var(--color-text-error);
}

.field-message svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Botão de toggle de senha */
.btn-toggle-password {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-placeholder);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
  z-index: 5;
}

.btn-toggle-password:hover,
.btn-toggle-password:focus-visible {
  color: var(--color-text-primary);
  outline: 2px solid var(--color-border-focus);
  outline-offset: 1px;
}

.btn-toggle-password svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* -------------------------------------------------------------
   LINHA DE OPÇÕES (lembrar + esqueci)
------------------------------------------------------------- */
.form-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

/* Checkbox customizado */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  user-select: none;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  transition: color var(--transition-fast);
  margin-bottom: 0;
}

.checkbox-label:hover {
  color: var(--color-text-primary);
}

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

.checkbox-custom {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    border-color var(--transition-fast),
    background   var(--transition-fast),
    box-shadow   var(--transition-fast);
}

.checkbox-custom svg {
  width: 10px;
  height: 10px;
  stroke: #fff;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.checkbox-input:checked + .checkbox-custom {
  background: var(--gradient-brand);
  border-color: transparent;
  box-shadow: 0 0 10px rgba(29,75,155,.40);
}

.checkbox-input:checked + .checkbox-custom svg {
  opacity: 1;
  transform: scale(1);
}

.checkbox-input:focus-visible + .checkbox-custom {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
}

.link-forgot {
  font-size: var(--font-size-sm);
  color: var(--color-text-link);
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

.link-forgot:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.link-forgot:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* -------------------------------------------------------------
   BOTÃO DE LOGIN
------------------------------------------------------------- */
.btn-login {
  position: relative;
  width: 100%;
  height: 48px;
  border: none !important;
  border-radius: var(--radius-md) !important;
  background: var(--gradient-brand) !important;
  color: #fff !important;
  font-family: var(--font-family);
  font-size: var(--font-size-md) !important;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  overflow: hidden;
  transition:
    box-shadow  var(--transition-normal),
    opacity     var(--transition-fast),
    transform   var(--transition-fast);
  margin-top: var(--space-sm);
}

.btn-login:not(:disabled):hover {
  box-shadow: var(--btn-hover-shadow) !important;
  transform: translateY(-1px);
}

.btn-login:not(:disabled):active {
  transform: translateY(0);
}

.btn-login:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 3px;
}

.btn-login:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Conteúdo do botão */
.btn-login-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  transition: opacity var(--transition-fast);
}

.btn-login-content svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Estado de loading */
.btn-login.is-loading .btn-login-content {
  opacity: 0;
}

.btn-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.btn-login.is-loading .btn-spinner {
  opacity: 1;
}

.spinner-ring {
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Estado de sucesso no botão */
.btn-login.is-success {
  background: linear-gradient(135deg, #22c55e, #16a34a) !important;
}

/* -------------------------------------------------------------
   ALERTAS GLOBAIS
------------------------------------------------------------- */
.alert-login {
  display: none;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  animation: fadeIn 0.2s ease;
  margin-bottom: var(--space-md);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.alert-login.is-visible {
  display: flex;
}

.alert-login.alert-error {
  background: rgba(255,77,109,.10);
  border: 1px solid rgba(255,77,109,.25);
  color: var(--color-text-error);
}

.alert-login.alert-success {
  background: rgba(34,197,94,.10);
  border: 1px solid rgba(34,197,94,.25);
  color: var(--color-text-success);
}

.alert-login svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-top: 1px;
}

/* -------------------------------------------------------------
   DIVISOR E RODAPÉ
------------------------------------------------------------- */
.login-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-xl) 0 var(--space-md);
}

.login-footer {
  text-align: center;
  font-size: var(--font-size-xs);
  color: var(--color-text-placeholder);
  line-height: 1.6;
}

.login-footer a {
  color: var(--color-text-link);
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* -------------------------------------------------------------
   RESPONSIVIDADE
------------------------------------------------------------- */
@media (max-width: 440px) {
  .login-card {
    padding: var(--space-lg) var(--space-md) var(--space-xl) !important;
    border-radius: var(--radius-md) !important;
  }

  .logo-name {
    font-size: var(--font-size-xl);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* -------------------------------------------------------------
   BOTAO INSTALAR APP (PWA)
------------------------------------------------------------- */
.btn-install-app {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid rgba(91, 156, 246, .3);
  border-radius: var(--radius-md, 8px);
  color: #5B9CF6;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}

.btn-install-app:hover {
  background: rgba(91, 156, 246, .1);
  border-color: rgba(91, 156, 246, .5);
}

.btn-install-app svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Modal instrucao iOS --- */
.ios-install-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.ios-install-modal {
  background: var(--color-surface, #1a2035);
  border: 1px solid var(--color-border, #2a3550);
  border-radius: 12px;
  padding: 24px;
  max-width: 320px;
  color: var(--color-text-primary, #e2e8f0);
  font-size: 14px;
  line-height: 1.6;
}

.ios-install-modal ol {
  padding-left: 20px;
  margin: 12px 0;
}

.ios-install-modal li {
  margin-bottom: 8px;
}

.btn-ios-close {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 10px;
  background: rgba(91, 156, 246, .15);
  border: 1px solid rgba(91, 156, 246, .3);
  border-radius: 8px;
  color: #5B9CF6;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* --- Light Theme Overrides --- */
[data-theme="light"] .field-input:focus {
  background: #f0f2f5 !important;
}

[data-theme="light"] .btn-install-app {
  color: #1a4590;
  border-color: rgba(26, 69, 144, .3);
}

[data-theme="light"] .btn-install-app:hover {
  background: rgba(26, 69, 144, .1);
  border-color: rgba(26, 69, 144, .5);
}

[data-theme="light"] .btn-ios-close {
  color: #1a4590;
  background: rgba(26, 69, 144, .15);
  border-color: rgba(26, 69, 144, .3);
}
