/* =====================================================
   USER LAYOUT - GLOBAL
   Header/Footer style banchuasach
===================================================== */

:root {
    --user-blue: #002045;
    --user-blue-light: #083765;
    --user-gold: #8a7600;
    --user-gold-soft: #efe3bd;
    --user-bg: #f8f3e8;
    --user-bg-soft: #fffdf7;
    --user-border: #ded3bd;
    --user-text: #172033;
    --user-muted: #7a8290;
    --user-white: #ffffff;
    --user-danger: #b42318;
    --user-shadow: 0 14px 34px rgba(64, 50, 22, 0.10);
    --user-shadow-soft: 0 8px 22px rgba(0, 32, 69, 0.06);
    --rl-font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
}

body.user-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--user-bg);
    color: var(--user-text);
    font-family: var(--rl-font);
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

button {
    cursor: pointer;
}

.uni-container {
    width: min(1240px, calc(100% - 40px));
    margin: 0 auto;
}

/* =====================================================
   HEADER
===================================================== */

.uni-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 64px;
    border-bottom: 1px solid #e7dcc7;
    background: rgba(255, 253, 248, 0.96);
    backdrop-filter: blur(12px);
}

.uni-header-inner {
    height: 64px;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 310px;
    align-items: center;
    gap: 18px;
}

.uni-brand {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--user-blue);
    text-decoration: none;
}

.uni-brand-mark {
    width: 58px;
    height: 46px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.uni-brand-mark.has-logo {
    width: 58px;
    height: 46px;
}

.uni-brand-mark.is-fallback {
    width: 38px;
    height: 38px;
}

.uni-logo-img {
    max-width: 58px;
    max-height: 46px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.uni-logo-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--user-blue);
    font-size: 32px;
    font-weight: 300;
    line-height: 1;
}

.uni-brand-text {
    min-width: 0;
    display: grid;
    gap: 1px;
}

.uni-brand-text strong {
    max-width: 230px;
    color: var(--user-blue);
    font-size: 16px;
    font-weight: 780;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uni-brand-text small {
    max-width: 240px;
    color: #8a8172;
    font-size: 11px;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uni-nav {
    height: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
}

.uni-nav a {
    position: relative;
    height: 100%;
    display: inline-flex;
    align-items: center;
    color: #4f5967;
    font-size: 13px;
    font-weight: 650;
    white-space: nowrap;
    text-decoration: none;
    transition: color 0.16s ease;
}

.uni-nav a::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 0;
    height: 3px;
    border-radius: 999px 999px 0 0;
    background: var(--user-gold);
    transform: translateX(-50%);
    transition: width 0.16s ease;
}

.uni-nav a:hover,
.uni-nav a.active {
    color: var(--user-blue);
}

.uni-nav a.active::after {
    width: 64px;
}

.uni-header-actions {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.uni-login-btn {
    min-height: 38px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 9px;
    background: var(--user-blue);
    color: #fffdf7;
    font-size: 13px;
    font-weight: 750;
    text-decoration: none;
    box-shadow: 0 10px 22px rgba(0, 32, 69, 0.14);
    transition: background 0.18s ease, box-shadow 0.18s ease;
}

.uni-login-btn .material-symbols-outlined {
    font-size: 18px;
    font-weight: 300;
}

.uni-login-btn:hover {
    background: var(--user-gold);
    box-shadow: 0 12px 26px rgba(138, 118, 0, 0.22);
}

.uni-user-profile {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
}

.uni-user-mini {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--user-text);
    text-decoration: none;
}

.uni-avatar-wrap {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    position: relative;
}

.uni-avatar-img,
.avatar-placeholder {
    width: 34px;
    height: 34px;
    border-radius: 50%;
}

.uni-avatar-img {
    object-fit: cover;
    display: block;
}

.avatar-placeholder {
    display: grid;
    place-items: center;
    background: #00897b;
    color: #ffffff;
    font-size: 14px;
    font-weight: 780;
}

.user-meta {
    min-width: 0;
    display: grid;
    gap: 1px;
}

.user-meta strong {
    max-width: 165px;
    color: var(--user-text);
    font-size: 12.4px;
    font-weight: 780;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-meta small {
    max-width: 180px;
    color: #8a929d;
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uni-logout-form {
    margin: 0;
}

.uni-logout-form button {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid #f0cccc;
    border-radius: 8px;
    background: #fff7f7;
    color: #d04b4b;
    cursor: pointer;
    transition: 0.16s ease;
}

.uni-logout-form button:hover {
    background: #d04b4b;
    color: #ffffff;
}

.uni-logout-form .material-symbols-outlined {
    font-size: 18px;
    font-weight: 250;
}

/* =====================================================
   MAIN
===================================================== */

.uni-main {
    flex: 1 0 auto;
    display: block;
    background: var(--user-bg);
}

/* =====================================================
   TOAST
===================================================== */

.user-toast {
    position: fixed;
    top: 78px;
    right: 24px;
    z-index: 300;
    min-width: 280px;
    max-width: 420px;
    padding: 13px 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid var(--user-border);
    box-shadow: var(--user-shadow);
}

.toast-content {
    display: flex;
    gap: 9px;
}

.toast-content .material-symbols-outlined {
    font-size: 20px;
    font-weight: 250;
}

.user-toast.success .material-symbols-outlined {
    color: #16844a;
}

.user-toast.error .material-symbols-outlined {
    color: #b42318;
}

.user-toast.warning .material-symbols-outlined {
    color: var(--user-gold);
}

.toast-text {
    color: var(--user-text);
    font-size: 13px;
    line-height: 1.45;
}

.toast-text a {
    color: var(--user-blue);
    font-weight: 650;
    text-decoration: underline;
}

.toast-close {
    border: 0;
    background: transparent;
    color: #8a929d;
    font-size: 18px;
    line-height: 1;
}

/* =====================================================
   FOOTER
===================================================== */

.uni-footer {
    flex-shrink: 0;
    padding: 42px 0 18px;
    background: var(--user-blue);
    color: #fffdf7;
}

.uni-footer-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.85fr 0.85fr 0.85fr;
    gap: 38px;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.footer-logo-img {
    max-width: 58px;
    max-height: 58px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.footer-logo-fallback {
    color: #d8bf38;
    font-size: 32px;
    font-weight: 300;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.footer-logo h3 {
    max-width: 260px;
    margin: 0;
    color: #fffdf7;
    font-size: 17px;
    font-weight: 750;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.footer-desc {
    max-width: 360px;
    margin: 13px 0 0;
    color: rgba(255, 253, 247, 0.72);
    font-size: 12.8px;
    line-height: 1.7;
    white-space: normal;
}

.footer-links-col h4 {
    margin: 0 0 12px;
    color: #fffdf7;
    font-size: 13.5px;
    font-weight: 750;
}

.footer-contact-list,
.footer-time-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 9px;
}

.footer-contact-list li {
    display: flex;
    align-items: center;
    gap: 7px;
    color: rgba(255, 253, 247, 0.72);
    font-size: 12.5px;
}

.footer-contact-list .material-symbols-outlined {
    color: #d8bf38;
    font-size: 17px;
    font-weight: 250;
}

.footer-time-list li {
    color: rgba(255, 253, 247, 0.72);
    font-size: 12.5px;
}

.footer-quick-links {
    display: grid;
    gap: 8px;
}

.footer-quick-links a {
    color: rgba(255, 253, 247, 0.72);
    font-size: 12.5px;
    transition: 0.18s ease;
}

.footer-quick-links a:hover {
    color: #fffdf7;
    text-decoration: underline;
}

.uni-footer-bottom {
    margin-top: 30px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.uni-footer-bottom p {
    margin: 0;
    color: rgba(255, 253, 247, 0.62);
    font-size: 12px;
}

.footer-contact-list li span:last-child,
.footer-time-list li,
.footer-quick-links a {
    overflow-wrap: anywhere;
}

/* =====================================================
   CHATBOX
===================================================== */

.chatbox-widget {
    position: fixed;
    right: 18px;
    bottom: 6px;
    z-index: 250;
    font-family: var(--rl-font);
}

.chatbox-widget.is-open .chatbox-toggle {
    display: none !important;
}

.chatbox-toggle {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    background: var(--user-blue);
    color: #fffdf7;
    box-shadow: 0 14px 32px rgba(0, 32, 69, 0.22);
    transition: 0.18s ease;
}

.chatbox-toggle:hover,
.chatbox-toggle.is-active {
    background: var(--user-gold);
}

.chatbox-toggle .material-symbols-outlined {
    font-size: 24px;
    font-weight: 300;
}

.chatbox-panel {
    position: absolute;
    right: 0;
    bottom: 40px;
    width: 390px;
    max-width: calc(100vw - 24px);
    height: 610px;
    max-height: calc(100vh - 58px);
    display: none;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border: 1px solid #d9cfbb;
    background: #fffdf8;
    box-shadow: 0 18px 40px rgba(0, 32, 69, 0.16);
}

.chatbox-widget.is-open .chatbox-panel,
.chatbox-panel.is-open {
    display: grid;
}

.chatbox-head {
    min-height: 66px;
    padding: 13px 14px;
    background: var(--user-blue);
    color: #fffdf7;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.chatbox-head strong {
    display: block;
    font-size: 14px;
    font-weight: 760;
}

.chatbox-head span {
    display: block;
    margin-top: 2px;
    color: rgba(255, 253, 247, 0.72);
    font-size: 11.5px;
}

.chatbox-head button {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-size: 20px;
    line-height: 1;
}

.chatbox-body {
    padding: 14px;
    overflow-y: auto;
    background: #fffdf8;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    max-width: 86%;
    padding: 9px 11px;
    border-radius: 14px;
    color: var(--user-text);
    font-size: 13px;
    line-height: 1.45;
}

.chat-message.bot {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    background: #f1eadb;
}

.chat-message.user {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    background: var(--user-blue);
    color: #fffdf7;
}

.chatbox-form {
    padding: 10px;
    border-top: 1px solid #e6dcc9;
    background: #fffdf8;
    display: flex;
    gap: 8px;
}

.chatbox-form input {
    min-width: 0;
    flex: 1;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #d9cfbb;
    border-radius: 999px;
    background: #ffffff;
    color: var(--user-text);
    outline: none;
    font-size: 13px;
}

.chatbox-form input:focus {
    border-color: var(--user-gold);
    box-shadow: 0 0 0 3px rgba(138, 118, 0, 0.08);
}

.chatbox-form button {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--user-blue);
    color: #fffdf7;
    display: grid;
    place-items: center;
}

.chatbox-form button:hover {
    background: var(--user-gold);
}

.chatbox-form button .material-symbols-outlined {
    font-size: 20px;
    font-weight: 250;
}

/* =====================================================
   RESPONSIVE
===================================================== */

@media (max-width: 1100px) {
    .uni-header {
        height: auto;
    }

    .uni-header-inner {
        height: auto;
        min-height: 64px;
        padding: 8px 0;
        grid-template-columns: 260px minmax(0, 1fr) auto;
        gap: 16px;
    }

    .uni-nav {
        gap: 22px;
    }

    .user-meta {
        display: none;
    }

    .uni-footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 820px) {
    .uni-header-inner {
        grid-template-columns: 1fr auto;
    }

    .uni-nav {
        grid-column: 1 / -1;
        height: 42px;
        justify-content: flex-start;
        gap: 22px;
        overflow-x: auto;
    }

    .uni-nav a {
        height: 42px;
        min-height: 42px;
        white-space: nowrap;
    }

    .uni-header-actions {
        justify-content: flex-end;
    }
}

@media (max-width: 560px) {
    .uni-container {
        width: min(100% - 28px, 1240px);
    }

    .uni-brand-text small {
        display: none;
    }

    .uni-brand-mark,
    .uni-brand-mark.has-logo {
        width: 46px;
        height: 38px;
    }

    .uni-logo-img {
        max-width: 46px;
        max-height: 38px;
    }

    .uni-login-btn {
        min-height: 36px;
        padding: 0 15px;
    }

    .uni-footer-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .user-toast {
        left: 14px;
        right: 14px;
        top: 76px;
        min-width: 0;
    }

    .chatbox-widget {
        right: 12px;
        bottom: 8px;
    }

    .chatbox-panel {
        width: calc(100vw - 24px);
        height: min(560px, calc(100vh - 80px));
    }
}
/* =====================================================
   CLEAN RESPONSIVE PATCH - USER GLOBAL
===================================================== */
body.user-page {
    overflow-x: hidden;
}

.uni-header-inner,
.uni-brand,
.uni-nav,
.uni-header-actions,
.uni-footer-grid {
    min-width: 0;
}

.uni-brand-text strong,
.uni-brand-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 980px) {
    .uni-header-inner {
        grid-template-columns: minmax(0, 1fr) auto !important;
        gap: 10px;
    }

    .uni-brand-text {
        max-width: min(58vw, 360px);
    }

    .uni-nav {
        grid-column: 1 / -1;
        width: 100%;
        padding-bottom: 2px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .uni-nav::-webkit-scrollbar {
        display: none;
    }
}

@media (max-width: 560px) {
    .uni-container {
        width: calc(100% - 24px) !important;
    }

    .uni-header-inner {
        min-height: 58px;
        padding-block: 7px;
    }

    .uni-brand {
        gap: 7px;
    }

    .uni-brand-text {
        max-width: calc(100vw - 148px);
    }

    .uni-login-btn,
    .uni-account-btn {
        min-height: 34px;
        padding-inline: 11px;
        font-size: 11.5px;
    }

    .uni-nav {
        gap: 10px;
    }

    .uni-nav a {
        min-width: max-content;
        padding-inline: 3px;
        font-size: 12px;
    }
}

/* =====================================================
   CLEAN MOBILE OVERFLOW GUARD
===================================================== */
@media (max-width: 640px) {
    input,
    select,
    textarea,
    button {
        max-width: 100%;
    }
}

/* =====================================================
   MOBILE HEADER ALIGN FIX
   Đưa avatar + nút đăng xuất lên ngang hàng với tên thư viện
===================================================== */
@media (max-width: 820px) {
    .uni-header-inner {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
        grid-template-areas:
            "brand actions"
            "nav nav";
        align-items: center;
        column-gap: 10px;
        row-gap: 6px;
    }

    .uni-brand {
        grid-area: brand;
        min-width: 0;
    }

    .uni-header-actions {
        grid-area: actions;
        align-self: center;
        justify-self: end;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        min-width: max-content;
    }

    .uni-user-profile {
        display: flex;
        align-items: center;
        gap: 7px;
    }

    .uni-nav {
        grid-area: nav;
        grid-column: auto !important;
        width: 100%;
        height: 40px;
        min-height: 40px;
        align-self: end;
    }
}

@media (max-width: 560px) {
    .uni-header-inner {
        min-height: auto;
        padding-block: 8px 5px;
        row-gap: 8px;
    }

    .uni-brand-text {
        max-width: calc(100vw - 150px) !important;
    }

    .uni-brand-text strong {
        max-width: 100%;
        font-size: 15px;
        line-height: 1.12;
    }

    .uni-brand-mark,
    .uni-brand-mark.has-logo {
        width: 44px;
        height: 36px;
    }

    .uni-logo-img {
        max-width: 44px;
        max-height: 36px;
    }

    .uni-avatar-wrap,
    .uni-avatar-img,
    .avatar-placeholder,
    .uni-logout-form button {
        width: 32px;
        height: 32px;
    }

    .uni-logout-form button {
        border-radius: 9px;
    }

    .uni-nav {
        height: 39px;
        min-height: 39px;
        gap: 13px;
    }

    .uni-nav a {
        height: 39px;
        min-height: 39px;
        padding-inline: 2px;
        font-size: 12.5px;
    }
}

@media (max-width: 390px) {
    .uni-brand-text strong {
        font-size: 14px;
    }

    .uni-brand-text {
        max-width: calc(100vw - 138px) !important;
    }

    .uni-avatar-wrap,
    .uni-avatar-img,
    .avatar-placeholder,
    .uni-logout-form button {
        width: 30px;
        height: 30px;
    }

    .uni-user-profile {
        gap: 6px;
    }
}
