/* Authentication Modal Styles */

#auth-modal {
  position: fixed;
  top: var(--app-header-height, 70px);
  left: 0;
  right: 0;
  width: 100%;
  bottom: var(--app-footer-height, 52px);
  height: auto;
  z-index: 1200;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  overflow: hidden;
  box-sizing: border-box;
}

#auth-modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: -1;
}

#auth-modal-card {
  background: rgba(255, 255, 255, 0.02);
  padding: 1.15rem 1.25rem 1.25rem;
  border-radius: 1.2rem;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  text-align: center;
  width: 390px;
  max-width: 90%;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
  opacity: 0;
  transform: translateY(12px) scale(0.985);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}

.auth-welcome {
  margin: 0 0 0.25rem;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 650;
}

.auth-registration-hint {
  margin: 0 0 0.7rem;
  color: #64748b;
  font-size: 0.7rem;
  line-height: 1.35;
}

.auth-legal-consent {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  margin: 0 2px 0.45rem;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.69rem;
  line-height: 1.4;
  text-align: left;
}

.auth-legal-consent input {
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: #2563eb;
  cursor: pointer;
}

.auth-legal-consent a,
.auth-legal-summary a {
  color: #93c5fd;
  font-weight: 700;
  text-underline-offset: 2px;
}

.auth-legal-summary {
  margin: 0 3px 0.55rem;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.64rem;
  line-height: 1.35;
  text-align: left;
}

.auth-legal-consent.has-error {
  color: #fecaca;
}

.auth-method-panel.hidden {
  display: none;
}

#auth-modal-card[data-auth-method='social'],
#auth-modal-card[data-auth-method='credentials'] {
  width: 360px;
  padding: 1rem 1.15rem 1.1rem;
}

.auth-method-switch,
.auth-method-back {
  border: 0;
  background: transparent;
  color: #bfdbfe;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.auth-method-switch {
  min-height: 34px;
  margin: 6px auto -3px;
  padding: 5px 10px;
  font-size: 0.73rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-method-switch:hover,
.auth-method-back:hover {
  color: #ffffff;
}

.auth-method-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 auto 8px 0;
  padding: 3px 0;
  font-size: 0.72rem;
}

.auth-method-back .material-symbols-outlined {
  font-size: 17px;
}

.auth-credentials-title {
  margin: 0 0 0.75rem;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.86rem;
  font-weight: 750;
}

.social-login-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.social-login-buttons.hidden,
.identity-claim-panel.hidden,
.identity-reminder.hidden {
  display: none;
}

.social-login-btn {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.92);
  color: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-sizing: border-box;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.social-login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.1);
}

.social-login-btn.is-unavailable {
  cursor: not-allowed;
  filter: grayscale(0.45);
  opacity: 0.56;
}

.social-login-btn.is-unavailable:hover {
  transform: none;
  box-shadow: none;
}

.social-login-btn--facebook {
  border-color: #1877f2;
  background: #1877f2;
  color: #ffffff;
}

.social-provider-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ffffff;
  font-family: Arial, sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
}

.social-provider-mark--google {
  border: 1px solid #e2e8f0;
  color: #4285f4;
}

.social-provider-mark--facebook {
  color: #1877f2;
}

.social-login-status {
  margin: 1px 4px 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.67rem;
  line-height: 1.35;
}

.social-login-status.hidden {
  display: none;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  color: #64748b;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(100, 116, 139, 0.25);
}

.identity-claim-panel {
  text-align: left;
}

#auth-modal[data-auth-screen='identity'] #auth-modal-card {
  min-height: 0;
  max-height: 100%;
  justify-content: flex-start;
  overflow: hidden;
}

#auth-modal[data-auth-screen='identity'] .identity-claim-panel {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 12px 96px;
  -webkit-overflow-scrolling: touch;
}

.identity-back-btn,
.identity-skip-btn {
  border: 0;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font: inherit;
}

.identity-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: -4px 0 12px;
  padding: 4px 0;
  font-size: 0.78rem;
}

.identity-back-btn .material-symbols-outlined {
  font-size: 18px;
}

.identity-claim-heading {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.identity-claim-heading > .material-symbols-outlined {
  color: #d97706;
  font-size: 28px;
}

.identity-claim-heading h3 {
  margin: 0;
  color: #0f172a;
  font-family: var(--font-fancy);
  font-size: 1.16rem;
}

.identity-claim-heading p {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 0.76rem;
  line-height: 1.4;
}

.identity-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.identity-form-grid label,
.identity-notes-label {
  color: #475569;
  font-size: 0.7rem;
  font-weight: 650;
}

.identity-form-grid input,
.identity-form-grid select,
.identity-notes-label textarea {
  width: 100%;
  min-height: 40px;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.9);
  color: #1e293b;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.82rem;
}

.identity-form-grid input:focus,
.identity-form-grid select:focus,
.identity-notes-label textarea:focus {
  border-color: #d97706;
  outline: none;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.12);
}

.identity-notes-label {
  display: block;
  margin-top: 8px;
}

.identity-notes-label textarea {
  min-height: 56px;
  resize: vertical;
}

.identity-claim-error {
  min-height: 16px;
  margin: 6px 0;
  color: #b91c1c;
  font-size: 0.72rem;
  text-align: center;
}

.identity-skip-btn {
  display: block;
  width: 100%;
  padding: 10px 0 0;
  font-size: 0.78rem;
  text-align: center;
}

.identity-reminder {
  position: fixed;
  top: calc(var(--app-header-height, 70px) + 10px);
  left: 50%;
  z-index: 1050;
  width: min(620px, calc(100% - 24px));
  min-height: 54px;
  padding: 9px 10px 9px 14px;
  border: 1px solid #fed7aa;
  border-radius: 14px;
  background: rgba(255, 251, 235, 0.96);
  box-shadow: 0 10px 28px rgba(120, 53, 15, 0.13);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  box-sizing: border-box;
}

.identity-reminder__icon {
  color: #c2410c;
  font-size: 24px;
}

.identity-reminder__copy {
  min-width: 0;
}

.identity-reminder__copy strong,
.identity-reminder__copy span {
  display: block;
}

.identity-reminder__copy strong {
  color: #7c2d12;
  font-size: 0.8rem;
}

.identity-reminder__copy span {
  margin-top: 1px;
  color: #9a3412;
  font-size: 0.7rem;
  line-height: 1.3;
}

#identity-reminder-btn {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: #0f172a;
  color: #ffffff;
  cursor: pointer;
  font-size: 0.73rem;
  font-weight: 750;
}

.auth-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
  transition:
    transform 0.2s ease,
    background 0.2s ease;
  z-index: 3;
}

.auth-modal-close:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.92);
}

body.auth-active #auth-modal-card {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#auth-modal-card::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 150%;
  height: 150%;
  background-image: url('../logo_2.png');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.05;
  z-index: -1;
  pointer-events: none;
}

.auth-branding-wrapper {
  margin-bottom: 0.65rem;
}

#auth-modal-card h2 {
  margin-top: 0;
  margin-bottom: 0px;
  letter-spacing: 0.02em;
  line-height: 1;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 4px;
}

#auth-modal-card .auth-subtitle {
  margin-top: 2px;
  margin-bottom: 0;
  color: #475569;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

#auth-modal-card .brand-aquino {
  font-size: 1.8rem;
  color: #d97706;
  display: inline-block;
}

#auth-modal-card .brand-tree {
  font-size: 2.2rem;
  color: #0f172a;
  line-height: 0.9;
  font-family: 'Playfair Display', serif;
  font-style: italic;
}

.auth-icon {
  margin-bottom: 0.75rem;
  display: block;
  font-size: 24px;
  color: rgba(15, 23, 42, 0.6);
}

.auth-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 0.55rem;
  width: 100%;
}

#admin-username,
#admin-password {
  width: 100%;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #1e293b;
  border-radius: 0.75rem;
  box-sizing: border-box;
  font-size: 0.95rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

#admin-username:focus,
#admin-password:focus {
  border-color: #d97706;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.15);
  outline: none;
  transform: translateY(-1px);
}

#login-btn {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  background: #1e293b;
  color: white;
  border: none;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#login-btn:hover {
  background: #0f172a;
  transform: translateY(-1px);
  box-shadow: 0 6px 15px rgba(15, 23, 42, 0.3);
}

#login-btn:disabled {
  cursor: not-allowed;
  opacity: 0.8;
}

/* Auth States */
#login-btn.btn-error {
  background: #ef4444;
  color: white;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
  animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

#login-btn.btn-success {
  background: #16a34a;
  color: white;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.auth-error-msg {
  display: none; /* Hidden as we use button feedback now */
}

.auth-error-msg.show-error {
  visibility: visible;
  opacity: 1;
}

/* Mobile Fixes */
@media (max-width: 480px) {
  #auth-modal-card {
    width: 100%;
    max-width: 100%;
    padding: 1rem;
  }
  #auth-modal {
    justify-content: center;
    padding: 0.75rem;
  }

  #auth-modal[data-auth-screen='identity'] {
    top: var(--app-visual-viewport-offset-top, 0px);
    bottom: auto;
    height: var(--app-visual-viewport-height, 100dvh);
    min-height: 0;
    justify-content: flex-start;
    align-items: stretch;
    padding: max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  #auth-modal[data-auth-screen='identity'] #auth-modal-card {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    padding: 0.75rem 0.5rem 0.65rem 0.85rem;
  }

  #auth-modal[data-auth-screen='identity'] .identity-claim-panel {
    padding: 2px calc(0.35rem + env(safe-area-inset-right))
      calc(1rem + env(safe-area-inset-bottom)) 0;
  }

  #auth-modal[data-auth-screen='identity'] .identity-back-btn {
    margin-top: 0;
    padding-right: 48px;
  }

  .identity-form-grid {
    grid-template-columns: 1fr;
  }

  .identity-reminder {
    top: calc(var(--app-header-height, 70px) + 6px);
    grid-template-columns: 24px minmax(0, 1fr);
    padding: 9px 11px;
  }

  #identity-reminder-btn {
    grid-column: 2;
    justify-self: start;
  }
}

@media (max-height: 600px) {
  #auth-modal {
    padding: 0.5rem;
  }

  #auth-modal-card {
    padding: 0.7rem 1rem;
  }

  .auth-branding-wrapper {
    margin-bottom: 0.25rem;
  }

  #auth-modal-card .auth-subtitle,
  .auth-registration-hint,
  .auth-legal-summary,
  .social-login-status {
    display: none;
  }

  #auth-modal-card .brand-aquino {
    font-size: 1.45rem;
  }

  #auth-modal-card .brand-tree {
    font-size: 1.75rem;
  }

  .auth-welcome {
    margin-bottom: 0.25rem;
    font-size: 0.78rem;
  }

  .social-login-buttons,
  .auth-input-group {
    gap: 5px;
  }

  .social-login-btn {
    min-height: 38px;
  }

  .auth-divider {
    margin: 5px 0;
  }

  #admin-username,
  #admin-password {
    padding-block: 8px;
  }

  .auth-input-group {
    margin-bottom: 0.4rem;
  }

  #login-btn {
    height: 40px;
  }
}

/* Header/Footer Transparency when Auth is active */
body:has(#auth-modal:not(.hidden)) {
  --header-surface: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.14),
    rgba(255, 255, 255, 0.06)
  );
  --header-border-color: rgba(255, 255, 255, 0.18);
  --header-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --header-backdrop-filter: blur(18px) saturate(145%);
  --footer-surface: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.14),
    rgba(255, 255, 255, 0.06)
  );
  --footer-border-color: rgba(255, 255, 255, 0.18);
  --footer-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --footer-backdrop-filter: blur(18px) saturate(145%);
}
