/* Auth modals — login / register / forgot password */

.auth-modal-overlay {
    padding: 1rem;
}

.auth-modal {
    width: 100%;
    max-width: 440px;
    max-height: min(92vh, 820px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 1.25rem;
    background: #fff;
    box-shadow:
        0 25px 50px -12px rgb(0 0 0 / 0.25),
        0 0 0 1px rgb(0 0 0 / 0.04);
}

.dark .auth-modal {
    background: #1a1d2d;
    box-shadow:
        0 25px 50px -12px rgb(0 0 0 / 0.5),
        0 0 0 1px rgb(255 255 255 / 0.06);
}

/* Cuộn trong body, không hiện thanh scroll */
.auth-modal--scroll {
    overflow: hidden;
}

.auth-modal--scroll .auth-modal__body {
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.auth-modal--scroll .auth-modal__body::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.auth-modal__header {
    position: relative;
    flex-shrink: 0;
    padding: 1.25rem 1.25rem 0;
    background: linear-gradient(145deg, var(--color-primary, #b00010) 0%, #8a000c 100%);
    color: #fff;
}

.auth-modal__header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.auth-modal__brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
}

.auth-modal__logo {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.625rem;
    object-fit: contain;
    background: #fff;
    padding: 0.25rem;
    flex-shrink: 0;
}

.auth-modal__logo-fallback {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.625rem;
    background: #fff;
    color: var(--color-primary, #b00010);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.auth-modal__site-name {
    font-size: 0.9375rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-modal__tagline {
    font-size: 0.6875rem;
    opacity: 0.85;
    font-weight: 500;
}

.auth-modal__close {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgb(255 255 255 / 0.12);
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-modal__close:hover {
    background: rgb(255 255 255 / 0.22);
}

.auth-modal__tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem;
    padding: 0.25rem;
    margin: 0 -0.25rem;
    background: rgb(0 0 0 / 0.15);
    border-radius: 0.75rem 0.75rem 0 0;
}

.auth-modal__tab {
    border: none;
    cursor: pointer;
    padding: 0.6875rem 1rem;
    font-size: 0.875rem;
    font-weight: 700;
    border-radius: 0.5rem 0.5rem 0 0;
    color: rgb(255 255 255 / 0.75);
    background: transparent;
    transition: color 0.2s, background 0.2s;
}

.auth-modal__tab:hover:not(.is-active) {
    color: #fff;
    background: rgb(255 255 255 / 0.08);
}

.auth-modal__tab.is-active {
    color: var(--color-primary, #b00010);
    background: #fff;
}

.dark .auth-modal__tab.is-active {
    background: #1a1d2d;
    color: #f87171;
}

.auth-modal__body {
    padding: 1.5rem 1.25rem 1.25rem;
    flex: 1;
    min-height: 0;
}

@media (min-width: 480px) {
    .auth-modal__body {
        padding: 1.75rem 1.5rem 1.5rem;
    }
}

.auth-modal__form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-modal__field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.auth-modal__label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #334155;
}

.dark .auth-modal__label {
    color: #e2e8f0;
}

.auth-modal__input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-modal__input-icon {
    position: absolute;
    left: 0.875rem;
    font-size: 1.25rem;
    color: #94a3b8;
    pointer-events: none;
}

.auth-modal__input {
    width: 100%;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    padding: 0.75rem 2.75rem 0.75rem 2.75rem;
    font-size: 0.875rem;
    color: #0f172a;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.auth-modal__input::placeholder {
    color: #94a3b8;
}

.auth-modal__input:focus {
    border-color: var(--color-primary, #b00010);
    background: #fff;
    box-shadow: 0 0 0 3px rgb(176 0 16 / 0.12);
}

.dark .auth-modal__input {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

.dark .auth-modal__input:focus {
    background: #1e293b;
    box-shadow: 0 0 0 3px rgb(248 113 113 / 0.15);
}

.auth-modal__input.is-valid {
    border-color: #22c55e;
}

.auth-modal__input.is-invalid {
    border-color: #ef4444;
}

.auth-modal__toggle-pw {
    position: absolute;
    right: 0.5rem;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}

.auth-modal__toggle-pw:hover {
    color: var(--color-primary, #b00010);
    background: rgb(176 0 16 / 0.06);
}

.auth-modal__rules {
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    background: #f8fafc;
    border: 1px dashed #e2e8f0;
}

.dark .auth-modal__rules {
    background: #0f172a;
    border-color: #334155;
}

.auth-modal__rules-title {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    letter-spacing: 0.02em;
}

.dark .auth-modal__rules-title {
    color: #94a3b8;
}

.auth-modal__rules-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.auth-modal__rule {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: #64748b;
    transition: color 0.2s;
}

.dark .auth-modal__rule {
    color: #94a3b8;
}

.auth-modal__rule .material-symbols-outlined {
    font-size: 1.125rem;
    flex-shrink: 0;
    margin-top: 0.0625rem;
    color: #cbd5e1;
    transition: color 0.2s;
}

.auth-modal__rule.is-met {
    color: #15803d;
}

.dark .auth-modal__rule.is-met {
    color: #4ade80;
}

.auth-modal__rule.is-met .material-symbols-outlined {
    color: #22c55e;
}

.auth-modal__submit {
    width: 100%;
    border: none;
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #fff;
    background: var(--color-primary, #b00010);
    box-shadow: 0 4px 14px rgb(176 0 16 / 0.35);
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.auth-modal__submit:hover:not(:disabled) {
    background: color-mix(in srgb, var(--color-primary, #b00010) 88%, #000);
}

.auth-modal__submit:active:not(:disabled) {
    transform: scale(0.98);
}

.auth-modal__submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.auth-modal__message {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.5;
}

.auth-modal__message.is-success {
    background: #ecfdf5;
    border: 1px solid #86efac;
    color: #166534;
}

.auth-modal__message.is-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.dark .auth-modal__message.is-success {
    background: rgb(22 101 52 / 0.2);
    border-color: #22c55e;
    color: #86efac;
}

.dark .auth-modal__message.is-error {
    background: rgb(127 29 29 / 0.25);
    border-color: #f87171;
    color: #fecaca;
}

.auth-modal__divider {
    position: relative;
    margin: 1.25rem 0;
    text-align: center;
}

.auth-modal__divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: #e2e8f0;
}

.dark .auth-modal__divider::before {
    background: #334155;
}

.auth-modal__divider span {
    position: relative;
    padding: 0 0.75rem;
    font-size: 0.75rem;
    color: #64748b;
    background: #fff;
}

.dark .auth-modal__divider span {
    background: #1a1d2d;
    color: #94a3b8;
}

.auth-modal__social {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.auth-modal__social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.6875rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.auth-modal__social-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.dark .auth-modal__social-btn {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

.dark .auth-modal__social-btn:hover {
    background: #1e293b;
}

.auth-modal__footer-text {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.8125rem;
    color: #64748b;
}

.auth-modal__link {
    color: var(--color-primary, #b00010);
    font-weight: 700;
    text-decoration: none;
}

.auth-modal__link:hover {
    text-decoration: underline;
}

.auth-modal__forgot {
    text-align: right;
}

.auth-modal__forgot .auth-modal__link {
    font-size: 0.8125rem;
    font-weight: 600;
}

/* —— Modal open / close / switch —— */
.modal-overlay .modal-backdrop {
    opacity: 0;
    transition: opacity 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity;
}

.modal-overlay.is-open .modal-backdrop {
    opacity: 1;
}

.modal-overlay .modal-content {
    opacity: 0;
    transform: scale(0.96) translate3d(0, 10px, 0);
    transition:
        opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.modal-overlay.is-open .modal-content {
    opacity: 1;
    transform: scale(1) translate3d(0, 0, 0);
}

.auth-modal__tab {
    transition:
        color 0.25s ease,
        background 0.25s ease,
        transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-modal__tab.is-active {
    transform: translateY(-1px);
}

.auth-modal__rule .material-symbols-outlined {
    transition:
        color 0.28s ease,
        transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.auth-modal__rule.is-met .material-symbols-outlined {
    transform: scale(1.08);
}

.auth-modal__message:not(.hidden) {
    animation: auth-modal-message-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes auth-modal-message-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .modal-overlay .modal-backdrop,
    .modal-overlay .modal-content {
        transition-duration: 0.01ms;
    }

    .auth-modal__message:not(.hidden) {
        animation: none;
    }

    .auth-modal__tab.is-active {
        transform: none;
    }
}
