/* ===================================
   KOEKKOEK SMART BARN - CLIENT AUTH
   Navy + Orange (Koekkoek brand)
   =================================== */

:root {
  --navy: #0f172a;
  --navy-light: #1e293b;
  --navy-lighter: #334155;
  --white: #ffffff;
  --white-muted: rgba(255, 255, 255, 0.7);
  --white-subtle: rgba(255, 255, 255, 0.4);
  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --accent-glow: rgba(245, 158, 11, 0.15);
  --accent-glow-strong: rgba(245, 158, 11, 0.3);
  --success: #10b981;
  --error: #ef4444;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  font-family: var(--font);
  background: var(--navy);
  color: var(--white);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Container */
.app-container {
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* ===================================
   SCREENS
   =================================== */

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
}

.screen.fade-out {
  opacity: 0;
}

/* ===================================
   CODE ENTRY SCREEN
   =================================== */

.code-screen {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-light) 100%);
}

/* Ambient glow decoration */
.ambient-glow {
  position: absolute;
  top: -120px;
  right: -80px;
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  animation: glowPulse 6s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

/* Login Content */
.login-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1.5rem 2rem;
  max-width: 400px;
  width: 100%;
  position: relative;
  z-index: 1;
}

.code-screen .login-content {
  flex: 1;
}

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

.logo-container {
  display: flex;
  justify-content: center;
  margin-bottom: 3rem;
}

.logo {
  width: 180px;
  height: auto;
  filter: brightness(1.1);
}

/* ===================================
   LOGIN HEADER
   =================================== */

.login-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.login-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.login-header p {
  font-size: 0.9375rem;
  color: var(--white-muted);
}

/* ===================================
   LOGIN FORM
   =================================== */

.login-form {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* Code Input Group */
.code-input-group {
  display: flex;
  align-items: center;
  background: var(--navy-light);
  border: 2px solid var(--navy-lighter);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.2s ease;
  margin-bottom: 0.75rem;
}

.code-input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.code-input-group.error {
  border-color: var(--error);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
  animation: shake 0.4s ease;
}

.code-prefix {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  background: var(--navy-lighter);
  border-right: 1px solid var(--navy-lighter);
  min-width: 64px;
  align-self: stretch;
}

.code-prefix span {
  font-size: 1rem;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.code-separator {
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--white-subtle);
  padding: 0 0.25rem 0 0.5rem;
  user-select: none;
}

.code-input {
  flex: 1;
  padding: 1.125rem 1rem 1.125rem 0.25rem;
  font-size: 1.125rem;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-weight: 600;
  color: var(--white);
  background: transparent;
  border: none;
  outline: none;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  min-width: 0;
}

.code-input::placeholder {
  color: var(--white-subtle);
  font-weight: 400;
  font-family: var(--font);
  letter-spacing: 0;
  font-size: 1rem;
  text-transform: none;
}

/* Code hint */
.code-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 0 0.25rem;
  color: var(--white-subtle);
  font-size: 0.8125rem;
}

.code-hint svg {
  flex-shrink: 0;
  opacity: 0.6;
}

/* ===================================
   LOGIN BUTTON
   =================================== */

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1.125rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  color: var(--navy);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
  position: relative;
  overflow: hidden;
}

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

.login-btn:not(:disabled):hover::before {
  left: 100%;
}

.login-btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(245, 158, 11, 0.4);
}

.login-btn:not(:disabled):active {
  transform: translateY(0);
  box-shadow: 0 2px 15px rgba(245, 158, 11, 0.3);
}

.login-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.login-btn svg {
  transition: transform 0.2s ease;
}

.login-btn:not(:disabled):hover svg {
  transform: translateX(4px);
}

/* Loading state */
.login-btn.loading span,
.login-btn.loading svg {
  visibility: hidden;
}

.login-btn.loading::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(15, 23, 42, 0.3);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ===================================
   LOGIN ERROR
   =================================== */

.login-error {
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 12px;
  text-align: center;
  display: none;
}

.login-error.show {
  display: block;
  animation: shake 0.4s ease;
}

/* ===================================
   LOGIN FOOTER
   =================================== */

.login-footer {
  margin-top: auto;
  padding-top: 3rem;
  text-align: center;
}

.login-footer p {
  font-size: 0.8125rem;
  color: var(--white-subtle);
  letter-spacing: 0.02em;
}

/* ===================================
   VERIFY SCREEN
   =================================== */

.verify-screen {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-light) 100%);
  z-index: 5;
}

.verify-animation {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2rem;
}

.verify-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 3px solid var(--navy-lighter);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.verify-icon {
  color: var(--accent);
  opacity: 0.8;
}

.verify-text {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.verify-sub {
  font-size: 0.875rem;
  color: var(--white-subtle);
}

/* ===================================
   SUCCESS SCREEN
   =================================== */

.success-screen {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-light) 100%);
  z-index: 10;
}

.success-animation {
  margin-bottom: 2rem;
}

.success-circle {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.1);
  border: 3px solid var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-check {
  color: var(--success);
  animation: drawCheck 0.3s ease 0.2s both;
}

.success-text {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.375rem;
}

.success-company {
  font-size: 1.0625rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 1rem;
}

.success-sub {
  font-size: 0.875rem;
  color: var(--white-subtle);
}

/* ===================================
   BIOMETRIC & QUICK LOGIN SCREENS
   =================================== */

.biometric-screen,
.quick-login-screen {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-light) 100%);
}

.biometric-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.skip-btn {
  background: none;
  border: none;
  color: var(--white-muted);
  font-size: 0.9375rem;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  padding: 0.75rem 1rem;
  transition: color 0.2s ease;
}

.skip-btn:hover {
  color: var(--white);
}

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

.logo-container.small .logo {
  width: 120px;
}

/* ===================================
   HELP BUTTON
   =================================== */

.help-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--navy-lighter);
  background: var(--navy-light);
  color: var(--white-muted);
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  z-index: 100;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.1);
}

/* ===================================
   HELP OVERLAY
   =================================== */

.help-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.help-overlay.show {
  opacity: 1;
  visibility: visible;
}

.help-card {
  background: var(--navy-light);
  border: 1px solid var(--navy-lighter);
  border-radius: 20px;
  max-width: 380px;
  width: 100%;
  overflow: hidden;
  transform: translateY(16px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.help-overlay.show .help-card {
  transform: translateY(0) scale(1);
}

.help-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--navy-lighter);
}

.help-card-header h3 {
  font-size: 1.0625rem;
  font-weight: 600;
}

.help-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--white-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.help-close:hover {
  background: var(--navy-lighter);
  color: var(--white);
}

.help-card-body {
  padding: 1.5rem;
}

.help-card-body p {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--white-muted);
}

.help-divider {
  height: 1px;
  background: var(--navy-lighter);
  margin: 1.25rem 0;
}

.help-contact-label {
  font-weight: 600;
  color: var(--white) !important;
  margin-bottom: 0.375rem;
}

.help-whatsapp-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.75rem 1.25rem;
  background: #25d366;
  color: var(--white);
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font);
  text-decoration: none;
  transition: all 0.2s ease;
}

.help-whatsapp-btn:hover {
  background: #20bd5a;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.3);
}

/* ===================================
   ANIMATIONS
   =================================== */

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

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

@keyframes scaleIn {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes drawCheck {
  from { stroke-dasharray: 30; stroke-dashoffset: 30; }
  to { stroke-dasharray: 30; stroke-dashoffset: 0; }
}

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

/* Entrance animations for code screen elements */
.code-screen.active .logo-container {
  animation: entranceUp 0.5s ease both;
}

.code-screen.active .login-header {
  animation: entranceUp 0.5s ease 0.1s both;
}

.code-screen.active .login-form {
  animation: entranceUp 0.5s ease 0.2s both;
}

/* ===================================
   RESPONSIVE
   =================================== */

@media (min-height: 700px) {
  .login-header {
    margin-bottom: 2.75rem;
  }

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

@media (max-height: 580px) {
  .logo-container {
    margin-bottom: 1.5rem;
  }

  .logo {
    width: 120px;
  }

  .login-header {
    margin-bottom: 1.5rem;
  }

  .login-header h1 {
    font-size: 1.5rem;
  }

  .login-footer {
    padding-top: 1rem;
  }

  .ambient-glow {
    display: none;
  }
}

@media (min-width: 480px) {
  .code-input {
    font-size: 1.25rem;
  }

  .code-prefix span {
    font-size: 1.0625rem;
  }
}
