/**
 * style.css
 * Estilos principais da tela de autenticação/cadastro TOTVS Linha RM
 * Foco em fidelidade visual, alta usabilidade e responsividade total.
 */

:root {
  /* Cores especificadas e paleta TOTVS Linha RM */
  --color-welcome: #29b6c5;           /* "Boas-vindas" */
  --color-btn-access: #0C9ABE;        /* Botão "Acessar" */
  --color-btn-hover: #0a84a3;         /* Hover do botão */
  --color-input-bg: #FBFBFB;          /* Fundo dos inputs */
  --color-footer-text: #0E547E;       /* Texto e links do rodapé */
  
  --color-title-rm: #636b73;          /* "Linha RM" cinza suave */
  --color-text-body: #333333;         /* Texto geral escuro */
  --color-placeholder: #7c858e;       /* Placeholder dos inputs */
  --color-border-input: #ccd1d6;      /* Borda padrão dos inputs */
  --color-border-hover: #9ca6af;      /* Borda ao passar o mouse */
  --color-focus-ring: #0C9ABE;        /* Anel de foco acessível */
  --color-divider: #e5e8eb;           /* Linha divisória */
  --color-error: #d9383a;             /* Mensagens de erro */
  --color-warning-bg: #fff8e6;        /* Fundo do alerta CapsLock */
  --color-warning-border: #f6c343;    /* Borda do alerta CapsLock */
  --color-warning-text: #7d5a00;      /* Texto CapsLock */

  --bg-page: #ffffff;
  --font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Open Sans', 'Roboto', 'Helvetica Neue', sans-serif;
  
  --radius-input: 3px;
  --radius-btn: 3px;
  --transition-speed: 0.2s;
}

/* Reset básico e tipografia */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  font-family: var(--font-family);
  background-color: var(--bg-page);
  color: var(--color-text-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
}

/* Acessibilidade: classes utilitárias */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========================================================
   1. BARRA SUPERIOR DE USABILIDADE & CONTROLE DE RESPONSIVIDADE
   ======================================================== */
.top-usability-bar {
  background: #f1f4f8;
  border-bottom: 1px solid #dce2e8;
  padding: 6px 16px;
  font-size: 13px;
  color: #4b5563;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.top-bar-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.machine-quick-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
  animation: pulseLive 2s infinite;
}

@keyframes pulseLive {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.machine-label {
  color: #6b7280;
}

.divider-dot {
  color: #9ca3af;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Alternador de visualização para teste de responsividade */
.viewport-toggle {
  display: flex;
  background: #e2e8f0;
  padding: 2px;
  border-radius: 4px;
}

.view-btn {
  background: transparent;
  border: none;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  border-radius: 3px;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.view-btn:hover {
  color: #0f172a;
}

.view-btn.active {
  background: #ffffff;
  color: var(--color-btn-access);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Botão Gatilho do Drawer */
.metrics-trigger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  color: var(--color-footer-text);
  border: 1px solid #cbd5e1;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.metrics-trigger-btn:hover {
  background: #f8fafc;
  border-color: var(--color-btn-access);
  color: var(--color-btn-access);
}

.metrics-trigger-btn .badge {
  background: var(--color-btn-access);
  color: #ffffff;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
}

/* ========================================================
   2. ESTRUTURA PRINCIPAL & CARD DE AUTENTICAÇÃO
   ======================================================== */
.page-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px 16px;
  min-height: calc(100vh - 45px);
  background: #ffffff;
  transition: all 0.3s ease;
}

/* Modos simulados de teste de tela */
.page-container.view-sim-desktop .auth-card {
  width: 440px;
  border: none;
  box-shadow: none;
}

.page-container.view-sim-mobile {
  background: #2a2a2a;
  padding: 40px 16px;
}

.page-container.view-sim-mobile .auth-card {
  width: 390px;
  max-width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  background: #ffffff;
}

/* Card centralizado */
.auth-card {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  padding: 24px 20px;
  border-radius: 6px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Estilo Desktop Padrão (conforme imagem 1: limpo, aberto) */
@media (min-width: 768px) {
  .page-container:not(.view-sim-mobile) .auth-card {
    max-width: 430px;
    padding: 30px 24px;
    border: none;
    box-shadow: none;
  }
}

/* Estilo Mobile (conforme imagem 2: cartão delimitado, bordas suaves) */
@media (max-width: 767px) {
  .auth-card {
    border: 1px solid #d8dde2;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  }
}

/* ========================================================
   3. CABEÇALHO DO CARD (LOGOS E TÍTULOS)
   ======================================================== */
.card-header {
  text-align: center;
  margin-bottom: 24px;
}

.totvs-header-logo {
  height: 48px;
  width: auto;
  max-width: 170px;
  object-fit: contain;
  margin-bottom: 16px;
  display: inline-block;
}

.system-title {
  font-size: 32px;
  font-weight: 300;
  color: var(--color-title-rm);
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.welcome-subtitle {
  font-size: 22px;
  font-weight: 400;
  color: var(--color-welcome); /* #29b6c5 */
  letter-spacing: 0.2px;
}

/* ========================================================
   4. FORMULÁRIO E CAMPOS DE ENTRADA
   ======================================================== */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.input-group {
  display: flex;
  flex-direction: column;
  position: relative;
}

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

/* Ícone embutido no lado esquerdo do input */
.input-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  pointer-events: none;
  z-index: 2;
}

.input-icon .icon-img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

/* Estilo base dos controles de formulário */
.form-control {
  width: 100%;
  height: 42px;
  padding: 0 12px 0 38px;
  background-color: var(--color-input-bg); /* #FBFBFB */
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-input);
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--color-text-body);
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed), background-color var(--transition-speed);
  appearance: none;
  -webkit-appearance: none;
}

.form-control::placeholder {
  color: var(--color-placeholder);
  opacity: 0.9;
  font-size: 13.5px;
}

.form-control:hover {
  border-color: var(--color-border-hover);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-focus-ring);
  box-shadow: 0 0 0 2px rgba(12, 154, 190, 0.2);
  background-color: #ffffff;
}

.form-control.is-invalid {
  border-color: var(--color-error);
  box-shadow: 0 0 0 2px rgba(217, 56, 58, 0.15);
}

/* Botão de mostrar/ocultar senha */
.password-toggle-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #718096;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: color var(--transition-speed);
}

.password-toggle-btn:hover {
  color: var(--color-btn-access);
}

.password-toggle-btn:focus-visible {
  outline: 2px solid var(--color-focus-ring);
}

/* Select de Ambiente / Base */
.select-wrapper {
  position: relative;
}

.select-control {
  cursor: pointer;
  padding-right: 32px;
}

.select-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #64748b;
  pointer-events: none;
}

/* Mensagens de feedback de validação */
.field-feedback {
  font-size: 12px;
  color: var(--color-error);
  margin-top: 4px;
  padding-left: 2px;
  min-height: 18px;
  display: none;
}

.field-feedback.active {
  display: block;
}

/* Alerta de Caps Lock */
.caps-warning {
  margin-top: 4px;
  padding: 4px 8px;
  background-color: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  border-radius: 3px;
  color: var(--color-warning-text);
  font-size: 11.5px;
}

/* ========================================================
   5. BOTÃO DE ACESSO & LINK ESQUECEU SENHA
   ======================================================== */
.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  background-color: var(--color-btn-access); /* #0C9ABE */
  color: #ffffff;
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  margin-top: 4px;
  box-shadow: 0 2px 4px rgba(12, 154, 190, 0.28);
  transition: background-color var(--transition-speed), transform 0.1s ease, box-shadow var(--transition-speed);
}

.btn-submit:hover {
  background-color: var(--color-btn-hover);
  box-shadow: 0 3px 6px rgba(12, 154, 190, 0.38);
}

.btn-submit:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(12, 154, 190, 0.2);
}

.btn-submit:focus-visible {
  outline: 2px solid #005a74;
  outline-offset: 2px;
}

.btn-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Spinner de carregamento no botão */
.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn-submit.loading .btn-spinner {
  display: inline-block;
}

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

/* Link Esqueceu sua senha */
.forgot-password-box {
  text-align: center;
  margin-top: 4px;
}

.link-forgot {
  color: var(--color-btn-access);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: underline;
  transition: color var(--transition-speed);
}

.link-forgot:hover {
  color: var(--color-footer-text);
}

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

/* ========================================================
   6. RODAPÉ DO CARD & LINKS SECUNDÁRIOS
   ======================================================== */
.card-divider {
  border: none;
  border-top: 1px solid var(--color-divider);
  margin: 28px 0 20px 0;
  width: 100%;
}

.card-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.footer-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  text-align: center;
}

.footer-link {
  color: var(--color-footer-text); /* #0E547E */
  font-size: 12px;
  text-decoration: underline;
  transition: color var(--transition-speed), opacity var(--transition-speed);
  line-height: 1.4;
}

.footer-link:hover {
  color: var(--color-btn-access);
  opacity: 0.9;
}

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

/* Logo TOTVS no rodapé */
.footer-brand {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.totvs-footer-logo {
  height: 24px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  display: block;
}

/* ========================================================
   7. TOAST NOTIFICATION (FEEDBACK VISUAL DE USABILIDADE)
   ======================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #ffffff;
  border-left: 4px solid var(--color-btn-access);
  border-radius: 4px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  max-width: 360px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast.success {
  border-left-color: #10b981;
}

.toast.error {
  border-left-color: var(--color-error);
}

.toast-icon {
  font-size: 20px;
  line-height: 1;
}

.toast-body {
  flex: 1;
}

.toast-title {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 12px;
  color: #475569;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  font-size: 14px;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.toast-close:hover {
  color: #334155;
}

/* Responsividade adicional para telas muito pequenas */
@media (max-width: 360px) {
  .system-title {
    font-size: 26px;
  }
  .welcome-subtitle {
    font-size: 19px;
  }
  .auth-card {
    padding: 16px 12px;
  }
  .footer-nav {
    gap: 8px 12px;
  }
}
