/* ==========================================================================
   Authentication / Login Page Styles
   Coherent with Thermodiag design system (theme.css, components.css)
   ========================================================================== */

/* Login overlay - covers entire viewport */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-page);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--surface-radial-1), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, var(--surface-radial-2), transparent),
    linear-gradient(180deg, var(--surface-page-linear-1), var(--surface-page-linear-2) 50%, var(--surface-page-linear-3));
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Login card container */
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 40px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Logo and branding */
.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  width: 180px;
  height: auto;
  margin-bottom: 20px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.2));
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px 0;
  letter-spacing: -0.5px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

/* Form styles */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.auth-input {
  padding: 14px 16px;
  background: var(--surface-input);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.auth-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.auth-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 20%, transparent);
  transform: translateY(-1px);
}

.auth-input:invalid:not(:placeholder-shown) {
  border-color: var(--status-danger);
}

/* Password input wrapper with toggle button */
.auth-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-wrapper .auth-input {
  flex: 1;
  padding-right: 48px;
}

.auth-toggle-password {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  box-shadow: none;
  transition: color 0.2s ease, background 0.2s ease;
}

.auth-toggle-password:hover {
  color: var(--text);
  background: var(--surface-muted);
  transform: translateY(-50%);
}

.auth-toggle-password:active {
  transform: translateY(-50%);
}

.auth-toggle-password .eye-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* Show/hide icons based on state */
.auth-toggle-password .eye-closed {
  display: none;
}

.auth-toggle-password.showing .eye-open {
  display: none;
}

.auth-toggle-password.showing .eye-closed {
  display: block;
}

/* Submit button */
.auth-submit {
  margin-top: 8px;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-on-accent);
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow-accent-1), var(--shadow-accent-2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

.auth-submit:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-accent-1), var(--shadow-accent-2), 0 8px 20px rgba(124,243,194,0.15);
}

.auth-submit:active {
  transform: translateY(0);
}

.auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Error message */
.auth-error {
  display: none;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--status-danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-danger) 40%, transparent);
  border-radius: 10px;
  color: var(--status-danger);
  font-size: 13px;
  text-align: center;
  animation: auth-shake 0.4s ease;
}

.auth-error.show {
  display: block;
}

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

/* Loading state */
.auth-submit.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.auth-submit.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid transparent;
  border-top-color: var(--text-on-accent);
  border-radius: 50%;
  animation: auth-spin 0.6s linear infinite;
}

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

/* Footer / copyright */
.auth-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.7;
}

/* ==========================================================================
   Logout Button in Header
   ========================================================================== */

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  box-shadow: none;
}

.logout-btn:hover {
  color: var(--status-danger);
  border-color: color-mix(in srgb, var(--status-danger) 50%, transparent);
  transform: translateY(-1px);
}

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

.logout-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* User info display */
.user-info {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  margin-right: 12px;
}

.user-email {
  font-size: 12px;
  color: var(--muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hide shell content when not authenticated */
body:not(.authenticated) .shell {
  display: none;
}

body:not(.authenticated) .auth-overlay {
  display: flex;
}

body.authenticated .auth-overlay {
  display: none;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .auth-card {
    margin: 16px;
    padding: 28px 24px;
  }

  .auth-logo {
    width: 140px;
  }

  .auth-title {
    font-size: 20px;
  }

  .user-email {
    display: none;
  }
}
