/* ============================================================
   LOGIN — Malga-Style Premium Dark Theme
   Bureau de Dados e Inteligência
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-page: #0a0c10;
  --bg-card: rgba(16, 20, 30, 0.55);
  --bg-input: rgba(20, 26, 40, 0.45);
  --border-card: rgba(255, 255, 255, 0.06);
  --border-input: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(45, 212, 191, 0.45);
  --fg: #f0f4f8;
  --fg-secondary: #cbd5e1;
  --fg-muted: #94a3b8;
  --fg-dim: #64748b;
  --accent: #2dd4bf;
  --accent-dark: #042f2e;
  --accent-hover: #14b8a6;
  --success: #10b981;
  --danger: #ef4444;
  --radius: 12px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
}

html {
  color-scheme: dark;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--fg);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Background abstract scene ────────────────────────────── */

/* Soft ambient glow */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(700px ellipse at 72% 15%, rgba(45, 212, 191, 0.045) 0%, transparent 55%),
    radial-gradient(500px ellipse at 30% 85%, rgba(99, 102, 241, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* 3D geometric cube shape — top right */
.scene-cube {
  position: fixed;
  top: -60px;
  right: -40px;
  width: 340px;
  height: 340px;
  z-index: 0;
  pointer-events: none;
  transform: perspective(600px) rotateX(12deg) rotateY(-25deg) rotateZ(15deg);
  animation: cubeIdle 24s ease-in-out infinite alternate;
}

.scene-cube .cube-face {
  position: absolute;
  border: 1px solid rgba(45, 212, 191, 0.06);
  border-radius: 18px;
  background: rgba(45, 212, 191, 0.015);
}

.scene-cube .cube-face:nth-child(1) {
  inset: 0;
}

.scene-cube .cube-face:nth-child(2) {
  inset: 30px;
  border-color: rgba(45, 212, 191, 0.045);
  background: rgba(45, 212, 191, 0.01);
}

.scene-cube .cube-face:nth-child(3) {
  inset: 65px;
  border-color: rgba(45, 212, 191, 0.03);
}

/* Second cube — bottom left (subtle) */
.scene-cube-secondary {
  position: fixed;
  bottom: -120px;
  left: -100px;
  width: 280px;
  height: 280px;
  z-index: 0;
  pointer-events: none;
  transform: perspective(600px) rotateX(-8deg) rotateY(20deg) rotateZ(-10deg);
  opacity: 0.4;
}

.scene-cube-secondary .cube-face {
  position: absolute;
  border: 1px solid rgba(99, 102, 241, 0.05);
  border-radius: 16px;
}

.scene-cube-secondary .cube-face:nth-child(1) {
  inset: 0;
}

.scene-cube-secondary .cube-face:nth-child(2) {
  inset: 25px;
}

@keyframes cubeIdle {
  0%   { transform: perspective(600px) rotateX(12deg) rotateY(-25deg) rotateZ(15deg); }
  100% { transform: perspective(600px) rotateX(14deg) rotateY(-22deg) rotateZ(13deg) translate(-8px, 10px); }
}

/* ── Logo area (top of card) ──────────────────────────────── */
.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.login-logo img,
.login-logo svg {
  width: 36px;
  height: 36px;
}

/* ── Main container ───────────────────────────────────────── */
.login-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeUp 0.5s ease both;
}

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

/* ── Card ─────────────────────────────────────────────────── */
.login-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.02),
    0 20px 50px -12px rgba(0,0,0,0.55);
  padding: 40px 36px 36px;
}

/* ── Card header ──────────────────────────────────────────── */
.card-header {
  text-align: center;
  margin-bottom: 28px;
}

.card-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.card-header p {
  font-size: 0.875rem;
  color: var(--fg-dim);
  font-weight: 400;
}

.card-header p a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 400;
}

.card-header p a:hover {
  text-decoration: underline;
}

/* ── Form fields ──────────────────────────────────────────── */
.field {
  margin-bottom: 18px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.field-label label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg-secondary);
}

.field-label .field-action {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--fg-dim);
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: color var(--transition);
}

.field-label .field-action:hover {
  color: var(--fg-muted);
}

/* ── Input ────────────────────────────────────────────────── */
.input-box {
  display: flex;
  align-items: center;
  height: 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  position: relative;
}

.input-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.08);
}

.input-box input {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 0.875rem;
  font-family: inherit;
  padding: 0 14px;
  outline: none;
  min-width: 0;
}

.input-box input::placeholder {
  color: var(--fg-dim);
}

.input-box input:-webkit-autofill,
.input-box input:-webkit-autofill:hover,
.input-box input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #131a28 inset;
  -webkit-text-fill-color: var(--fg);
  caret-color: var(--fg);
  transition: background-color 5000s ease-in-out 0s;
}

/* ── Password toggle ─────────────────────────────────────── */
.btn-eye {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--fg-dim);
  margin-right: 4px;
  padding: 0;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.btn-eye:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg-muted);
}

.btn-eye svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Submit button ────────────────────────────────────────── */
.btn-submit {
  width: 100%;
  height: 42px;
  background: var(--accent);
  color: var(--accent-dark);
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform 0.1s ease;
  position: relative;
  overflow: hidden;
  margin-top: 6px;
  letter-spacing: 0.01em;
}

.btn-submit:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 14px rgba(45, 212, 191, 0.2);
}

.btn-submit:active:not(:disabled) {
  transform: scale(0.985);
}

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

/* Loading spinner */
.btn-submit .spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(4, 47, 46, 0.2);
  border-top-color: var(--accent-dark);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  margin: 0 auto;
}

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

.btn-submit.is-loading .btn-label {
  display: none;
}

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

/* ── Alert ────────────────────────────────────────────────── */
.alert-zone {
  margin-bottom: 4px;
}

.alert-msg {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.825rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  animation: alertIn 0.3s ease;
}

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

.alert-msg.error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.alert-msg.success {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.alert-msg.info {
  background: rgba(45, 212, 191, 0.08);
  border: 1px solid rgba(45, 212, 191, 0.15);
  color: var(--accent);
}

/* ── Tagline (below card) ─────────────────────────────────── */
.tagline-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  height: 28px;
  font-size: 0.8rem;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.tagline-bar .tag-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tagline-bar .tag-icon svg {
  width: 16px;
  height: 16px;
  stroke: var(--fg-dim);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Logo icons group (like Malga's S|N|B) */
.tagline-bar .tag-logos {
  display: flex;
  align-items: center;
  gap: 3px;
}

.tagline-bar .tag-logos .tag-dot {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: white;
}

.tagline-bar .tag-logos .tag-dot:nth-child(1) {
  background: var(--accent);
}

.tagline-bar .tag-logos .tag-dot:nth-child(2) {
  background: #6366f1;
}

.tagline-bar .tag-logos .tag-dot:nth-child(3) {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--fg-muted);
}

.tagline-bar .tag-text {
  color: var(--fg-dim);
  white-space: nowrap;
}

.tagline-bar .tag-highlight {
  color: var(--fg);
  font-weight: 500;
  white-space: nowrap;
}

/* ── Legal footer ─────────────────────────────────────────── */
.legal-bar {
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--fg-dim);
  z-index: 2;
}

.legal-bar a {
  color: var(--fg-dim);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition);
}

.legal-bar a:hover {
  color: var(--fg-muted);
}

.legal-bar .sep {
  opacity: 0.4;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 480px) {
  body {
    padding: 16px;
    align-items: flex-start;
    padding-top: max(10vh, 40px);
  }

  .login-card {
    padding: 32px 24px 28px;
    border-radius: var(--radius);
  }

  .card-header h1 {
    font-size: 1.3rem;
  }

  .scene-cube {
    width: 240px;
    height: 240px;
    top: -50px;
    right: -50px;
  }
}

@media (max-width: 360px) {
  body {
    padding: 12px;
    padding-top: max(6vh, 24px);
  }

  .login-card {
    padding: 24px 18px 24px;
  }
}

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

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

::selection {
  background: var(--accent);
  color: var(--accent-dark);
}

/* Touch */
button, a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
