/* ==========================================================================
   Auth layout dùng chung cho /login và /register
   Bám theo theme chính (css/home.css): font Saira, bo góc --ui-radius,
   màu nhấn --ui-accent, nền lưới, dark mode theo [data-color-mode="dark"].
   ========================================================================== */

.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--ui-page);
    background-image: linear-gradient(90deg, rgba(238, 241, 245, .6) 1px, transparent 1px), linear-gradient(rgba(238, 241, 245, .6) 1px, transparent 1px);
    background-size: 50px 50px, 50px 50px;
    color: var(--ui-text);
}

/* ---------- Thanh trên cùng ---------- */
.auth-topbar {
    width: min(calc(100% - 51px), var(--ui-max));
    margin: 0 auto;
    padding: 22px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    text-decoration: none;
}

.auth-brand-logo {
    display: block;
    width: auto;
    max-width: 190px;
    height: 46px;
    object-fit: contain;
}

.auth-brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    flex: 0 0 46px;
    border-radius: 14px;
    background: var(--ui-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .5px;
}

.auth-brand-name {
    color: var(--ui-text);
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.auth-icon-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--ui-border-strong);
    border-radius: 999px;
    background: #fff;
    color: #475569;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.auth-icon-button svg {
    width: 17px;
    height: 17px;
}

.auth-icon-button:hover {
    background: #f1f5f9;
    border-color: rgba(14, 87, 54, .3);
    color: var(--ui-accent);
}

.auth-topbar-link {
    height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 14px;
    border: 1px solid var(--ui-border-strong);
    border-radius: 999px;
    background: #fff;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.auth-topbar-link svg {
    width: 15px;
    height: 15px;
}

.auth-topbar-link:hover {
    background: #f1f5f9;
    border-color: rgba(14, 87, 54, .3);
    color: var(--ui-accent);
}

/* ---------- Khung chính ---------- */
.auth-wrap {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 26px 25.5px 40px;
}

.auth-shell {
    width: min(100%, 1120px);
    margin: auto 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.06fr);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow);
    overflow: hidden;
}

/* ---------- Cột giới thiệu ---------- */
.auth-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 42px 38px;
    color: #fff;
    background: linear-gradient(158deg, #0e5736 0%, #0a4429 58%, #073020 100%);
    overflow: hidden;
}

.auth-aside::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px);
    background-size: 34px 34px;
    pointer-events: none;
}

.auth-aside > * {
    position: relative;
    z-index: 1;
}

.auth-aside-badge {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 13px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .16);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.1px;
}

.auth-aside-badge svg {
    width: 14px;
    height: 14px;
}

.auth-aside-title {
    color: #fff;
    font-size: 30px;
    line-height: 38px;
    font-weight: 800;
    letter-spacing: -.6px;
}

.auth-aside-text {
    color: rgba(255, 255, 255, .82);
    font-size: 15px;
    line-height: 24px;
}

.auth-feature-list {
    display: grid;
    gap: 13px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.auth-feature-list li {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    color: rgba(255, 255, 255, .92);
    font-size: 14px;
    line-height: 21px;
}

.auth-feature-icon {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, .14);
    color: #8ee7b7;
}

.auth-feature-icon svg {
    width: 13px;
    height: 13px;
}

.auth-hashtags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
}

.auth-tag {
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: rgba(255, 255, 255, .1);
    color: rgba(255, 255, 255, .78);
    font-size: 11.5px;
    font-weight: 600;
}

/* ---------- Cột form ---------- */
.auth-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    padding: 42px 44px;
}

.auth-panel-head {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.auth-eyebrow {
    color: var(--ui-accent);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.3px;
}

.auth-panel-title {
    color: var(--ui-text);
    font-size: 26px;
    line-height: 34px;
    font-weight: 800;
    letter-spacing: -.4px;
}

.auth-panel-subtitle {
    color: var(--ui-muted);
    font-size: 14px;
    line-height: 21px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.auth-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--ui-text);
    font-size: 13px;
    font-weight: 600;
}

.auth-label-hint {
    color: var(--ui-muted);
    font-size: 11.5px;
    font-weight: 500;
}

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

.auth-input {
    width: 100%;
    min-height: 46px;
    padding: 11px 14px;
    border: 1px solid var(--ui-border-strong);
    border-radius: 12px;
    background: #fff;
    color: var(--ui-text);
    font-size: 15px;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}

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

.auth-input:focus {
    border-color: var(--ui-accent);
    box-shadow: 0 0 0 3px rgba(14, 87, 54, .13);
}

.auth-input.has-icon {
    padding-left: 40px;
}

.auth-input.has-toggle {
    padding-right: 74px;
}

.auth-input.is-invalid {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

.auth-input-icon {
    position: absolute;
    left: 13px;
    display: grid;
    place-items: center;
    color: #94a3b8;
    pointer-events: none;
}

.auth-input-icon svg {
    width: 17px;
    height: 17px;
}

.auth-toggle {
    position: absolute;
    right: 7px;
    height: 32px;
    padding: 0 11px;
    border: 0;
    border-radius: 9px;
    background: #f1f5f9;
    color: #475569;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    transition: background .18s ease, color .18s ease;
}

.auth-toggle:hover {
    background: #e2e8f0;
    color: var(--ui-accent);
}

.auth-field-error {
    display: none;
    color: #dc2626;
    font-size: 12px;
    font-weight: 600;
}

.auth-field-error.is-visible {
    display: block;
}

/* ---------- Nút bấm ---------- */
.auth-submit {
    width: 100%;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 0;
    border-radius: 12px;
    background: var(--ui-accent);
    color: #fff;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    transition: background .18s ease, opacity .18s ease;
}

.auth-submit:hover {
    background: #0a452a;
}

.auth-submit:disabled {
    opacity: .65;
    cursor: not-allowed;
}

.auth-submit .auth-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    animation: auth-spin .7s linear infinite;
}

.auth-submit.is-loading .auth-spinner {
    display: block;
}

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

/* ---------- Thông báo ---------- */
.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 20px;
}

.auth-alert-icon {
    flex: 0 0 auto;
    margin-top: 1px;
}

.auth-alert-icon svg {
    width: 16px;
    height: 16px;
}

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

.auth-alert.is-success {
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #15803d;
}

/* ---------- Liên kết chuyển trang & ghi chú ---------- */
.auth-alt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--ui-muted);
    font-size: 13.5px;
}

.auth-alt a {
    color: var(--ui-accent);
    font-weight: 700;
    text-decoration: none;
}

.auth-alt a:hover {
    text-decoration: underline;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
    .auth-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .auth-aside {
        padding: 30px 26px;
        gap: 16px;
    }

    .auth-aside-title {
        font-size: 24px;
        line-height: 32px;
    }

    .auth-feature-list,
    .auth-hashtags {
        display: none;
    }

    .auth-panel {
        padding: 34px 28px;
    }
}

@media (max-width: 620px) {
    .auth-topbar {
        width: calc(100% - 24px);
        padding-top: 14px;
    }

    .auth-brand-logo {
        max-width: 130px;
        height: 38px;
    }

    .auth-brand-mark {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
        border-radius: 12px;
    }

    .auth-brand-name {
        font-size: 16px;
    }

    .auth-topbar-link {
        padding: 0 11px;
        font-size: 12px;
    }

    .auth-wrap {
        padding: 18px 12px 28px;
    }

    .auth-aside {
        padding: 24px 20px;
    }

    .auth-aside-title {
        font-size: 21px;
        line-height: 28px;
    }

    .auth-aside-text {
        font-size: 14px;
        line-height: 22px;
    }

    .auth-panel {
        padding: 26px 20px;
        gap: 18px;
    }

    .auth-panel-title {
        font-size: 22px;
        line-height: 30px;
    }

    .auth-input {
        min-height: 48px;
        font-size: 16px;
    }
}

/* ---------- Dark mode ---------- */
[data-color-mode="dark"] .auth-page {
    background-image: none;
    background-color: var(--ui-page);
}

[data-color-mode="dark"] .auth-shell {
    background: var(--ui-surface);
}

[data-color-mode="dark"] .auth-icon-button,
[data-color-mode="dark"] .auth-topbar-link {
    background: var(--ui-surface);
    border-color: var(--ui-border-strong);
    color: var(--ui-muted);
}

[data-color-mode="dark"] .auth-icon-button:hover,
[data-color-mode="dark"] .auth-topbar-link:hover {
    background: var(--ui-page);
    color: var(--ui-accent);
}

[data-color-mode="dark"] .auth-input {
    background: var(--ui-page);
    border-color: var(--ui-border-strong);
    color: var(--ui-text);
}

[data-color-mode="dark"] .auth-toggle {
    background: #2b3230;
    color: var(--ui-muted);
}

[data-color-mode="dark"] .auth-toggle:hover {
    background: #38403d;
    color: var(--ui-dark-positive);
}

[data-color-mode="dark"] .auth-alert.is-error {
    border-color: rgba(255, 159, 169, .4);
    background: rgba(255, 159, 169, .12);
    color: var(--ui-dark-negative);
}

[data-color-mode="dark"] .auth-alert.is-success {
    border-color: rgba(139, 217, 177, .4);
    background: rgba(139, 217, 177, .12);
    color: var(--ui-dark-positive);
}

[data-color-mode="dark"] .auth-field-error {
    color: var(--ui-dark-negative);
}
