/* Sidebar Navigation - Scaled Down ~10% */
.sidebar { 
    width: 235px; /* Reduced from 260px */
    height: calc(100vh - 24px);
    margin: 12px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 20px; /* Reduced from 24px */
    display: flex;
    flex-direction: column; 
    padding: 20px 14px; /* Reduced from 24px 16px */
    flex-shrink: 0; 
    z-index: 100; 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
}
.sidebar-header { display: flex; align-items: center; gap: 8px; margin-bottom: 28px; padding: 0 10px; } /* Adjusted gap/margin/padding */
.sidebar-logo { font-size: 18px; font-weight: 800; color: var(--text-primary); text-decoration: none; display: flex; align-items: center; gap: 8px; } /* Reduced font/gap */
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; } /* Reduced gap */
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 99px; color: var(--text-secondary); text-decoration: none; font-weight: 500; font-size: 14px; transition: all 0.2s; } /* Reduced padding/gap, added font-size */
.nav-item:hover, .nav-item.active { background: rgba(0,0,0,0.05); color: var(--text-primary); }
.nav-item svg { width: 18px; height: 18px; } /* Reduced size */

.user-profile { margin-top: auto; padding: 14px; border-top: 1px solid var(--border-light); display: flex; align-items: center; gap: 10px; cursor: pointer; border-radius: 12px; transition: background 0.2s; position: relative; } /* Reduced padding/gap */
.user-profile:hover { background: rgba(0,0,0,0.03); }
.user-avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--bg-input); } /* Reduced size */
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 700; font-size: 13px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* Reduced font */
.user-role { font-size: 11px; color: var(--text-tertiary); } /* Reduced font */
.user-menu { position: absolute; bottom: 100%; left: 0; right: 0; background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 12px; padding: 6px; box-shadow: var(--shadow-lg); display: none; margin-bottom: 8px; }
.user-menu.active { display: block; }
.menu-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--text-secondary); text-decoration: none; font-size: 13px; font-weight: 500; cursor: pointer; } /* Reduced gap/padding */
.menu-item:hover { background: rgba(0,0,0,0.04); color: var(--text-primary); }
.menu-item.danger { color: #ef4444; }
.menu-item.danger:hover { background: rgba(239, 68, 68, 0.08); }
.hamburger { display: none; position: fixed; top: 2px; left: 16px; z-index: 200; background: var(--bg-card); border: 1px solid var(--border-light); padding: 8px; border-radius: 8px; cursor: pointer; box-shadow: var(--shadow-sm); }
.nav-version-tag{font-size:9px;padding:2px 6px;background:linear-gradient(135deg,#6366f1 0%,#a855f7 100%);color:white;border-radius:6px;font-weight:700;margin-left:auto;box-shadow:0 2px 5px rgba(168,85,247,0.2);}

@media (max-width: 768px) {
    .sidebar { 
        position: fixed; 
        transform: translateX(-100%); 
        width: 260px; /* Keep mobile width slightly larger for touch? Or match base? Let's match base roughly or keep 260 for safety */
        height: 100vh;
        margin: 0;
        border-radius: 0;
        border: none;
        border-right: 1px solid var(--border-light);
        box-shadow: 20px 0 50px rgba(0,0,0,0.1); 
    }
    .sidebar-header { padding-left: 60px; }
    .sidebar.open { transform: translateX(0); }
    .hamburger { display: block; }
    .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 90; display: none; backdrop-filter: blur(4px); }
    .sidebar-overlay.active { display: block; }
}
.beta-tag { font-size: 11px; background: #000;  padding: 1px 5px; border-radius: 4px; font-weight: 700; margin-left: 4px; color: var(--bg-body); } /* Reduced font/padding */

/* --- Refined User Widget & Menu (New) --- */
.user-profile-widget {
    background: #f3f4f6;
    border-radius: 10px; /* Reduced radius */
    padding: 7px 10px; /* Reduced padding */
    display: flex;
    align-items: center;
    gap: 8px; /* Reduced gap */
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    position: relative;
    border: 1px solid transparent;
}
.user-profile-widget:hover {
    background: #e5e7eb;
}
.user-profile-widget.active {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.up-avatar {
    width: 32px; height: 32px; /* Reduced from 36px */
    border-radius: 7px;
    background: linear-gradient(135deg, #000, #000);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 13px; /* Reduced font */
}
.up-info {
    flex: 1; display: flex; flex-direction: column; gap: 2px; overflow: hidden;
}
.up-name {
    font-size: 13px; font-weight: 600; color: #1f2937; /* Reduced font */
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.up-role {
    font-size: 10px; color: #000000; display: flex; align-items: center; gap: 3px; /* Reduced font/gap */
}
.up-chevron {
    color: #9ca3af; transition: transform 0.2s;
}
.user-profile-widget.active .up-chevron {
    transform: rotate(180deg);
}

/* Sidebar Upgrade Button */
.sidebar-upgrade-btn {
    width: 100%;
    color: #ffffff;
    background: linear-gradient(135deg, #ff6b8b 0%, #ffe08a 40%, #6dd5c3 80%);
    border: none;
    border-radius: 9px; 
    padding: 10px 0;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
.sidebar-upgrade-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
}

/* Popup Menu Refined */
.refined-user-menu {
    position: absolute;
    left: 100%; bottom: 0; 
    margin-left: 14px; /* Reduced margin */
    width: 240px; /* Reduced width */
    background: #fff;
    border-radius: 14px; /* Reduced radius */
    box-shadow: 0 10px 40px rgba(0,0,0,0.12), 0 2px 10px rgba(0,0,0,0.05);
    padding: 14px; /* Reduced padding */
    z-index: 2000;
    opacity: 0; visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(0,0,0,0.06);
}
@media (max-width: 768px) {
    .refined-user-menu {
        left: 12px; bottom: 80px; 
        margin-left: 0;
    }
}
.refined-user-menu.active {
    opacity: 1; visibility: visible;
    transform: translateY(0);
}

.rum-header {
    font-size: 11px; color: #9ca3af; margin-bottom: 10px; font-weight: 500;
}
.rum-user-row {
    display: flex; gap: 10px; align-items: center; margin-bottom: 14px;
}
.rum-avatar {
    width: 40px; height: 40px; /* Reduced size */
    border-radius: 10px;
    background: #000;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 16px;
}
.rum-info { display: flex; flex-direction: column; overflow: hidden; }
.rum-name { font-size: 14px; font-weight: 700; color: #111827; }
.rum-email { font-size: 11px; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rum-divider {
    height: 1px; background: #f3f4f6; margin: 7px 0;
}

.rum-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 6px;
    border-radius: 7px;
    color: #374151;
    font-size: 13px; font-weight: 500;
    text-decoration: none;
    transition: background 0.15s;
    cursor: pointer;
}
.rum-item:hover {
    background: #f9fafb;
    color: #111827;
}
.rum-icon { width: 16px; height: 16px; color: #6b7280; }
.rum-item:hover .rum-icon { color: #111827; }

.rum-item.upgrade { color: #111827; }
.rum-item.upgrade .rum-icon { color: #f59e0b; } 

.rum-footer {
    margin-top: 10px;
    display: flex; flex-direction: column; gap: 3px;
}
.rum-link {
    font-size: 10px; color: #9ca3af; text-decoration: underline; cursor: pointer;
}
.rum-link:hover { color: #6b7280; }

/* --- Nav Sign In Button --- */
.btn-primary-sm {
    background: #000; color: #fff;
    border: none; border-radius: 9px;
    padding: 0 18px; height: 28px; /* Reduced padding/height */
    font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.3s;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-sm);
}
.btn-primary-sm:hover {
    background: #333;
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* Sidebar Contact QR */
.sidebar-contact-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f3f4f6;
}
.sidebar-contact-title {
    font-size: 11px; font-weight: 600; color: #111827; margin-bottom: 5px;
}

.sidebar-qr-grid {
    display: flex; gap: 7px; flex-wrap: wrap;
}
.sidebar-qr-item {
    display: flex; flex-direction: column; align-items: center;
}
.sidebar-qr-item img {
    width: 86px; height: 86px; border-radius: 5px; border: 1px solid #e5e7eb; padding: 2px; background: #fff;
}

/* Compact Mode for Laptops (max-height: 850px) */
@media (max-height: 850px) {
    .sidebar {
        padding-top: 12px;
        padding-bottom: 12px;
        gap: 0;
    }
    .sidebar-header {
        margin-bottom: 12px;
    }
    .nav-item {
        padding: 8px 10px;
        font-size: 13px;
        gap: 8px;
    }
    .nav-item svg {
        width: 16px; height: 16px;
    }
    .sidebar-qr-item img {
        width: 70px; height: 70px;
    }
    .sidebar-upgrade-btn {
        padding: 6px 0;
        margin-bottom: 6px;
        font-size: 12px;
    }
    .user-profile-widget {
        padding: 6px 8px;
    }
    .up-avatar {
        width: 28px; height: 28px;
        font-size: 12px;
    }
}

/* Super Compact Mode for 13-inch or smaller (max-height: 700px) */
@media (max-height: 700px) {
    .sidebar {
        padding-top: 8px;
        padding-bottom: 8px;
        width: 220px;
        overflow-y: auto; /* Enable full sidebar scrolling */
    }
    /* Disable inner scroll and allow nav to expand naturally */
    .sidebar-nav {
        flex: none;
        overflow-y: visible;
    }
    .sidebar-header {
        margin-bottom: 8px;
    }
    .sidebar-logo {
        font-size: 16px;
    }
    .nav-item {
        padding: 6px 8px;
        font-size: 12px;
    }
    .sidebar-qr-item img {
        width: 50px; height: 50px;
    }
    .sidebar-contact-title {
        font-size: 10px;
    }
    /* Ensure upgrade button is visible and accessible */
    .sidebar-upgrade-btn {
        display: flex; 
        font-size: 12px;
        padding: 6px 0;
        margin-bottom: 6px;
    }
    /* Ensure proper spacing for auth section in scroll mode */
    #sidebarAuthSection {
        margin-top: 12px;
        padding-bottom: 10px;
    }
}
