* {
    box-sizing: border-box;
}

:root {
    --layout-bg: #eef5ff;
    --sidebar-bg: #0f172a;
    --sidebar-bg-soft: #13203a;
    --sidebar-border: rgba(148, 163, 184, 0.22);
    --sidebar-text: #dbe7ff;
    --sidebar-muted: #8fa3c3;
    --sidebar-active: #2f80ff;
    --sidebar-active-dark: #2a71df;
    --content-text: #0f172a;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: "Segoe UI", Arial, sans-serif;
    background: radial-gradient(circle at top left, #e9f3ff 0%, #f3f8ff 46%, #edf4ff 100%);
    color: var(--content-text);
}

.app-layout {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 248px;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-soft) 100%);
    color: var(--sidebar-text);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 30;
    box-shadow: 6px 0 24px rgba(2, 6, 23, 0.35);
    transition: width 0.22s ease;
}

.sidebar-header {
    padding: 14px 12px;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-logo {
    text-decoration: none;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 9px;
}

.sidebar-logo-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #31a4ff 0%, #2f80ff 65%, #2858d8 100%);
    font-weight: 700;
}

.sidebar-logo-text {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.sidebar-collapse-toggle {
    border: 1px solid var(--sidebar-border);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.35);
    color: #c6d7f4;
    cursor: pointer;
}

.sidebar-profile {
    padding: 12px;
    margin: 10px;
    border-radius: 10px;
    border: 1px solid var(--sidebar-border);
    background: rgba(255, 255, 255, 0.04);
    display: flex;
    gap: 10px;
    align-items: center;
}

.sidebar-profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--sidebar-border);
}

.sidebar-profile-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-profile-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-role {
    font-size: 12px;
    color: #c7d7f3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-search {
    padding: 0 10px 10px;
}

.sidebar-search-input {
    width: 100%;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--sidebar-border);
    background: rgba(15, 23, 42, 0.45);
    color: var(--sidebar-text);
    padding: 0 10px;
    outline: none;
}

.sidebar-search-input::placeholder {
    color: var(--sidebar-muted);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 12px;
}

.sidebar-item,
.sidebar-subitem {
    margin-bottom: 6px;
}

.sidebar-link {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--sidebar-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(148, 163, 184, 0.45);
    transform: translateY(-1px);
}

.sidebar-link.is-open,
.sidebar-link.is-active {
    background: linear-gradient(180deg, var(--sidebar-active), var(--sidebar-active-dark));
    border-color: transparent;
    color: #fff;
}

.sidebar-link-icon {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.07));
    border: 1px solid rgba(148, 163, 184, 0.34);
    color: #d8e7ff;
    font-size: 12px;
    line-height: 1;
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.sidebar-link:hover .sidebar-link-icon {
    transform: scale(1.04);
}

.sidebar-link-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.sidebar-link-chevron {
    font-size: 16px;
    line-height: 1;
    transition: transform 0.18s ease;
}

.sidebar-link.is-open .sidebar-link-icon,
.sidebar-link.is-active .sidebar-link-icon {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.sidebar-item.is-open > .sidebar-link .sidebar-link-chevron,
.sidebar-subitem.is-open > .sidebar-link .sidebar-link-chevron {
    transform: rotate(90deg);
}

.sidebar-submenu {
    display: none;
    margin-top: 6px;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px dashed rgba(148, 163, 184, 0.32);
}

.sidebar-item.is-open > .sidebar-submenu,
.sidebar-subitem.is-open > .sidebar-submenu {
    display: block;
}

.sidebar-link-sub {
    min-height: 34px;
    font-size: 12px;
}

.sidebar-link-icon-sub {
    width: 22px;
    height: 22px;
    border-radius: 7px;
    font-size: 11px;
    color: #bcd0f1;
}

.sidebar-link-sub2 {
    min-height: 32px;
    font-size: 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.025);
}

.sidebar-link-sub2 .sidebar-link-icon-sub {
    width: 20px;
    height: 20px;
    font-size: 10px;
}

.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: 10px;
}

.sidebar-link-secondary {
    background: rgba(255, 255, 255, 0.03);
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 56px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(248, 251, 255, 0.88);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
}

.sidebar-toggle {
    display: none;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    border-radius: 8px;
    background: #fff;
    padding: 0 6px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
}

.sidebar-toggle-bar {
    height: 2px;
    border-radius: 10px;
    background: #0f172a;
}

.main-content {
    padding: 14px;
    min-height: calc(100vh - 56px);
}

body.sidebar-collapsed .sidebar {
    width: 78px;
}

body.sidebar-collapsed .sidebar-logo-text,
body.sidebar-collapsed .sidebar-profile-meta,
body.sidebar-collapsed .sidebar-search,
body.sidebar-collapsed .sidebar-link-text,
body.sidebar-collapsed .sidebar-link-chevron {
    display: none;
}

body.sidebar-collapsed .sidebar-link {
    justify-content: center;
    width: 44px;
    min-height: 44px;
    padding: 0;
    margin: 0 auto 8px;
    border-radius: 12px;
}

body.sidebar-collapsed .sidebar-link-icon {
    width: 28px;
    height: 28px;
    border-radius: 9px;
        font-size: 13px;
    }
    
body.sidebar-collapsed .sidebar-item,
body.sidebar-collapsed .sidebar-subitem {
    margin-bottom: 8px;
}

body.sidebar-collapsed .sidebar-submenu {
    display: none !important;
}

@media (max-width: 920px) {
    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    body.sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: inline-flex;
    }
}
