/* ============================================
   AESAS CTE REPORTA - LOGIN PAGE
   Modern, Secure, Accessible Design
   ============================================ */

/* Reset e Variáveis */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #003366;
  --primary-dark: #002244;
  --primary-light: #0066cc;
  --secondary: #6c757d;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #17a2b8;
  --light: #f8f9fa;
  --dark: #212529;
  --white: #ffffff;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-600: #475569;
  --gray-800: #343a40;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.25);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius: 16px;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   BACKGROUND ANIMADO (RESTAURADO!)
   ============================================ */
.login-wrapper {
  position: fixed;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: linear-gradient(
    135deg,
    #003366 0%,
    #0066cc 25%,
    #0099ff 75%,
    #00ccff 100%
  );
}

/* Background overlay com gradientes radiais */
.login-background {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.bg-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 25%,
    var(--primary-light) 75%,
    #00ccff 100%
  );
  opacity: 1;
}

.bg-pattern {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(
      circle at 20% 50%,
      rgba(255, 255, 255, 0.1) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 80%,
      rgba(255, 255, 255, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 40% 20%,
      rgba(255, 255, 255, 0.05) 0%,
      transparent 50%
    );
}

/* Formas flutuantes animadas */
.floating-shapes {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.shape {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(2px);
}

.shape-1 {
  width: 300px;
  height: 300px;
  top: -150px;
  left: -150px;
  animation: float 20s ease-in-out infinite;
}

.shape-2 {
  width: 200px;
  height: 200px;
  top: 40%;
  right: -100px;
  animation: float 15s ease-in-out infinite 2s;
}

.shape-3 {
  width: 250px;
  height: 250px;
  bottom: -125px;
  left: 30%;
  animation: float 18s ease-in-out infinite 1s;
}

.shape-4 {
  width: 150px;
  height: 150px;
  top: 20%;
  right: 20%;
  animation: float 12s ease-in-out infinite 3s;
}

@keyframes float {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  33% {
    transform: translate(30px, -30px) rotate(120deg);
  }
  66% {
    transform: translate(-20px, 20px) rotate(240deg);
  }
}

/* ============================================
   CONTAINER
   ============================================ */
.login-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

/* ============================================
   LOGIN BOX
   ============================================ */
.login-box {
  width: 100%;
  max-width: 480px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

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

/* ============================================
   HEADER
   ============================================ */
.login-header {
  padding: 3rem 2rem 2rem;
  text-align: center;
  background: linear-gradient(
    180deg,
    rgba(0, 51, 102, 0.02) 0%,
    transparent 100%
  );
}

.logo-container {
  margin-bottom: 2rem;
}

.logo-wrapper {
  position: relative;
  display: inline-block;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  padding: 4px;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 51, 102, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 20px rgba(0, 51, 102, 0);
  }
}

.logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  background: white;
  padding: 15px;
}

.logo-glow {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(0, 102, 204, 0.3) 0%,
    transparent 70%
  );
  filter: blur(10px);
  z-index: -1;
}

.system-title {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

.system-subtitle {
  color: var(--gray-600);
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
}

/* ============================================
   FORM
   ============================================ */
.login-form-container {
  padding: 0 2rem 2rem;
}

/* Floating Label Inputs */
.form-floating-modern {
  position: relative;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--gray-100);
  border: 2px solid var(--gray-300);
  border-radius: 12px;
  transition: var(--transition);
  overflow: hidden;
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(0, 51, 102, 0.1);
}

.input-wrapper.has-error {
  border-color: var(--danger);
}

.input-wrapper.has-error:focus-within {
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.1);
}

.input-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  flex-shrink: 0;
}

.input-wrapper:focus-within .input-icon {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
}

.form-control-modern {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 1.5rem 1rem 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--dark);
  height: 56px;
}

.form-control-modern::placeholder {
  opacity: 0;
}

.input-wrapper label {
  position: absolute;
  left: 60px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-600);
  font-size: 1rem;
  font-weight: 500;
  pointer-events: none;
  transition: var(--transition);
}

.form-control-modern:focus + label,
.form-control-modern:not(:placeholder-shown) + label {
  top: 14px;
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
}

.password-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 56px;
  background: transparent;
  border: none;
  color: var(--gray-600);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.password-toggle:hover {
  color: var(--primary);
  background: rgba(0, 51, 102, 0.05);
}

.input-border {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.input-wrapper:focus-within .input-border {
  transform: scaleX(1);
}

/* Error Messages */
.error-message {
  display: flex;
  align-items: center;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(220, 38, 38, 0.1);
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideDown 0.3s ease;
}

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

/* Form Options */
.form-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-check-modern {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-check-input {
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-300);
  border-radius: 6px;
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.form-check-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  user-select: none;
}

/* Login Button */
.btn-login {
  width: 100%;
  height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(0, 51, 102, 0.3);
}

.btn-login:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 51, 102, 0.4);
}

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

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

.btn-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: opacity 0.3s ease;
}

.btn-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

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

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

.btn-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0);
  pointer-events: none;
}

.btn-login.ripple-active .btn-ripple {
  animation: ripple 0.6s ease-out;
}

@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Links */
.link-forgot {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: var(--transition);
}

.link-forgot:hover {
  background: rgba(0, 51, 102, 0.05);
  color: var(--primary-dark);
}

/* ============================================
   FOOTER
   ============================================ */
.login-footer {
  padding: 1.5rem 2rem;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(0, 51, 102, 0.02) 100%
  );
  border-top: 1px solid var(--gray-200);
}

.security-badges {
  display: flex;
  justify-content: center;
  gap: 2rem;
}

.badge-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
}

.badge-item i {
  font-size: 1.1rem;
}

/* ============================================
   SYSTEM INFO
   ============================================ */
.system-info {
  text-align: center;
  margin-top: 2rem;
  padding: 0 1rem;
  animation: fadeIn 1s ease 0.5s both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.info-text,
.copyright {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
  margin: 0.5rem 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ============================================
   THEME TOGGLE
   ============================================ */
.auth-theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: var(--transition);
}

.auth-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.auth-theme-toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ============================================
   LOADING OVERLAY
   ============================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 51, 102, 0.95);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay.active {
  display: flex;
}

.loading-content {
  text-align: center;
  color: white;
}

.spinner-modern {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

.loading-text {
  font-size: 1.1rem;
  font-weight: 600;
}

/* ============================================
   ALERTS
   ============================================ */
.alert-modern {
  border-radius: 12px;
  border: none;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: start;
  gap: 1rem;
  margin-bottom: 1.5rem;
  animation: slideDown 0.4s ease;
}

.alert-danger {
  background: linear-gradient(
    135deg,
    rgba(220, 38, 38, 0.1),
    rgba(220, 38, 38, 0.05)
  );
  border-left: 4px solid var(--danger);
  color: var(--danger);
}

.alert-success {
  background: linear-gradient(
    135deg,
    rgba(40, 167, 69, 0.1),
    rgba(40, 167, 69, 0.05)
  );
  border-left: 4px solid var(--success);
  color: var(--success);
}

.alert-modern i {
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 576px) {
  .login-container {
    padding: 1rem;
  }

  .login-box {
    max-width: 100%;
  }

  .login-header {
    padding: 2rem 1.5rem 1.5rem;
  }

  .login-form-container {
    padding: 0 1.5rem 1.5rem;
  }

  .system-title {
    font-size: 1.5rem;
  }

  .logo-wrapper {
    width: 70px;
    height: 70px;
  }

  .security-badges {
    gap: 1rem;
  }

  .badge-item {
    font-size: 0.8rem;
  }
}

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

.btn-login:focus-visible,
.password-toggle:focus-visible,
.link-forgot:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .login-box {
    border: 2px solid var(--dark);
  }

  .input-wrapper {
    border-width: 3px;
  }

  .btn-login {
    border: 2px solid var(--dark);
  }
}

/* ============================================
   AUTH PAGES (password reset, etc.)
   ============================================ */
.auth-page-content {
  padding-top: 0.5rem;
}

.auth-page-title {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--primary);
  text-align: center;
  margin-bottom: 0.75rem;
}

.auth-page-subtitle {
  color: #475569;
  text-align: center;
  font-size: 0.925rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.auth-status-icon {
  text-align: center;
  font-size: 3rem;
  margin-bottom: 1rem;
}

.auth-status-icon--primary {
  color: var(--primary-light);
}

.auth-status-icon--success {
  color: var(--success);
}

.auth-status-icon--danger {
  color: var(--danger);
}

.auth-back-link {
  display: block;
  text-align: center;
  margin-top: 1.5rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.925rem;
}

.auth-back-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.auth-page-content .form-text {
  font-size: 0.8rem;
  color: var(--gray-600);
}

/* ============================================
   DARK MODE
   ============================================ */
[data-bs-theme="dark"] .login-wrapper {
  background: linear-gradient(
    135deg,
    #0f172a 0%,
    #1e293b 25%,
    #0c4a6e 75%,
    #164e63 100%
  );
}

[data-bs-theme="dark"] .bg-gradient {
  background: linear-gradient(
    135deg,
    #0f172a 0%,
    #1e3a5f 25%,
    #0c4a6e 75%,
    #155e75 100%
  );
}

[data-bs-theme="dark"] .login-box {
  background: rgba(30, 41, 59, 0.92);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

[data-bs-theme="dark"] .login-header {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03) 0%,
    transparent 100%
  );
}

[data-bs-theme="dark"] .system-title {
  background: linear-gradient(135deg, #93c5fd 0%, #60a5fa 50%, #38bdf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

[data-bs-theme="dark"] .system-subtitle {
  color: #cbd5e1;
}

[data-bs-theme="dark"] .login-footer {
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(255, 255, 255, 0.02) 100%
  );
  border-top-color: #334155;
}

[data-bs-theme="dark"] .badge-item {
  color: #cbd5e1;
}

[data-bs-theme="dark"] .input-wrapper {
  background: #1e293b;
  border-color: #334155;
}

[data-bs-theme="dark"] .input-wrapper:focus-within {
  background: #0f172a;
  border-color: #60a5fa;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.15);
}

[data-bs-theme="dark"] .form-control-modern {
  color: #f1f5f9;
}

[data-bs-theme="dark"] .input-wrapper label {
  color: #cbd5e1;
}

[data-bs-theme="dark"] .form-control-modern:focus + label,
[data-bs-theme="dark"] .form-control-modern:not(:placeholder-shown) + label {
  color: #60a5fa;
}

[data-bs-theme="dark"] .password-toggle {
  color: #94a3b8;
}

[data-bs-theme="dark"] .password-toggle:hover {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.1);
}

[data-bs-theme="dark"] .form-check-label {
  color: #cbd5e1;
}

[data-bs-theme="dark"] .link-forgot {
  color: #60a5fa;
}

[data-bs-theme="dark"] .link-forgot:hover {
  background: rgba(96, 165, 250, 0.1);
  color: #93c5fd;
}

[data-bs-theme="dark"] .auth-page-title {
  color: #dbeafe;
}

[data-bs-theme="dark"] .auth-page-subtitle {
  color: #cbd5e1;
}

[data-bs-theme="dark"] .auth-back-link {
  color: #60a5fa;
}

[data-bs-theme="dark"] .auth-back-link:hover {
  color: #93c5fd;
}

[data-bs-theme="dark"] .auth-page-content .form-text {
  color: #94a3b8;
}

[data-bs-theme="dark"] .info-text,
[data-bs-theme="dark"] .copyright {
  color: rgba(255, 255, 255, 0.88);
}

[data-bs-theme="dark"] .auth-theme-toggle {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fbbf24;
}

[data-bs-theme="dark"] .auth-theme-toggle:hover {
  background: rgba(15, 23, 42, 0.8);
}

[data-bs-theme="dark"] .auth-theme-toggle:focus-visible {
  outline-color: #fbbf24;
}

[data-bs-theme="dark"] .alert-danger {
  background: linear-gradient(
    135deg,
    rgba(220, 38, 38, 0.2),
    rgba(220, 38, 38, 0.08)
  );
  color: #fca5a5;
}

[data-bs-theme="dark"] .alert-success {
  background: linear-gradient(
    135deg,
    rgba(40, 167, 69, 0.2),
    rgba(40, 167, 69, 0.08)
  );
  color: #86efac;
}

[data-bs-theme="dark"] .loading-overlay {
  background: rgba(15, 23, 42, 0.95);
}
