/* Basic modal container covers full viewport */
.modal {
  position: fixed;
  inset: 0;
  display: none; /* toggled via JS */
  z-index: 2000; /* above other UI (e.g., lightbox) */
  font-family: 'FactorB', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

/* Backdrop */
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: saturate(120%) blur(2px);
  animation: modalFadeIn 140ms ease-out;
}

/* Dialog */
.modal__dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(420px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  background: #fff;
  color: #111;
  border-radius: 12px;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 8px 10px -6px rgba(0, 0, 0, 0.1);
  animation: modalSlideIn 180ms cubic-bezier(.2,.8,.2,1);
}

/* Header */
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #eee;
}

.modal__header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

/* Close button */
.modal__close {
  border: none;
  background: transparent;
  color: #666;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 6px;
}
.modal__close:hover {
  background: rgba(0,0,0,0.06);
  color: #111;
}

/* Body */
.modal__body {
  padding: 16px;
}

/* Form elements */
.modal__body form {
  display: grid;
  gap: 10px;
}

.modal__body label {
  font-size: 13px;
  color: #374151;
}

.modal__body input[type="email"],
.modal__body input[type="password"],
.modal__body input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  background: #fff;
  color: #111;
  font-family: 'FactorB', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}
.modal__body input[type="email"]::placeholder,
.modal__body input[type="password"]::placeholder,
.modal__body input[type="text"]::placeholder {
  color: #9ca3af;
}
.modal__body input[type="email"]:focus,
.modal__body input[type="password"]:focus,
.modal__body input[type="text"]:focus {
  border-color: #60a5fa; /* blue-400 */
  box-shadow: 0 0 0 3px rgba(96,165,250,0.35);
}

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

.password-input-wrapper input {
  padding-right: 42px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 10%;
  transform: translateY(-10%);
  background: transparent;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 120ms ease, color 120ms ease;
}

.password-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #374151;
}

.password-toggle:focus {
  outline: 2px solid #ccc;
  outline-offset: 2px;
}

/* Submit button */
.modal__body button[type="submit"]:active {
  transform: translateY(1px);
}

/* Inline message box inside modal */
.modal .message.error,
.modal .message.success {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 6px;
}
.modal .message.error {
  background: #fee2e2; /* red-100 */
  color: #991b1b;      /* red-800 */
  border: 1px solid #fecaca; /* red-200 */
}
.modal .message.success {
  background: #dcfce7; /* green-100 */
  color: #14532d;      /* green-900 */
  border: 1px solid #bbf7d0; /* green-200 */
}

/* Small screen spacing */
@media (max-width: 420px) {
  .modal__dialog {
    width: calc(100vw - 24px);
  }
}

/* Animations */
@keyframes modalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modalSlideIn {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 10px)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .modal__dialog {
    background: #0b0f14;
    color: #e5e7eb;
    border: 1px solid #1f2937;
  }
  .modal__header {
    border-bottom-color: #1f2937;
  }
  .modal__close {
    color: #9ca3af;
  }
  .modal__close:hover {
    background: rgba(255,255,255,0.06);
    color: #f3f4f6;
  }
  .modal__body input[type="email"],
  .modal__body input[type="password"] {
    background: #0b0f14;
    color: #e5e7eb;
    border-color: #1f2937;
  }
  .modal .message.error {
    background: rgba(220,38,38,0.1);
    color: #fecaca;
    border-color: rgba(220,38,38,0.25);
  }
  .modal .message.success {
    background: rgba(34,197,94,0.08);
    color: #bbf7d0;
    border-color: rgba(34,197,94,0.25);
  }
}

#btn-open-login {
    appearance: none;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #111827;
    color: #fff;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 120ms ease, transform 40ms ease-in-out, border-color 120ms ease;
}
#btn-open-login:hover {
    background: #0f172a;
    border-color: #cbd5e1;
}
#btn-open-login:active {
    transform: translateY(1px);
}
@media (prefers-color-scheme: dark) {
    #btn-open-login {
        background: #111827;
        border-color: #1f2937;
        color: #e5e7eb;
    }

    #btn-open-login:hover {
        background: #0b0f14;
        border-color: #334155;
    }
}
