/* ==========================================================================
   Auth Panel — login + signup side drawer.
   ========================================================================== */

:root {
  --auth-panel-width:        500px;
  --auth-panel-z-overlay:    100001;
  --auth-panel-z-drawer:     100002;

  --auth-panel-pad-x:        var(--spacing-desktop-x);
  --auth-panel-pad-y:        var(--spacing-desktop-x);
  --auth-panel-gap:          16px;
  --auth-panel-gap-sm:       8px;
  --auth-panel-gap-lg:       24px;

  --auth-input-height:       48px;
  --auth-input-radius:       var(--radius-btn);
  --auth-input-pad-x:        16px;
  --auth-input-icon-pad:     44px;

  --auth-btn-height:         48px;
  --auth-social-height:      44px;

  --auth-overlay-bg:         rgba(0, 0, 0, 0.5);
  --auth-transition-dur:     0.35s;
  --auth-transition-ease:    cubic-bezier(0.25, 0.46, 0.45, 0.94);

  --auth-font-title:         24px;
  --auth-font-tab:           16px;
  --auth-font-label:         14px;
  --auth-font-input:         16px;
  --auth-font-btn:           16px;
  --auth-font-small:         12px;

  --auth-border-color:       var(--color-border);
  --auth-focus-color:        var(--color-blue-dark);
  --auth-input-bg:           var(--color-white);
}

/* ----- Overlay ----- */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--auth-overlay-bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--auth-transition-dur) ease;
  z-index: var(--auth-panel-z-overlay);
}
.auth-overlay[hidden] { display: none; }
.auth-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ----- Panel container ----- */
.auth-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--auth-panel-width);
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: var(--color-white);
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  visibility: hidden;
  transition:
    transform var(--auth-transition-dur) var(--auth-transition-ease),
    visibility 0s linear var(--auth-transition-dur);
  z-index: var(--auth-panel-z-drawer);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-secondary);
}
.auth-panel[hidden] { display: none; }
.auth-panel.is-open {
  transform: translateX(0);
  visibility: visible;
  transition:
    transform var(--auth-transition-dur) var(--auth-transition-ease),
    visibility 0s linear 0s;
}

/* ----- Header logo (mobile only) ----- */
.auth-panel__logo {
  display: none;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}
.auth-panel__logo img {
  width: 150px;
  height: auto;
  display: block;
}

/* ----- Header ----- */
.auth-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--auth-panel-pad-y) var(--auth-panel-pad-x) var(--auth-panel-gap-sm);
  gap: var(--auth-panel-gap);
  flex-shrink: 0;
}
.auth-panel__title {
  margin: 0;
  font-size: var(--auth-font-title);
  font-weight: 700;
  color: var(--color-text-dark);
  line-height: 1.2;
}
.auth-panel__close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.auth-panel__close:hover,
.auth-panel__close:focus-visible {
  background-color: var(--color-bg-light);
  color: var(--color-text-dark);
  outline: none;
}

/* ----- Tabs ----- */
.auth-panel__tabs {
  display: flex;
  gap: var(--auth-panel-gap-lg);
  padding: 0 var(--auth-panel-pad-x);
  border-bottom: 1px solid var(--auth-border-color);
  flex-shrink: 0;
}
.auth-panel__tab {
  background: none;
  border: none;
  padding: 12px 0;
  font-size: var(--auth-font-tab);
  font-weight: 500;
  color: var(--color-text-light);
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}
.auth-panel__tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--color-blue);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.2s ease;
}
.auth-panel__tab.is-active {
  color: var(--color-blue);
  font-weight: 600;
}
.auth-panel__tab.is-active::after { transform: scaleX(1); }
.auth-panel__tab:focus-visible { outline: 2px solid var(--auth-focus-color); outline-offset: 4px; }

/* ----- Body / scroll area ----- */
.auth-panel__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--auth-panel-pad-y) var(--auth-panel-pad-x) var(--auth-panel-pad-y);
  -webkit-overflow-scrolling: touch;
}
.auth-panel__view[hidden] { display: none; }

/* ----- Form ----- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--auth-panel-gap);
}

.auth-form__alert,
.auth-form__success {
  padding: 12px 16px;
  border-radius: var(--auth-input-radius);
  font-size: var(--auth-font-small);
  line-height: 1.4;
}
.auth-form__alert {
  background: rgba(216, 81, 81, 0.08);
  color: var(--color-error);
  border: 1px solid rgba(216, 81, 81, 0.25);
}
.auth-form__success {
  background: rgba(79, 156, 102, 0.08);
  color: var(--color-green);
  border: 1px solid rgba(79, 156, 102, 0.25);
}
.auth-form__alert[hidden],
.auth-form__success[hidden] { display: none; }

/* ----- Field ----- */
.auth-field {
  display: flex;
  flex-direction: column;
  gap: var(--auth-panel-gap-sm);
}
.auth-field__label {
  font-size: var(--auth-font-label);
  font-weight: 500;
  color: var(--color-text-dark);
  line-height: 1.4;
}
.auth-field__wrap {
  position: relative;
  display: block;
}
.auth-field__input {
  width: 100%;
  height: var(--auth-input-height);
  padding: 0 var(--auth-input-pad-x);
  font-size: var(--auth-font-input);
  font-family: var(--font-secondary);
  color: var(--color-text-dark);
  background: var(--auth-input-bg);
  border: 1px solid var(--auth-border-color);
  border-radius: var(--auth-input-radius);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  -webkit-appearance: none;
  appearance: none;
}
.auth-field__input--has-icon { padding-right: var(--auth-input-icon-pad); }
.auth-field__input::placeholder { color: var(--color-text-light); }
.auth-field__input:focus,
.auth-field__input:focus-visible {
  outline: none;
  border-color: var(--auth-focus-color);
  box-shadow: 0 0 0 4px rgba(63, 117, 201, 0.15);
}
.auth-field.is-invalid .auth-field__input,
.auth-field__input.is-invalid {
  border-color: var(--color-error);
}
.auth-field.is-invalid .auth-field__input:focus,
.auth-field__input.is-invalid:focus {
  box-shadow: 0 0 0 4px rgba(216, 81, 81, 0.15);
}

.auth-field__toggle {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 28px;
  height: 28px;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--color-text-light);
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.auth-field__toggle:hover { color: var(--color-text-dark); }
.auth-field__toggle:focus-visible {
  outline: 2px solid var(--auth-focus-color);
  outline-offset: 2px;
}
.auth-field__icon { display: block; }
.auth-field__icon--hide { display: none; }
.auth-field__toggle[aria-pressed="true"] .auth-field__icon--show { display: none; }
.auth-field__toggle[aria-pressed="true"] .auth-field__icon--hide { display: block; }

.auth-field__error {
  margin: 0;
  font-size: var(--auth-font-small);
  color: var(--color-error);
  line-height: 1.3;
  min-height: 0;
}
.auth-field__error[hidden] { display: none; }

/* ----- Row layouts ----- */
.auth-form__row {
  display: flex;
  align-items: center;
  gap: var(--auth-panel-gap);
  margin-top: -4px;
}
.auth-form__row--right { justify-content: flex-end; }

.auth-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-blue);
  font-size: var(--auth-font-small);
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
  font-family: var(--font-secondary);
}
.auth-link:hover { color: var(--color-blue-dark); }
.auth-link:focus-visible {
  outline: 2px solid var(--auth-focus-color);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ----- Submit button ----- */
.auth-form__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--auth-panel-gap-sm);
  width: 100%;
  height: var(--auth-btn-height);
  padding: 0 16px;
  background: var(--color-blue);
  color: var(--color-white);
  font-size: var(--auth-font-btn);
  font-weight: 600;
  font-family: var(--font-secondary);
  border: none;
  border-radius: var(--auth-input-radius);
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.06s ease;
}
.auth-form__submit:hover { background: var(--color-blue-dark); }
.auth-form__submit:active { transform: translateY(1px); }
.auth-form__submit:focus-visible {
  outline: 2px solid var(--auth-focus-color);
  outline-offset: 2px;
}
.auth-form__submit:disabled {
  opacity: 0.7;
  cursor: progress;
}
.auth-form__submit-icon { flex-shrink: 0; }

/* ----- Divider ----- */
.auth-form__divider {
  display: flex;
  align-items: center;
  gap: var(--auth-panel-gap);
  margin: var(--auth-panel-gap-sm) 0;
  color: var(--color-text-light);
  font-size: var(--auth-font-small);
}
.auth-form__divider::before,
.auth-form__divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--auth-border-color);
}

/* ----- Social buttons ----- */
.auth-form__socials {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--auth-panel-gap);
}
.auth-social-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--auth-panel-gap-sm);
  height: var(--auth-social-height);
  padding: 0 12px;
  border: 1px solid var(--auth-border-color);
  border-radius: var(--auth-input-radius);
  background: var(--color-white);
  color: var(--color-text-dark);
  font-size: var(--auth-font-small);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}
.auth-social-btn:hover {
  background: var(--color-bg-light);
  border-color: var(--color-text-light);
}
.auth-social-btn:focus-visible {
  outline: 2px solid var(--auth-focus-color);
  outline-offset: 2px;
}

/* ----- Switch-view footer ----- */
.auth-form__switch {
  margin: var(--auth-panel-gap-sm) 0 0;
  text-align: center;
  font-size: var(--auth-font-small);
  color: var(--color-text);
}
.auth-form__switch .auth-link { margin-left: 4px; }

/* ==========================================================================
   Body lock when panel is open
   ========================================================================== */
body.auth-panel-open {
  overflow: hidden;
  touch-action: none;
}

/* ==========================================================================
   Mobile
   ========================================================================== */
@media (max-width: 480px) {
  :root {
    --auth-panel-width:   100vw;
    --auth-panel-pad-x:   var(--spacing-mobile-x);
    --auth-panel-pad-y:   var(--spacing-mobile-x);
  }
  .auth-panel {
    box-shadow: none;
  }
  .auth-panel__logo { display: flex; }
  .auth-panel__title { display: none; }
  .auth-form__socials { grid-template-columns: 1fr; }
  .auth-field__input,
  .auth-form__submit,
  .auth-social-btn,
  .auth-panel__close {
    min-height: 48px;
  }
}

@media (min-width: 481px) and (max-width: 767px) {
  :root {
    --auth-panel-width: 100vw;
    --auth-panel-pad-x: var(--spacing-tablet-x);
  }
  .auth-panel__logo { display: flex; }
  .auth-panel__title { display: none; }
}
