/*
 * Somnus Sleep Medicine Center - Authentication Styles
 * Professional Medical Theme with Warm, Trustworthy Design
 * For Login and Registration Pages
 */

:root {
  /* SMD SAPPAYA Primary Brand Colors */
  --smd-primary: #152c6e;
  --smd-secondary: #2563eb;
  --smd-accent: #0897b0;
  --smd-success: #0d9e6e;
  --smd-warning: #d97706;
  --smd-danger: #dc2626;
  --smd-info: #0897b0;

  /* Neutral Medical Colors */
  --smd-light: #f8fafc;
  --smd-lighter: #ffffff;
  --smd-dark: #0a1121;
  --smd-gray: #475569;
  --smd-gray-light: #94a3b8;
  --smd-border: #e2e8f0;
  --smd-border-light: #f1f5f9;

  /* Compatibility aliases */
  --medical-blue: var(--smd-secondary);
  --medical-blue-dark: #1d4ed8;
  --text-primary: var(--smd-dark);
  --text-secondary: rgba(71, 85, 105, 0.85);
  --text-muted: rgba(100, 116, 139, 0.75);
  --border-light: var(--smd-border-light);
  --border-medium: var(--smd-border);
  --success: var(--smd-success);
  --danger: var(--smd-danger);

  /* Medical Gradients */
  --medical-gradient: linear-gradient(
    135deg,
    #152c6e 0%,
    #2563eb 50%,
    #0897b0 100%
  );
  --medical-gradient-light: linear-gradient(
    135deg,
    rgba(248, 250, 252, 0.95) 0%,
    rgba(241, 245, 249, 0.95) 100%
  );
  --success-gradient: linear-gradient(135deg, #0d9e6e 0%, #047857 100%);

  /* Material Design Shadows */
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-medium: 0 4px 12px rgba(21, 44, 110, 0.08);
  --shadow-strong: 0 8px 25px rgba(21, 44, 110, 0.12);
  --medical-shadow: 0 8px 25px rgba(21, 44, 110, 0.15);

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;

  /* Typography */
  --font-primary: "Sarabun", "Kanit", -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-heading: "Kanit", sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-primary);
  background:
    radial-gradient(110% 110% at 10% 10%, rgba(37, 99, 235, 0.25), transparent 55%),
    radial-gradient(120% 120% at 90% 15%, rgba(8, 151, 176, 0.22), transparent 60%),
    radial-gradient(90% 90% at 50% 95%, rgba(21, 44, 110, 0.3), transparent 65%),
    var(--medical-gradient);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--smd-dark);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  padding: clamp(20px, 3vh, 40px);
  overflow: auto;
  isolation: isolate;
}

/* Medical Icons Floating Background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0) 45%),
    radial-gradient(circle at 15% 85%, rgba(255, 255, 255, 0.18) 0%, transparent 55%),
    radial-gradient(circle at 82% 25%, rgba(255, 255, 255, 0.14) 0%, transparent 52%);
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: -1;
}

/* Floating Medical Icons */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 160 160"><path stroke="%23ffffff26" stroke-width="1.5" d="M20 80c0-33.137 26.863-60 60-60s60 26.863 60 60-26.863 60-60 60S20 113.137 20 80Z"/><path stroke="%23ffffff1f" stroke-width="1.5" d="M60 80c0-11.046 8.954-20 20-20s20 8.954 20 20-8.954 20-20 20S60 91.046 60 80Z"/></svg>');
  background-repeat: no-repeat;
  background-size: 480px 480px;
  background-position: center;
  opacity: 0.65;
  pointer-events: none;
  z-index: -1;
  filter: blur(0.3px);
}

@keyframes floatIcons {
  0%,
  100% {
    background-position: 10% 20%, 80% 15%, 20% 70%, 90% 80%, 50% 30%, 70% 60%,
      15% 90%, 85% 40%;
    opacity: 0.8;
  }
  25% {
    background-position: 15% 25%, 75% 20%, 25% 65%, 85% 75%, 55% 35%, 65% 55%,
      20% 85%, 80% 45%;
    opacity: 0.6;
  }
  50% {
    background-position: 12% 30%, 85% 12%, 18% 75%, 88% 85%, 48% 25%, 72% 65%,
      12% 95%, 88% 35%;
    opacity: 0.9;
  }
  75% {
    background-position: 8% 15%, 82% 25%, 22% 68%, 92% 82%, 52% 32%, 68% 58%,
      18% 88%, 82% 42%;
    opacity: 0.7;
  }
}

.auth-wrapper {
  width: 100%;
  max-width: min(92vw, 480px);
  padding: clamp(16px, 3vh, 24px);
  position: relative;
  z-index: 2;
}

.auth-container {
  position: relative;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 28px;
  box-shadow: 0 20px 60px rgba(21, 44, 110, 0.15), 0 8px 20px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.auth-container::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(21, 44, 110, 0.16) 0%, rgba(21, 44, 110, 0) 45%);
  z-index: 0;
}

.auth-container > * {
  position: relative;
  z-index: 1;
}

.auth-header {
  background: var(--medical-gradient);
  color: white;
  text-align: center;
  padding: clamp(36px, 6vh, 56px) clamp(28px, 5vw, 40px);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.auth-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 64%);
  opacity: 0.7;
}

/* Medical Heart Logo */
.medical-heart-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.heart-icon {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 8px 20px rgba(10, 17, 33, 0.12);
}

.heart-icon i {
  font-size: 1.1rem;
  color: white;
  z-index: 2;
  position: relative;
}

/* Heartbeat Line Animation */
.heartbeat-line {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 2px;
  background: rgba(255, 255, 255, 0.22);
  z-index: 1;
}

.heartbeat-line::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.6);
  clip-path: polygon(
    0% 50%,
    10% 50%,
    15% 20%,
    20% 80%,
    25% 50%,
    30% 50%,
    35% 20%,
    40% 80%,
    45% 50%,
    100% 50%
  );
  animation: heartbeat 2s ease-in-out infinite;
}

@keyframes heartbeat {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

.pulse {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.45);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.3);
    opacity: 0.8;
  }
}

/* Brand Text */
.brand-name {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 3.6vw, 1.9rem);
  font-weight: 700;
  letter-spacing: 0.6px;
  text-shadow: 0 8px 18px rgba(10, 17, 33, 0.25);
}

.brand-tagline {
  font-size: clamp(0.8rem, 2vw, 0.9rem);
  opacity: 0.95;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.brand-description {
  font-size: clamp(0.72rem, 1.8vw, 0.78rem);
  opacity: 0.9;
  line-height: 1.35;
}

.auth-form {
  padding: clamp(32px, 5vh, 44px) clamp(32px, 6vw, 48px) clamp(36px, 6vh, 52px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-title {
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 3vw, 1.35rem);
  font-weight: 600;
  text-align: center;
  color: var(--smd-dark);
}

.form-subtitle {
  text-align: center;
  color: var(--smd-gray);
  font-size: clamp(0.8rem, 2vw, 0.85rem);
  margin-top: -6px;
}

/* Form Groups */
.form-group {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  color: var(--smd-dark);
  font-size: 0.8rem;
}

.input-wrapper {
  position: relative;
  transition: var(--transition-normal);
}

.input-wrapper.focused {
  transform: translateY(-1px);
}

.form-control {
  width: 100%;
  padding: 14px 18px 14px 46px;
  border: 1.5px solid rgba(148, 163, 184, 0.3);
  border-radius: 14px;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.98);
  transition: all 0.2s ease;
  font-family: var(--font-primary);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.04);
}

.form-control:focus {
  border-color: rgba(37, 99, 235, 0.6);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
  outline: none;
  background: var(--smd-lighter);
}

.form-control:focus-visible {
  outline: none;
}

.form-control::placeholder {
  color: var(--smd-gray-light);
}

.input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(71, 85, 105, 0.6);
  font-size: 1rem;
  z-index: 1;
  transition: all 0.2s ease;
}

.input-wrapper.focused .input-icon {
  color: var(--smd-secondary);
}

/* Buttons */
.btn-primary {
  background: var(--medical-gradient);
  border: none;
  color: white;
  padding: 15px 28px;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: none;
  letter-spacing: 0.3px;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(21, 44, 110, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(10, 17, 33, 0.28);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(21, 44, 110, 0.25), 0 12px 28px rgba(10, 17, 33, 0.3);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Links */
.auth-links {
  text-align: center;
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.link-primary,
.link-secondary {
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition-normal);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

.link-primary {
  color: var(--smd-secondary);
  background: rgba(37, 99, 235, 0.12);
}

.link-primary:hover {
  color: white;
  background: var(--medical-gradient);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(21, 44, 110, 0.15);
}

.link-secondary {
  color: rgba(71, 85, 105, 0.8);
}

.link-secondary:hover {
  color: var(--smd-primary);
  text-decoration: none;
}

.demo-section {
  background: rgba(248, 249, 250, 0.8);
  border-radius: var(--radius-md);
  padding: clamp(10px, 2vh, 15px);
  margin-top: clamp(12px, 3vh, 18px);
  border: 1px solid var(--border-light);
}

.demo-title {
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: clamp(8px, 2vh, 15px);
  text-align: center;
  font-size: clamp(0.75rem, 1.8vw, 0.9rem);
}

.demo-btn {
  width: 100%;
  padding: clamp(6px, 1.5vh, 10px) clamp(8px, 2vw, 15px);
  margin: clamp(2px, 0.5vh, 4px) 0;
  border-radius: var(--radius-sm);
  font-size: clamp(0.7rem, 1.5vw, 0.85rem);
  font-weight: 500;
  border: 1.5px solid;
  background: transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  min-height: clamp(28px, 6vh, 36px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.demo-admin {
  border-color: #8e44ad;
  color: #8e44ad;
}

.demo-admin:hover {
  background: #8e44ad;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(142, 68, 173, 0.2);
}

.demo-branch {
  border-color: #3498db;
  color: #3498db;
}

.demo-branch:hover {
  background: #3498db;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(52, 152, 219, 0.2);
}

.demo-finance {
  border-color: #27ae60;
  color: #27ae60;
}

.demo-finance:hover {
  background: #27ae60;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(39, 174, 96, 0.2);
}

.demo-tech {
  border-color: #f39c12;
  color: #f39c12;
}

.demo-tech:hover {
  background: #f39c12;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(243, 156, 18, 0.2);
}

.demo-doctor {
  border-color: #34495e;
  color: #34495e;
}

.demo-doctor:hover {
  background: #34495e;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(52, 73, 94, 0.2);
}

.demo-sales {
  border-color: #e74c3c;
  color: #e74c3c;
}

.demo-sales:hover {
  background: #e74c3c;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(231, 76, 60, 0.2);
}

/* Small screens */
@media (max-width: 576px) {
  .auth-wrapper {
    max-width: 100%;
    padding: 12px;
  }

  .auth-container {
    border-radius: 20px;
  }

  .auth-header {
    padding: 28px 20px 24px;
  }

  .brand-name {
    font-size: clamp(1.5rem, 5vw, 1.7rem);
  }

  .auth-form {
    padding: 24px 20px 28px;
  }

  .form-title {
    font-size: clamp(1.15rem, 4vw, 1.25rem);
  }

  .form-control {
    padding: 13px 16px 13px 42px;
    border-radius: 12px;
  }

  .btn-primary {
    padding: 14px 24px;
    border-radius: 12px;
  }

  .demo-section {
    padding: min(2vh, 12px);
  }

  .demo-btn {
    padding: min(1.5vh, 6px) min(2vw, 8px);
    font-size: clamp(0.7rem, 2vw, 0.75rem);
  }
}

/* Medium screens */
@media (min-width: 577px) and (max-width: 1024px) {
  .auth-wrapper {
    max-width: min(85vw, 420px);
  }

  .auth-header {
    padding: min(4vh, 25px) min(5vw, 25px);
  }

  .brand-name {
    font-size: clamp(1.6rem, 3.5vw, 2rem);
  }

  .form-title {
    font-size: clamp(1.2rem, 2.5vw, 1.4rem);
  }

  .demo-btn {
    padding: min(2vh, 8px) min(2.5vw, 12px);
    font-size: clamp(0.75rem, 1.8vw, 0.85rem);
  }
}

/* Large tablets and small laptops */
@media (min-width: 1025px) and (max-width: 1366px) {
  .auth-wrapper {
    max-width: min(80vw, 450px);
  }

  .auth-header {
    padding: min(3vh, 20px) min(4vw, 25px);
  }

  .auth-form {
    padding: min(4vh, 25px);
  }

  .brand-name {
    font-size: clamp(1.6rem, 2.5vw, 1.8rem);
  }

  .form-title {
    font-size: clamp(1.2rem, 2vw, 1.4rem);
  }

  .demo-btn {
    padding: min(1.8vh, 8px) min(2vw, 12px);
    font-size: clamp(0.75rem, 1.5vw, 0.8rem);
  }
}

/* Large screens (desktops) */
@media (min-width: 1367px) {
  .auth-wrapper {
    max-width: min(75vw, 500px);
  }

  .auth-header {
    padding: min(5vh, 30px) min(3vw, 30px);
  }

  .auth-form {
    padding: min(5vh, 30px);
  }

  .brand-name {
    font-size: clamp(1.8rem, 2vw, 2.2rem);
  }

  .form-title {
    font-size: clamp(1.4rem, 1.5vw, 1.6rem);
  }

  .demo-btn {
    padding: min(2vh, 10px) min(1.8vw, 15px);
    font-size: clamp(0.8rem, 1.2vw, 0.9rem);
  }
}

/* Extra large screens */
@media (min-width: 1920px) {
  .auth-wrapper {
    max-width: min(70vw, 600px);
  }

  .demo-btn {
    padding: min(2.5vh, 12px) min(1.5vw, 18px);
    font-size: clamp(0.85rem, 1vw, 1rem);
  }
}

/* Register page specific responsive adjustments */
.register-form {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

@media (max-width: 768px) {
  .register-form {
    max-height: calc(100vh - 150px);
  }
}

/* Ensure register form wrapper is wider and scrollable */
.auth-wrapper:has(.register-form) {
  max-width: 750px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

@media (min-width: 768px) {
  .auth-wrapper:has(.register-form) {
    max-width: 850px;
  }
}

@media (min-width: 1200px) {
  .auth-wrapper:has(.register-form) {
    max-width: 950px;
  }
}

/* Scroll styling for register form */
.auth-wrapper::-webkit-scrollbar {
  width: 8px;
}

.auth-wrapper::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.auth-wrapper::-webkit-scrollbar-thumb {
  background: rgba(74, 144, 226, 0.3);
  border-radius: 4px;
}

.auth-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(74, 144, 226, 0.5);
}

.register-form .form-group {
  margin-bottom: 18px;
}

.register-form .row .form-group {
  margin-bottom: 15px;
}

.register-form select.form-control {
  cursor: pointer;
}

.register-form .form-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

.register-form .form-check {
  margin: 20px 0;
  padding-left: 0;
}

.register-form .form-check-input {
  margin-right: 8px;
  margin-top: 2px;
}

.register-form .form-check-label {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.register-form .form-check-label a {
  color: var(--medical-blue);
  text-decoration: none;
}

.register-form .form-check-label a:hover {
  text-decoration: underline;
}

/* Required field indicator */
.required {
  color: var(--danger);
}

/* Success message */
.alert-success {
  background-color: rgba(39, 174, 96, 0.1);
  border: 1px solid rgba(39, 174, 96, 0.2);
  color: var(--success);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 0.9rem;
}

/* Error message */
.alert-danger {
  background-color: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.2);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 0.9rem;
}

/* Loading state */
.loading {
  pointer-events: none;
  opacity: 0.8;
}

.loading .btn-primary {
  cursor: wait;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus indicators for accessibility */
.form-control:focus,
.btn-primary:focus,
.demo-btn:focus,
.link-primary:focus,
.link-secondary:focus {
  outline: 2px solid var(--medical-blue);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-light: #000000;
    --border-medium: #000000;
    --text-muted: #000000;
  }
}
