/* =========================================
   Sidebar Layout Styles
   Light theme matching analysis page design
   ========================================= */

/* Sidebar Container */
.app-sidebar {
    width: 256px;
    background: linear-gradient(to bottom, #f9fafb, #ffffff);
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 10001;
    transition: all 0.3s ease;
}

/* Collapsed state */
.app-sidebar.collapsed {
    width: 64px;
}

/* Header Section - Compact */
.sidebar-header {
    padding: 8px 12px;
    border-bottom: 1px solid #e5e7eb;
}

.sidebar-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.app-sidebar.collapsed .logo-text {
    display: none;
}

.logo-icon {
    font-size: 20px;
}

.sidebar-toggle-btn {
    padding: 6px;
    border-radius: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.sidebar-toggle-btn:hover {
    background: #f3f4f6;
}

.sidebar-toggle-btn svg {
    width: 16px;
    height: 16px;
    color: #6b7280;
}

/* Navigation Menu - Ultra Compact */
.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.nav-category {
    margin-bottom: 8px;
}

.nav-category-title {
    padding: 0 12px;
    margin-bottom: 4px;
    font-size: 9px;
    font-weight: 500;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.app-sidebar.collapsed .nav-category-title {
    display: none;
}

.nav-items {
    padding: 0 6px;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 4px 6px;
    margin-bottom: 1px;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    position: relative;
    color: #6b7280;
}

.app-sidebar.collapsed .nav-item {
    justify-content: center;
}

.nav-item:hover {
    background: #f9fafb;
    color: #111827;
}

.nav-item.active {
    background: #dbeafe;
    color: #2563eb;
}

.nav-item-icon-wrapper {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: #f3f4f6;
    transition: all 0.2s;
    flex-shrink: 0;
}

.nav-item.active .nav-item-icon-wrapper {
    background: #bfdbfe;
}

.nav-item:hover .nav-item-icon-wrapper {
    background: #e5e7eb;
}

.nav-icon {
    font-size: 14px;
}

.nav-icon-svg {
    width: 16px;
    height: 16px;
    color: #6b7280;
    transition: color 0.2s;
}

.nav-item:hover .nav-icon-svg,
.nav-item.active .nav-icon-svg {
    color: #2563eb;
}

.nav-content {
    margin-left: 8px;
    flex: 1;
    text-align: left;
}

.app-sidebar.collapsed .nav-content {
    display: none;
}

.nav-label {
    font-size: 12px;
    font-weight: 500;
    display: block;
    line-height: 1.2;
}

.nav-description {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 0px;
    line-height: 1.2;
}

/* Active indicator */
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    background: #2563eb;
    border-radius: 0 3px 3px 0;
}

/* Footer Section - Ultra Compact */
.sidebar-footer {
    padding: 8px;
    border-top: 1px solid #e5e7eb;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    padding: 4px;
    border-radius: 4px;
    background: #f9fafb;
}

.app-sidebar.collapsed .user-section {
    justify-content: center;
    padding: 3px;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
}

.app-sidebar.collapsed .user-info {
    display: none;
}

.user-email-display {
    font-size: 11px;
    color: #111827;
    font-weight: 500;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.user-role {
    font-size: 9px;
    color: #6b7280;
    line-height: 1.2;
}

.sidebar-logout-btn {
    width: 100%;
    padding: 5px 8px;
    background: white;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.app-sidebar.collapsed .sidebar-logout-btn {
    padding: 8px;
}

.app-sidebar.collapsed .logout-text {
    display: none;
}

.sidebar-logout-btn:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fca5a5;
}

/* Main Content Area Adjustment */
.main-content-with-sidebar {
    margin-left: 256px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    background: #f9fafb; /* Match body background to avoid white space */
}

.main-content-with-sidebar.expanded {
    margin-left: 64px;
}

/* Tooltip for collapsed sidebar */
.nav-tooltip {
    position: absolute;
    left: 100%;
    margin-left: 8px;
    padding: 4px 8px;
    background: #1f2937;
    color: white;
    font-size: 12px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10002;
}

.app-sidebar.collapsed .nav-item:hover .nav-tooltip {
    opacity: 1;
}

/* Adjust property confirmation overlay when sidebar is present */
.with-sidebar .property-confirmation-overlay {
    position: fixed;
    top: 0;
    left: 256px;
    right: 0;
    bottom: 0;
    width: auto;
    padding: 15px !important; /* Ensure consistent padding */
    transition: left 0.3s ease;
}

/* When sidebar is collapsed, adjust overlay */
.with-sidebar.expanded .property-confirmation-overlay {
    left: 64px;
}

/* Alternative: when sidebar has collapsed class */
body:has(.app-sidebar.collapsed) .property-confirmation-overlay {
    left: 64px;
}

/* When body has sidebar-collapsed class */
body.sidebar-collapsed .property-confirmation-overlay {
    left: 64px !important;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Hide sidebar by default on mobile */
    .app-sidebar {
        position: fixed;
        left: -256px;
        width: 256px;
        z-index: 10001;
        transition: left 0.3s ease;
        height: 100vh;
        top: 0;
    }
    
    /* Show sidebar when mobile menu is open */
    .app-sidebar.mobile-menu-open {
        left: 0;
    }
    
    /* Remove left margin on mobile */
    .main-content-with-sidebar {
        margin-left: 0;
        padding-top: 60px; /* Space for mobile header */
    }
    
    /* Mobile menu overlay */
    .mobile-menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .mobile-menu-overlay.active {
        display: block;
    }
    
    /* Hide desktop toggle button on mobile */
    .sidebar-toggle-btn {
        display: none;
    }
    
    .with-sidebar .property-confirmation-overlay {
        left: 0;
    }
}

/* Mobile header bar */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    z-index: 998;
    padding: 0 10px;
    align-items: center;
    justify-content: space-between;
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }
}

/* Mobile hamburger button */
.mobile-menu-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.mobile-menu-btn:hover {
    background: #f9fafb;
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
    color: #4b5563;
}

.mobile-logo {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

/* Hide scrollbars */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

/* Remove old header when sidebar is active */
body.has-sidebar nav.bg-white {
    display: none;
}

body.has-sidebar {
    padding-top: 0;
}