/**
 * ALVEA - Surgical Access Terminal
 * Login modal with medical-grade HUD aesthetic
 * Design: Siemens Healthineers × Linear.app
 */

/* ============================================
   SURGICAL HUD DESIGN TOKENS
   ============================================ */
:root {
  /* Dark surgical palette */
  --modal-bg: #0A0E17;
  --modal-surface: #0F1420;
  --modal-elevated: #161C2C;
  --modal-border: rgba(255, 255, 255, 0.06);
  --modal-border-active: rgba(139, 92, 246, 0.5);

  /* Accent - Medical Purple */
  --modal-accent: #8B5CF6;
  --modal-accent-glow: rgba(139, 92, 246, 0.4);
  --modal-accent-subtle: rgba(139, 92, 246, 0.1);

  /* Secondary - Cyan for scanning effects */
  --modal-scan: #00D9FF;
  --modal-scan-glow: rgba(0, 217, 255, 0.3);

  /* Text */
  --modal-text: #FFFFFF;
  --modal-text-secondary: rgba(255, 255, 255, 0.6);
  --modal-text-muted: rgba(255, 255, 255, 0.4);

  /* Typography */
  --modal-font-display: 'Clash Display', system-ui, sans-serif;
  --modal-font-body: 'General Sans', system-ui, sans-serif;
  --modal-font-mono: 'Azeret Mono', monospace;

  /* Animation */
  --modal-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --modal-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================
   MODAL CONTAINER
   ============================================ */
.dvp-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  perspective: 1000px;
}

.dvp-modal.dvp-modal-open {
  display: flex;
}

/* ============================================
   OVERLAY - Deep Space Effect
   ============================================ */
.dvp-modal-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 80% 50% at 50% 0%,
    rgba(139, 92, 246, 0.15) 0%,
    rgba(10, 14, 23, 0.97) 50%,
    rgba(10, 14, 23, 0.99) 100%
  );
  backdrop-filter: blur(12px) saturate(180%);
  animation: overlayFadeIn 0.4s var(--modal-ease);
}

@keyframes overlayFadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px) saturate(100%);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(12px) saturate(180%);
  }
}

/* ============================================
   MODAL CARD - Surgical Terminal
   ============================================ */
.dvp-modal-content {
  position: relative;
  background: var(--modal-surface);
  border: 1px solid var(--modal-border);
  border-radius: 1.25rem;
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: terminalOpen 0.5s var(--modal-ease);
  padding: 0;

  /* Surgical panel shadow */
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.02),
    0 4px 6px -1px rgba(0, 0, 0, 0.4),
    0 25px 50px -12px rgba(0, 0, 0, 0.6),
    0 0 100px -20px var(--modal-accent-glow);

  /* Hide scrollbar but allow scroll */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.dvp-modal-content::-webkit-scrollbar {
  display: none;
}

@keyframes terminalOpen {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Corner brackets - surgical frame */
.dvp-modal-content::before,
.dvp-modal-content::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border: 2px solid var(--modal-accent);
  opacity: 0.5;
  pointer-events: none;
  z-index: 10;
}

.dvp-modal-content::before {
  top: 12px;
  left: 12px;
  border-right: none;
  border-bottom: none;
  border-radius: 4px 0 0 0;
}

.dvp-modal-content::after {
  bottom: 12px;
  right: 12px;
  border-left: none;
  border-top: none;
  border-radius: 0 0 4px 0;
}

/* ============================================
   HEADER - Access Terminal Banner
   ============================================ */
.dvp-modal-header {
  position: relative;
  padding: 2rem 2rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--modal-border);
  background: linear-gradient(
    180deg,
    rgba(139, 92, 246, 0.08) 0%,
    transparent 100%
  );
}

/* Scan line animation */
.dvp-modal-header::after {
  content: '';
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--modal-accent) 50%,
    transparent 100%
  );
  animation: scanPulse 3s ease-in-out infinite;
}

@keyframes scanPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Status indicator */
.dvp-modal-header::before {
  content: 'SECURE ACCESS';
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--modal-font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.2em;
  color: var(--modal-accent);
  text-transform: uppercase;
  opacity: 0.7;
}

.dvp-modal-title {
  font-family: var(--modal-font-display);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--modal-text);
  margin: 0.5rem 0 0.5rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.dvp-modal-subtitle {
  font-family: var(--modal-font-body);
  font-size: 0.875rem;
  color: var(--modal-text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* ============================================
   CLOSE BUTTON - Minimal surgical X
   ============================================ */
.dvp-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--modal-border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--modal-text-muted);
  transition: all 0.2s var(--modal-ease);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.dvp-modal-close:hover {
  background: var(--modal-accent-subtle);
  border-color: var(--modal-accent);
  color: var(--modal-accent);
  transform: rotate(90deg);
}

.dvp-modal-close svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.5;
}

/* ============================================
   MODAL BODY
   ============================================ */
.dvp-modal-body {
  padding: 1.5rem 2rem 2rem;
}

/* ============================================
   AUTH FORMS
   ============================================ */
.dvp-auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Form Groups */
.dvp-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dvp-form-group label {
  font-family: var(--modal-font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--modal-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Input fields - Medical terminal style */
.dvp-form-group input {
  padding: 0.875rem 1rem;
  font-family: var(--modal-font-body);
  font-size: 0.9375rem;
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 0.625rem;
  color: var(--modal-text);
  transition: all 0.2s var(--modal-ease);
  outline: none;
}

.dvp-form-group input::placeholder {
  color: var(--modal-text-muted);
}

.dvp-form-group input:focus {
  border-color: var(--modal-accent);
  box-shadow:
    0 0 0 3px var(--modal-accent-subtle),
    0 0 20px -5px var(--modal-accent-glow);
  background: rgba(139, 92, 246, 0.03);
}

/* ============================================
   BUTTONS
   ============================================ */
.dvp-btn-primary,
.dvp-btn-secondary,
.dvp-btn-google {
  position: relative;
  padding: 0.875rem 1.5rem;
  font-family: var(--modal-font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: 0.625rem;
  border: none;
  cursor: pointer;
  transition: all 0.25s var(--modal-ease);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  overflow: hidden;
}

/* Primary button - Glowing accent */
.dvp-btn-primary {
  background: linear-gradient(
    135deg,
    var(--modal-accent) 0%,
    #7C3AED 100%
  );
  color: white;
  box-shadow:
    0 0 20px -5px var(--modal-accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.dvp-btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.2) 0%,
    transparent 50%
  );
  opacity: 0;
  transition: opacity 0.25s;
}

.dvp-btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow:
    0 0 40px -5px var(--modal-accent-glow),
    0 10px 30px -10px rgba(139, 92, 246, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.dvp-btn-primary:hover:not(:disabled)::before {
  opacity: 1;
}

.dvp-btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.dvp-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Secondary button - Ghost style */
.dvp-btn-secondary {
  background: transparent;
  color: var(--modal-text-secondary);
  border: 1px solid var(--modal-border);
}

.dvp-btn-secondary:hover:not(:disabled) {
  background: var(--modal-accent-subtle);
  border-color: var(--modal-border-active);
  color: var(--modal-text);
}

/* Google button - Clean dark style */
.dvp-btn-google {
  background: var(--modal-bg);
  color: var(--modal-text);
  border: 1px solid var(--modal-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dvp-btn-google:hover:not(:disabled) {
  background: var(--modal-elevated);
  border-color: var(--modal-border-active);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dvp-btn-google:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dvp-btn-google svg {
  flex-shrink: 0;
}

/* ============================================
   DIVIDER - Surgical separator
   ============================================ */
.dvp-form-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.5rem 0;
}

.dvp-form-divider::before,
.dvp-form-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--modal-border),
    transparent
  );
}

.dvp-form-divider span {
  font-family: var(--modal-font-mono);
  font-size: 0.6875rem;
  color: var(--modal-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ============================================
   LINK BUTTON
   ============================================ */
.dvp-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: -0.25rem;
}

.dvp-link-button {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--modal-font-body);
  font-size: 0.8125rem;
  color: var(--modal-accent);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  opacity: 0.8;
}

.dvp-link-button:hover {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================
   AUTH MESSAGES
   ============================================ */
.dvp-auth-message {
  padding: 0.875rem 1rem;
  border-radius: 0.625rem;
  font-family: var(--modal-font-body);
  font-size: 0.8125rem;
  line-height: 1.5;
  margin-top: 1rem;
  font-weight: 500;
  border: 1px solid;
}

.dvp-auth-message-success {
  background: rgba(34, 197, 94, 0.1);
  color: #4ADE80;
  border-color: rgba(34, 197, 94, 0.2);
}

.dvp-auth-message-error {
  background: rgba(239, 68, 68, 0.1);
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.2);
}

.dvp-auth-message-info {
  background: rgba(139, 92, 246, 0.1);
  color: #A78BFA;
  border-color: rgba(139, 92, 246, 0.2);
}

/* ============================================
   BIOMETRIC SCAN EFFECT (on form focus)
   ============================================ */
.dvp-modal-content:has(input:focus)::before,
.dvp-modal-content:has(input:focus)::after {
  border-color: var(--modal-scan);
  opacity: 0.8;
  animation: bracketPulse 1.5s ease-in-out infinite;
}

@keyframes bracketPulse {
  0%, 100% {
    opacity: 0.5;
    box-shadow: 0 0 0 rgba(0, 217, 255, 0);
  }
  50% {
    opacity: 0.9;
    box-shadow: 0 0 15px var(--modal-scan-glow);
  }
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
  .dvp-modal {
    padding: 0.5rem;
    align-items: flex-end;
  }

  .dvp-modal-content {
    max-width: 100%;
    max-height: 95vh;
    border-radius: 1.25rem 1.25rem 0 0;
    animation: terminalSlideUp 0.4s var(--modal-ease);
  }

  @keyframes terminalSlideUp {
    from {
      opacity: 0;
      transform: translateY(100%);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .dvp-modal-header {
    padding: 1.75rem 1.5rem 1.25rem;
  }

  .dvp-modal-body {
    padding: 1.25rem 1.5rem 2rem;
  }

  .dvp-modal-title {
    font-size: 1.5rem;
  }

  .dvp-form-group input {
    font-size: 16px; /* Prevents iOS zoom */
    padding: 1rem;
  }

  .dvp-btn-primary,
  .dvp-btn-secondary,
  .dvp-btn-google {
    padding: 1rem 1.5rem;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .dvp-modal-overlay,
  .dvp-modal-content,
  .dvp-modal-header::after,
  .dvp-modal-content::before,
  .dvp-modal-content::after,
  .dvp-btn-primary,
  .dvp-btn-secondary,
  .dvp-btn-google,
  .dvp-modal-close {
    animation: none;
    transition: none;
  }
}
