/* ===================================
   MCB AI Style - Layout System
   Exact spacing from mcbai.vn
   Sidebar: 256px | Topbar: 81px
   Icons: Lucide SVG 24x24 stroke-width-2
   Font: Inter + Space Grotesk
   =================================== */

/* --- Sidebar --- */
.kgai-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 256px;
    background: rgba(11, 15, 25, 0.95);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    padding: 20px 16px;
    overflow-y: auto;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.kgai-sidebar::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

.kgai-sidebar-inner {
    flex: 1;
}

/* Logo: favicon + italic bold text */
.kgai-sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    margin-bottom: 28px;
    text-decoration: none !important;
}

.kgai-logo-favicon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: contain;
}

.kgai-logo-text {
    font-family: 'Inter', sans-serif !important;
    font-size: 24px;
    font-weight: 700;
    color: #fff !important;
    letter-spacing: -0.02em;
}

.kgai-logo-text em {
    font-style: italic;
    color: #2563EB !important;
    background-image: linear-gradient(135deg, #97b2ed, #2563EB);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Sidebar Nav */
.kgai-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kgai-sidebar-item {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    color: rgb(209, 213, 219) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 16px;
    font-weight: 400;
    text-decoration: none !important;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.kgai-sidebar-item svg {
    flex-shrink: 0;
    color: rgb(156, 163, 175);
    transition: color 0.2s;
}

.kgai-sidebar-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff !important;
}

.kgai-sidebar-item:hover svg {
    color: rgb(192, 132, 252);
}

.kgai-sidebar-item.active {
    background: rgba(124, 92, 255, 0.15);
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.15);
    position: relative;
}

.kgai-sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: #2563EB;
}

.kgai-sidebar-item.active svg {
    color: #60a5fa;
}

/* Badge (Coming Soon, lock) */
.kgai-sidebar-badge {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: rgb(107, 114, 128);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kgai-sidebar-badge-new {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.kgai-sidebar-badge-live {
    background: none;
    color: #34d399;
    font-size: 12px;
    animation: kgaiPulse 2s ease infinite;
}

@keyframes kgaiPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* VIP-locked sidebar items */
.kgai-sidebar-vip-item {
    opacity: 0.45;
    pointer-events: auto;
}

.kgai-sidebar-vip-item:hover {
    opacity: 0.7;
}

.kgai-sidebar-lock {
    margin-left: auto;
    color: #6b7280;
}

/* Sidebar Upgrade CTA */
.kgai-sidebar-cta-upgrade {
    background: linear-gradient(135deg, #2563EB, #1d4ed8) !important;
    border-color: rgba(37, 99, 235, 0.4) !important;
    color: #fff !important;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.25);
}

.kgai-sidebar-cta-upgrade:hover {
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.35) !important;
    transform: translateY(-1px);
}

.kgai-sidebar-cta-vip {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    border-color: rgba(245, 158, 11, 0.4) !important;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.2);
}

.kgai-sidebar-cta-vip:hover {
    box-shadow: 0 6px 24px rgba(245, 158, 11, 0.3) !important;
}

/* Arrow SVG for dropdowns */
.kgai-sidebar-arrow-svg {
    margin-left: auto;
    transition: transform 0.2s;
    color: rgb(107, 114, 128);
}

.kgai-sidebar-divider {
    padding: 24px 10px 10px;
    font-family: 'Inter', sans-serif !important;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgb(75, 85, 99);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    margin-top: 8px;
}

.kgai-sidebar-dropdown {
    position: relative;
}

.kgai-sidebar-submenu {
    display: none;
    flex-direction: column;
    padding-left: 25px;
    gap: 2px;
}

.kgai-sidebar-dropdown.open .kgai-sidebar-submenu {
    display: flex;
}

.kgai-sidebar-dropdown.open .kgai-sidebar-arrow-svg {
    transform: rotate(180deg);
}

.kgai-sidebar-submenu a {
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 14px;
    color: rgb(209, 213, 219) !important;
    text-decoration: none !important;
    transition: all 0.15s;
    font-family: 'Inter', sans-serif !important;
}

.kgai-sidebar-submenu a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff !important;
}

.kgai-sidebar-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
    border-radius: 12px;
    margin-top: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.2s;
}

.kgai-sidebar-cta:hover {
    background: rgba(124, 92, 255, 0.15);
    border-color: rgba(124, 92, 255, 0.3);
}

.kgai-sidebar-cta svg {
    color: rgb(192, 132, 252);
}

/* --- Topbar --- */
.kgai-topbar {
    position: fixed;
    top: 0;
    left: 290px;
    margin-top: 0;
    right: 0;
    height: 81px;
    z-index: 999;
    background: rgba(11, 15, 25, 0.6);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.kgai-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 24px;
}

.kgai-topbar-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.kgai-topbar-links a {
    color: rgb(209, 213, 219) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none !important;
    padding: 8px 16px;
    border-radius: 9999px;
    transition: all 0.2s;
}

.kgai-topbar-links a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff !important;
}

.kgai-topbar-link-active {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #fff !important;
}

.kgai-topbar-affiliate {
    color: rgb(250, 204, 21) !important;
    font-weight: 600 !important;
}

.kgai-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0.8;
}

.kgai-search-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    height: 25px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s;
    color: rgb(107, 114, 128);
    flex: 1;
}

.kgai-search-trigger:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

.kgai-search-placeholder {
    font-family: 'Inter', sans-serif !important;
    color: rgb(107, 114, 128);
    font-size: 14px;
}

.kgai-search-trigger kbd {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: rgb(107, 114, 128);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-family: 'Inter', sans-serif !important;
}

.kgai-topbar-btn {
    padding: 8px 20px;
    height: 25px;
    border-radius: 9999px;
    background: rgba(124, 92, 255, 0.15);
    border: 1px solid rgba(124, 92, 255, 0.3);
    color: #fff !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
}

.kgai-topbar-btn:hover {
    background: rgba(124, 92, 255, 0.25);
    box-shadow: 0 0 24px rgba(124, 92, 255, 0.2);
    transform: scale(1.02);
}

/* --- User Dropdown Menu --- */
.kgai-user-area {
    position: relative;
}

.kgai-user-menu {
    display: flex;
    align-items: center;
    position: relative;
}

.kgai-user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    padding: 4px 14px 4px 4px;
    color: #e5e7eb;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
}

.kgai-user-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
}

.kgai-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(124, 92, 255, 0.4);
}

.kgai-user-avatar-initials {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563EB, #ec4899);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kgai-user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kgai-user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 260px;
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 9999;
}

.kgai-user-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.kgai-user-dropdown-header {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kgai-user-dropdown-header strong {
    color: #fff;
    font-size: 14px;
}

.kgai-user-dropdown-header span {
    color: #9ca3af;
    font-size: 12px;
}

.kgai-user-badge {
    display: inline-block;
    width: fit-content;
    padding: 2px 8px;
    border-radius: 6px;
    margin-top: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
}

.kgai-badge-vip {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.kgai-user-dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 4px 0;
}

.kgai-user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #d1d5db !important;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none !important;
    transition: all 0.1s;
}

.kgai-user-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff !important;
}

.kgai-user-logout:hover {
    color: #f87171 !important;
}

/* --- Smart Search Modal --- */
.kgai-search-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
}

.kgai-search-modal.active {
    display: flex;
}

.kgai-search-box {
    width: 640px;
    max-width: 92vw;
    background: rgb(11, 15, 25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

/* Input Row */
.kgai-search-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.kgai-search-icon {
    flex-shrink: 0;
    color: rgb(107, 114, 128);
}

.kgai-search-input-row input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: #fff;
    font-family: 'Inter', sans-serif !important;
    font-size: 16px;
}

.kgai-search-input-row input::placeholder {
    color: rgb(75, 85, 99);
}

.kgai-search-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: #2563EB;
    border-radius: 50%;
    animation: mcbSpin 0.6s linear infinite;
    display: none;
}

.kgai-search-spinner.active {
    display: block;
}

@keyframes mcbSpin {
    to {
        transform: rotate(360deg);
    }
}

.kgai-search-esc {
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgb(75, 85, 99);
    font-size: 11px;
    font-weight: 600;
    font-family: 'Inter', sans-serif !important;
    cursor: pointer;
}

/* Quick Links */
.kgai-search-quick,
.kgai-search-results,
.kgai-search-empty {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.kgai-search-section-label {
    font-family: 'Inter', sans-serif !important;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgb(75, 85, 99);
    margin-bottom: 12px;
}

.kgai-search-quick-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.kgai-search-quick-item {
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.04);
    color: rgb(209, 213, 219) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none !important;
    transition: all 0.15s;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kgai-search-quick-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: #fff !important;
}

/* Search Results */
.kgai-search-results-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kgai-search-result-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    text-decoration: none !important;
    transition: all 0.15s;
    cursor: pointer;
}

.kgai-search-result-item:hover,
.kgai-search-result-item.active {
    background: rgba(124, 92, 255, 0.1);
}

.kgai-search-result-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.kgai-search-result-info {
    flex: 1;
    min-width: 0;
}

.kgai-search-result-title {
    color: #fff;
    font-family: 'Inter', sans-serif !important;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kgai-search-result-excerpt {
    color: rgb(107, 114, 128);
    font-size: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 2px;
}

.kgai-search-result-type {
    padding: 3px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: rgb(107, 114, 128);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* Empty State */
.kgai-search-empty {
    text-align: center;
    padding: 40px 20px;
}

.kgai-search-empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.kgai-search-empty p {
    color: rgb(156, 163, 175);
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.kgai-search-empty span {
    color: rgb(75, 85, 99);
    font-size: 13px;
}

/* Footer */
.kgai-search-footer {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.01);
}

.kgai-search-footer span {
    color: rgb(75, 85, 99);
    font-size: 11px;
    font-weight: 500;
    font-family: 'Inter', sans-serif !important;
}

@media (max-width: 640px) {
    .kgai-search-quick-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .kgai-search-box {
        border-radius: 12px;
    }

    .kgai-search-modal {
        padding-top: 5vh;
    }
}

/* --- Main Content Area --- */
.pl-hero {
    text-align: center;
}

body.kgai-theme {
    padding-top: 81px !important;
    padding-left: 290px !important;
}

/* --- Mobile Toggle --- */
.kgai-mobile-toggle {
    display: none;
    position: fixed;
    top: 22px;
    right: 16px;
    z-index: 1002;
    background: rgba(11, 15, 25, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    flex-direction: column;
    margin-top: 0;
    gap: 5px;
}

.kgai-mobile-toggle span {
    width: 20px;
    height: 2px;
    background: rgb(209, 213, 219);
    border-radius: 2px;
    transition: all 0.3s;
}

.kgai-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.6);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .kgai-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

    .kgai-topbar {
        left: 0;
    }

    body.kgai-theme {
        padding-left: 0 !important;
    }

    .kgai-mobile-toggle {
        display: flex;
    }

    .kgai-sidebar-overlay.active {
        display: block;
    }

    .kgai-topbar-links {
        display: none;
    }

    .kgai-search-placeholder {
        display: none;
    }
}