/* ============================================
 * Navbar Component Styles — Semi Design System
 * Depends on base.css
 * Top horizontal navigation (converted from sidebar)
 * ============================================ */

/* --- Navbar Variables (always dark) --- */
:root {
    --navbar-bg: #16161A;
    --navbar-fill: rgba(255, 255, 255, 0.08);
    --navbar-border: rgba(255, 255, 255, 0.08);
}

.dashboard-navbar {
    background-color: var(--navbar-bg);
    color: #F9F9F9;
    display: flex;
    align-items: center;
    gap: var(--sp-lg);
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--topbar-h);
    padding: 0 var(--sp-3xl);
    z-index: 200;
    flex-shrink: 0;
}

/* --- Brand --- */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    flex-shrink: 0;
}

.sidebar-brand__orb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background-color: var(--semi-color-primary);
    border-radius: var(--semi-border-radius-small);
    color: #FFFFFF;
}
.sidebar-brand__orb .ti { font-size: 18px; }

.sidebar-brand__name {
    font-size: 24px;
    font-weight: 600;
    line-height: 32px;
    color: #F9F9F9;
    letter-spacing: -0.5px;
}

/* --- Mobile hamburger --- */
.navbar-hamburger {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    background: transparent;
    border: none;
    color: #F9F9F9;
    border-radius: var(--semi-border-radius-small);
    transition: background-color 0.15s ease;
}
.navbar-hamburger:hover { background-color: var(--navbar-fill); }
.navbar-hamburger .ti { font-size: 22px; }

/* --- Navigation --- */
.navbar-nav {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--sp-xs);
}

.navbar-nav__item {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: var(--sp-sm) var(--sp-md);
    border-radius: var(--semi-border-radius-medium);
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: #F9F9F9;
    opacity: 0.7;
    position: relative;
    background: transparent;
    border: none;
    font-family: var(--semi-font-family);
    white-space: nowrap;
    transition: background-color 0.15s ease, opacity 0.15s ease;
    cursor: pointer;
}

.navbar-nav__item:hover {
    background-color: var(--navbar-fill);
    opacity: 1;
}

.navbar-nav__item--active {
    background-color: var(--navbar-fill);
    opacity: 1;
    font-weight: 600;
}

.navbar-nav__item--active::before {
    content: "";
    position: absolute;
    left: var(--sp-md);
    right: var(--sp-md);
    bottom: -1px;
    height: 3px;
    background-color: var(--semi-color-primary);
    border-radius: var(--semi-border-radius-extra-small) var(--semi-border-radius-extra-small) 0 0;
}

.navbar-nav__item .ti { font-size: 20px; flex-shrink: 0; }

/* --- Group (L1 trigger + L2 dropdown) --- */
.navbar-nav__group { position: relative; }

.navbar-nav__caret {
    font-size: 16px !important;
    opacity: 0.7;
    transition: transform 0.2s ease;
}
.navbar-nav__trigger--open .navbar-nav__caret { transform: rotate(180deg); }

.navbar-nav__dropdown {
    position: absolute;
    top: calc(100% + var(--sp-xs));
    left: 0;
    min-width: 180px;
    background-color: var(--navbar-bg);
    border: 1px solid var(--navbar-border);
    border-radius: var(--semi-border-radius-medium);
    padding: var(--sp-xs) 0;
    display: flex;
    flex-direction: column;
    z-index: 300;
    box-shadow: 0 0 1px rgba(0,0,0,0.3), 0 4px 14px rgba(0,0,0,0.25);
}

.navbar-nav__sub {
    display: flex;
    align-items: center;
    padding: var(--sp-md) var(--sp-lg);
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: #F9F9F9;
    opacity: 0.7;
    white-space: nowrap;
    transition: background-color 0.15s ease, opacity 0.15s ease;
    cursor: pointer;
}
.navbar-nav__sub:hover { background-color: var(--navbar-fill); opacity: 1; }
.navbar-nav__sub--active {
    background-color: var(--navbar-fill);
    opacity: 1;
    font-weight: 600;
    color: var(--semi-color-primary);
}

/* --- Navbar User --- */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    flex-shrink: 0;
    position: relative;
}

.sidebar-user__info { min-width: 0; }

.sidebar-user__name {
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    color: #F9F9F9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user__role {
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
    color: #F9F9F9;
    opacity: 0.5;
}

.sidebar-user__avatar-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--semi-border-radius-full);
    background-color: var(--semi-color-primary);
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease;
    overflow: hidden;
}
.sidebar-user__avatar-btn:hover { opacity: 0.85; }
.sidebar-user__avatar-btn--open { transform: scale(0.95); opacity: 0.85; }
.sidebar-user__avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--semi-border-radius-full); }
.sidebar-user__avatar-text { font-size: 14px; font-weight: 600; color: #FFFFFF; line-height: 1; }

/* --- User Dropdown Menu (drops down from top-right) --- */
.sidebar-user__dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + var(--sp-sm));
    min-width: 180px;
    background-color: var(--navbar-bg);
    border: 1px solid var(--navbar-border);
    border-radius: var(--semi-border-radius-medium);
    padding: var(--sp-xs) 0;
    z-index: 300;
    box-shadow: 0 0 1px rgba(0,0,0,0.3), 0 4px 14px rgba(0,0,0,0.25);
}

.sidebar-user__dropdown::after {
    content: "";
    position: absolute;
    top: -6px;
    right: 18px;
    width: 10px;
    height: 10px;
    background-color: var(--navbar-bg);
    border-left: 1px solid var(--navbar-border);
    border-top: 1px solid var(--navbar-border);
    transform: rotate(45deg);
}

.sidebar-user__dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    width: 100%;
    padding: var(--sp-md) var(--sp-lg);
    background: transparent;
    border: none;
    color: #F9F9F9;
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    text-align: left;
}
.sidebar-user__dropdown-item:hover { background-color: var(--navbar-fill); }
.sidebar-user__dropdown-item .ti { font-size: 18px; flex-shrink: 0; opacity: 0.7; }
.sidebar-user__dropdown-item--danger { color: var(--semi-color-danger); }
.sidebar-user__dropdown-item--danger .ti { color: var(--semi-color-danger); }

.sidebar-user__dropdown-divider {
    height: 1px;
    background-color: var(--navbar-border);
    margin: var(--sp-xs) var(--sp-lg);
}

/* --- Profile Modal --- */
.profile-modal {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-lg);
}

.profile-modal__backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(28, 31, 35, 0.5);
}

.profile-modal__card {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    background-color: var(--semi-color-bg-2);
    border-radius: var(--semi-border-radius-large);
    padding: var(--sp-lg);
    z-index: 1;
}

.profile-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-lg);
}

.profile-modal__title {
    font-size: 20px;
    font-weight: 600;
    line-height: 28px;
    color: var(--semi-color-text-0);
    margin: 0;
}

.profile-modal__close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--semi-color-text-1);
    border-radius: var(--semi-border-radius-small);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.profile-modal__close:hover { background-color: var(--semi-color-fill-1); color: var(--semi-color-text-0); }
.profile-modal__close .ti { font-size: 20px; }

/* --- Tabs --- */
.profile-modal__tabs {
    display: flex;
    gap: var(--sp-xs);
    margin-bottom: var(--sp-lg);
    border-bottom: 1px solid var(--semi-color-border);
    padding-bottom: var(--sp-xs);
}

.profile-modal__tab {
    padding: var(--sp-sm) var(--sp-md);
    font-family: var(--semi-font-family);
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: var(--semi-color-text-1);
    background: transparent;
    border: none;
    border-radius: var(--semi-border-radius-small);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.profile-modal__tab:hover { background-color: var(--semi-color-fill-1); color: var(--semi-color-text-0); }

.profile-modal__tab--active {
    color: var(--semi-color-primary);
    font-weight: 600;
    background-color: var(--semi-color-primary-light-default);
}

/* --- Toast --- */
.profile-toast {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: var(--sp-md) var(--sp-lg);
    border-radius: var(--semi-border-radius-small);
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    margin-bottom: var(--sp-lg);
}

.profile-toast.success {
    background-color: var(--semi-color-primary-light-default);
    color: var(--semi-color-success);
}

.profile-toast.error {
    background-color: var(--semi-color-danger-light-default);
    color: var(--semi-color-danger);
}

.profile-toast .ti { font-size: 18px; flex-shrink: 0; }

/* --- Avatar Section --- */
.profile-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-md);
    margin-bottom: var(--sp-xl);
}

.profile-avatar-section__preview {
    width: 96px;
    height: 96px;
    border-radius: var(--semi-border-radius-full);
    background-color: var(--semi-color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 600;
    color: #FFFFFF;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}
.profile-avatar-section__preview img { width: 100%; height: 100%; object-fit: cover; }

.profile-avatar-section__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-xs);
    background-color: rgba(28, 31, 35, 0.6);
    color: #F9F9F9;
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: var(--semi-border-radius-full);
    pointer-events: none;
}
.profile-avatar-section__preview:hover .profile-avatar-section__overlay { opacity: 1; }
.profile-avatar-section__overlay .ti { font-size: 24px; }

.profile-avatar-section__hint {
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
    color: var(--semi-color-text-2);
    margin: 0;
    text-align: center;
}

/* --- Info List --- */
.profile-info-list { display: flex; flex-direction: column; gap: var(--sp-md); }

.profile-info-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-md) 0;
    border-bottom: 1px solid var(--semi-color-border);
}
.profile-info-item:last-child { border-bottom: none; }

.profile-info-item__label { font-size: 14px; font-weight: 400; line-height: 20px; color: var(--semi-color-text-1); }
.profile-info-item__value { font-size: 14px; font-weight: 600; line-height: 20px; color: var(--semi-color-text-0); }

/* --- Form --- */
.profile-form { display: flex; flex-direction: column; gap: var(--sp-lg); }
.profile-form__group { display: flex; flex-direction: column; gap: var(--sp-xs); }

.profile-form__label {
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: var(--semi-color-text-0);
}

.profile-form__input {
    width: 100%;
    height: 32px;
    padding: 0 var(--sp-lg);
    font-family: var(--semi-font-family);
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    color: var(--semi-color-text-0);
    background-color: var(--semi-color-fill-0);
    border: 1px solid transparent;
    border-radius: var(--semi-border-radius-small);
    outline: none;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.profile-form__input:hover { background-color: var(--semi-color-fill-1); }
.profile-form__input:focus { border-color: var(--semi-color-focus-border); background-color: var(--semi-color-fill-0); }
.profile-form__input::placeholder { color: var(--semi-color-text-2); }

.profile-form__error {
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
    color: var(--semi-color-danger);
    margin: var(--sp-xs) 0 0;
}

.profile-form__actions { display: flex; justify-content: flex-end; padding-top: var(--sp-sm); }

/* --- Alpine.js cloak --- */
[x-cloak] { display: none !important; }

/* --- Responsive: Navbar (mobile) --- */
@media (max-width: 1024px) {
    .dashboard-navbar {
        flex-wrap: wrap;
        height: auto;
        min-height: var(--topbar-h);
        padding: 0 var(--sp-lg);
    }

    .navbar-hamburger { display: flex; }

    /* Collapse nav into a stacked panel toggled by hamburger */
    .navbar-nav {
        display: none;
        order: 3;
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: var(--sp-xs);
        padding: var(--sp-sm) 0;
        border-top: 1px solid var(--navbar-border);
    }
    .navbar-nav--open { display: flex; }

    .navbar-nav__item { width: 100%; }
    .navbar-nav__item--active::before {
        left: 0;
        right: auto;
        top: 50%;
        bottom: auto;
        transform: translateY(-50%);
        width: 3px;
        height: 20px;
        border-radius: 0 var(--semi-border-radius-extra-small) var(--semi-border-radius-extra-small) 0;
    }

    /* Dropdown becomes inline block within the stacked menu */
    .navbar-nav__group { width: 100%; }
    .navbar-nav__trigger { width: 100%; justify-content: flex-start; }
    .navbar-nav__caret { margin-left: auto; }
    .navbar-nav__dropdown {
        position: static;
        min-width: 0;
        border: none;
        box-shadow: none;
        padding: var(--sp-xxs) 0 var(--sp-xxs) var(--sp-3xl);
    }

    /* Push user area to the right of the top row (before wrapped nav) */
    .sidebar-user { order: 2; margin-left: var(--sp-sm); }
    .navbar-hamburger { order: 1; }
}

@media (max-width: 600px) {
    .sidebar-user__info { display: none; }
}
