/* =========================
   LOGIN INDICAH - CSS CONSOLIDADO
   Versão: Production Ready
   Inclui: Layout + Toast + Responsividade
   ========================= */

:root {
  /* Cores principais */
  --brand-red: #b32328;
  --brand-red-dark: #8e1c20;
  --brand-red-light: #c83238;

  /* Cores de texto */
  --text-primary: #2b2b2b;
  --text-secondary: #666666;
  --text-muted: #8d8d8d;

  /* Cores de interface */
  --line-color: #d9d9d9;
  --line-focus: var(--brand-red);
  --card-bg: rgba(255, 255, 255, 0.96);
  --input-bg: rgba(255, 255, 255, 0.5);

  /* Sombras */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 20px 48px rgba(0, 0, 0, 0.15);
  --shadow-button: 0 8px 24px rgba(179, 35, 40, 0.3);
  --shadow-button-hover: 0 12px 32px rgba(179, 35, 40, 0.4);

  /* Border radius */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-full: 999px;

  /* Transições */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.35s ease;

  /* Espaçamentos */
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
}

/* =========================
   RESET & BASE
   ========================= */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html,
body {
  height: 100%;
  width: 100%;
}

body.login-page {
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-primary);
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  overflow-x: hidden;
  position: relative;
}

/* =========================
   WAVE DECORATIVA
   ========================= */

.wave-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.wave {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: auto;
  min-width: 100%;
  object-fit: cover;
  opacity: 1;
}

/* =========================
   LAYOUT PRINCIPAL
   ========================= */

.login-container {
  min-height: 100vh;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 64px) clamp(16px, 3vw, 48px);
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: clamp(32px, 5vw, 80px);
  align-items: center;
  position: relative;
  z-index: 1;
}

/* =========================
   ILUSTRAÇÃO (Coluna Esquerda)
   ========================= */

.login-illustration {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--spacing-lg);
}

.illustration-wrapper {
  width: 100%;
  max-width: 600px;
}

.illustration-wrapper img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(var(--shadow-md));
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* =========================
   CARD DE LOGIN (Coluna Direita)
   ========================= */

.login-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--spacing-md);
}

.login-card {
  width: 100%;
  max-width: 480px;
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: clamp(32px, 5vw, 48px);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* =========================
   LOGO PRINCIPAL
   ========================= */

.login-brand {
  text-align: center;
  margin-bottom: var(--spacing-xl);
}

.logo {
    display: block;
    max-width: 80%;
    margin: 0 auto 20px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =========================
   FORMULÁRIO
   ========================= */

.login-form {
  margin-top: var(--spacing-lg);
  width: 100%;
}

.form-group {
  margin-bottom: var(--spacing-lg);
  width: 100%;
}

.form-group:last-of-type {
  margin-bottom: var(--spacing-xl);
}

/* Wrapper do input - compatível com classes antigas e novas */
.input-wrapper,
.input-div {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) 0;
  border-bottom: 2px solid var(--line-color);
  transition: border-color var(--transition-slow);
  width: 100%;
  max-width: 100%;
}

.input-wrapper:focus-within,
.input-div.focus {
  border-bottom-color: var(--line-focus);
}

/* Ícone - compatível com classes antigas e novas */
.input-icon,
.i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--transition-base);
}

.input-wrapper:focus-within .input-icon,
.input-wrapper:focus-within .i,
.input-div.focus .input-icon,
.input-div.focus .i {
  color: var(--brand-red);
}

.input-icon i,
.i i {
  font-size: 18px;
}

/* Campo de input - compatível com classes antigas e novas */
.input-field,
.div {
  flex: 1;
  position: relative;
  min-height: 48px;
}

.form-input,
.input {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 12px 8px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text-primary);
  transition: all var(--transition-base);
}

.form-input::placeholder,
.input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
  transition: opacity var(--transition-base);
}

.form-input:focus::placeholder,
.input:focus::placeholder {
  opacity: 0.5;
}

/* Linha animada de foco */
.input-wrapper::before,
.input-div::before {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--brand-red);
  transform: scaleX(0);
  transition: transform var(--transition-slow);
}

.input-wrapper:focus-within::before,
.input-div.focus::before {
  transform: scaleX(1);
}

/* Estado preenchido */
.input-wrapper.filled .input-icon,
.input-wrapper.filled .i,
.input-div.filled .input-icon,
.input-div.filled .i {
  color: var(--brand-red);
}

/* =========================
   BOTÃO DE LOGIN
   ========================= */

.btn-login {
  width: 100%;
  min-height: 54px;
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand-red) 0%, var(--brand-red-dark) 100%);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: var(--shadow-button);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.btn-login::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn-login:hover {
  background: linear-gradient(135deg, var(--brand-red-light) 0%, var(--brand-red) 100%);
  box-shadow: var(--shadow-button-hover);
  transform: translateY(-2px);
}

.btn-login:hover::before {
  left: 100%;
}

.btn-login:active {
  transform: translateY(0);
  box-shadow: var(--shadow-button);
}

.btn-login:focus {
  outline: 3px solid rgba(179, 35, 40, 0.3);
  outline-offset: 2px;
}

.btn-login i {
  font-size: 18px;
}

/* Estado de loading */
.btn-login:disabled {
  background: linear-gradient(135deg, #ccc 0%, #999 100%);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-login.loading {
  pointer-events: none;
  opacity: 0.9;
  cursor: wait;
}

.btn-login.loading span {
  opacity: 0;
}

.btn-login.loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* =========================
   LOGOS INSTITUCIONAIS
   ========================= */

/* Desktop - footer fixo */
.login-footer {
  position: fixed;
  bottom: 24px; /* Mesmo bottom do logo HEMOCE */
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.5);
  transition: all var(--transition-base);
  
  /* Alinhamento vertical centralizado */
  display: flex;
  align-items: center;
}

.login-footer:hover {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-lg);
}

.footer-logos {
  display: flex;
  align-items: center;
}

.footer-logos img {
  height: 56px; /* Mesma altura do logo HEMOCE */
  width: auto;
  display: block;
}

/* Tablet/Mobile - dentro do card */
.login-footer-inline {
  display: none;
  margin-top: var(--spacing-xl);
  padding-top: var(--spacing-lg);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  justify-content: center;
  align-items: center;
}

.login-footer-inline img {
  height: 48px;
  width: auto;
  opacity: 0.9;
}

/* =========================
   LOGO HEMOCE FIXO
   ========================= */

.logo-hemoce-fixed {
  position: fixed;
  bottom: 24px; /* Mesmo bottom do rodapé */
  left: 28px;
  z-index: 5;
  
  /* Mesmo estilo do rodapé */
  padding: 12px 24px;
  border-radius: var(--radius-full);

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.5);
  transition: all var(--transition-base);
  
  display: flex;
  align-items: center;
}

.logo-hemoce-fixed img {
  height: 56px; /* Mesma altura dos outros logos */
  width: auto;
  display: block;
}

/* =========================
   TOAST DE ERRO
   ========================= */

#incorrectToast {
  min-width: 350px;
  max-width: 450px;
  box-shadow: 0 8px 32px rgba(220, 38, 38, 0.3);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 12px;
  overflow: hidden;
}

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

#incorrectToast .toast-header {
  padding: 12px 16px;
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
  border-bottom: none;
}

#incorrectToast .toast-header strong {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#incorrectToast .toast-header i {
  font-size: 16px;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.1);
  }
}

#incorrectToast .btn-close {
  opacity: 0.9;
}

#incorrectToast .btn-close:hover {
  opacity: 1;
}

#incorrectToast .toast-body {
  padding: 0;
  background: #ffffff;
}

#incorrectToast .card-body {
  padding: 16px;
  background: linear-gradient(to bottom, #ffffff 0%, #fef2f2 100%);
}

#incorrectToast .card-header {
  background: transparent;
  border: none;
  padding: 0 0 8px 0;
  font-size: 15px;
  font-weight: 600;
  color: #dc2626;
  display: flex;
  align-items: center;
  gap: 8px;
}

#incorrectToast .card-text {
  font-size: 13px;
  line-height: 1.6;
  color: #7f1d1d;
  margin: 0;
}

#incorrectToast .card-text span {
  font-weight: 600;
  color: #dc2626;
}

#incorrectToast.hiding {
  opacity: 0;
  transition: opacity 0.4s ease-out;
}

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

#incorrectToast:hover {
  box-shadow: 0 12px 40px rgba(220, 38, 38, 0.35);
}

#incorrectToast .btn-close:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.3);
}

/* =========================
   RESPONSIVIDADE
   ========================= */

/* Large Desktop (1400px+) */
@media (min-width: 1400px) {
  .login-container {
    gap: 100px;
  }
  .illustration-wrapper {
    max-width: 700px;
  }
  .login-card {
    max-width: 520px;
    padding: 56px;
  }
  .logo {
    max-width: 400px;
  }
}

/* Desktop médio (1200px - 1399px) */
@media (min-width: 1200px) and (max-width: 1399px) {
  .login-container {
    max-width: 1200px;
  }
  .logo {
    max-width: 380px;
  }
}

/* Tablet landscape (992px - 1199px) */
@media (max-width: 1199px) {
  .login-container {
    grid-template-columns: 1fr 1fr;
    gap: 48px;
  }
  .illustration-wrapper {
    max-width: 500px;
  }
  .login-card {
    max-width: 460px;
  }
}

/* Tablet portrait (768px - 991px) */
@media (max-width: 991px) {
  .login-container {
    grid-template-columns: 1fr;
    max-width: 600px;
    padding: 32px 24px;
  }
  .login-illustration {
    display: none;
  }
  .logo-hemoce-fixed {
    display: none;
  }
  .login-footer {
    display: none;
  }
  .login-footer-inline {
    display: flex;
  }
  .login-card {
    max-width: 100%;
  }
  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(30px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* Mobile grande (576px - 767px) */
@media (max-width: 767px) {
  .login-container {
    padding: 24px 16px;
  }
  .login-card {
    padding: 32px 24px;
    border-radius: var(--radius-lg);
  }
  .logo {
    max-width: 280px;
  }
  .form-input,
  .input {
    font-size: 16px;
  }
  .btn-login {
    min-height: 52px;
    font-size: 15px;
  }
  .login-footer-inline img {
    height: 44px;
  }
}

/* Mobile pequeno (até 575px) */
@media (max-width: 575px) {
  .wave-container {
    display: none;
  }
  body.login-page {
    background: linear-gradient(135deg, #fafafa 0%, #f0f0f0 100%);
  }
  .login-container {
    padding: 16px;
    min-height: 100vh;
    display: flex;
    align-items: center;
  }
  .login-panel {
    width: 100%;
  }
  .login-card {
    padding: 28px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
  }
  .logo {
    max-width: 240px;
  }
  .login-brand {
    margin-bottom: var(--spacing-lg);
  }
  .form-group {
    margin-bottom: var(--spacing-md);
  }
  .form-group:last-of-type {
    margin-bottom: var(--spacing-lg);
  }
  .input-icon,
  .i {
    width: 36px;
  }
  .input-icon i,
  .i i {
    font-size: 16px;
  }
  .form-input,
  .input {
    font-size: 16px;
    padding: 10px 6px;
  }
  .btn-login {
    min-height: 50px;
    font-size: 14px;
    padding: 12px 24px;
  }
  .btn-login i {
    font-size: 16px;
  }
  .login-footer-inline {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
  }
  .login-footer-inline img {
    height: 40px;
  }
  /* Toast responsivo */
  #incorrectToast {
    min-width: 300px;
    max-width: calc(100vw - 32px);
    margin: 0 8px;
  }
  #incorrectToast .toast-header strong {
    font-size: 13px;
  }
  #incorrectToast .card-header {
    font-size: 14px;
  }
  #incorrectToast .card-text {
    font-size: 12px;
  }
  .position-fixed.top-0.end-0 {
    padding: 12px !important;
  }
}

/* Extra small (até 374px) */
@media (max-width: 374px) {
  .login-card {
    padding: 24px 16px;
  }
  .logo {
    max-width: 200px;
  }
  .btn-login {
    font-size: 13px;
    letter-spacing: 0.3px;
  }
  .login-footer-inline img {
    height: 36px;
  }
}

/* Landscape mobile */
@media (max-height: 600px) and (orientation: landscape) {
  .login-container {
    padding: 16px;
    min-height: auto;
  }
  .login-card {
    padding: 20px;
  }
  .logo {
    max-width: 200px;
  }
  .login-brand {
    margin-bottom: var(--spacing-md);
  }
  .form-group {
    margin-bottom: var(--spacing-sm);
  }
  .form-group:last-of-type {
    margin-bottom: var(--spacing-md);
  }
  .btn-login {
    min-height: 44px;
  }
  .login-footer-inline {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-sm);
  }
  .login-footer-inline img {
    height: 32px;
  }
}

/* =========================
   ACESSIBILIDADE
   ========================= */

*:focus {
  outline: 2px solid var(--brand-red);
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 2px solid var(--brand-red);
  outline-offset: 2px;
}

/* Modo de alto contraste */
@media (prefers-contrast: high) {
  :root {
    --text-primary: #000000;
    --text-muted: #555555;
    --line-color: #999999;
  }
  .login-card {
    border: 2px solid var(--line-color);
  }
  .btn-login {
    border: 2px solid var(--brand-red-dark);
  }
}

/* Redução de movimento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .wave {
    animation: none;
  }
  .illustration-wrapper img {
    animation: none;
  }
}

/* Print */
@media print {
  .wave-container,
  .login-illustration,
  .logo-hemoce-fixed,
  .login-footer,
  .login-footer-inline {
    display: none !important;
  }
  .login-card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* =========================
   ALINHAMENTO INPUTS E BOTÃO
   Garante mesma largura
   ========================= */

.login-form .form-group,
.login-form .btn-login {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.login-form .input-wrapper,
.login-form .input-div {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

/* Garante que o padding do card não afete o alinhamento */
.login-card {
  padding-left: clamp(32px, 5vw, 48px);
  padding-right: clamp(32px, 5vw, 48px);
}

@media (max-width: 767px) {
  .login-card {
    padding-left: 24px;
    padding-right: 24px;
  }
}

@media (max-width: 575px) {
  .login-card {
    padding-left: 20px;
    padding-right: 20px;
  }
}

@media (max-width: 374px) {
  .login-card {
    padding-left: 16px;
    padding-right: 16px;
  }
}