/* Sidebar Styles - ChatGPT/Claude-like left panel */

/* Main Layout */
html {
    overflow-x: hidden;
    width: 100%;
}

body {
    margin: 0;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

.main-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 100vh;
    min-height: 100dvh; /* Use dynamic viewport height for mobile browsers */
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    transition: margin-left 0.3s ease;
}

/* Prevent animation on page load */
.main-wrapper.no-transition {
    transition: none !important;
}

/* Sidebar Container */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height for mobile browsers */
    width: 260px;
    background: white;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width 0.3s ease, transform 0.3s ease;
}

/* Prevent animation on page load */
.sidebar.no-transition {
    transition: none !important;
}

.sidebar.no-transition * {
    transition: none !important;
}

/* Collapsed sidebar (icons only) */
.sidebar.sidebar-collapsed {
    width: 64px;
}

.sidebar.sidebar-collapsed .sidebar-logo-text,
.sidebar.sidebar-collapsed .sidebar-section-title,
.sidebar.sidebar-collapsed .sidebar-link span,
.sidebar.sidebar-collapsed .sidebar-user-info,
.sidebar.sidebar-collapsed .sidebar-link-text,
.sidebar.sidebar-collapsed .sidebar-section:has(#recent-vacancies-list) {
    display: none;
}

/* Hide section header content but keep the add button visible */
.sidebar.sidebar-collapsed .sidebar-section-header {
    justify-content: center;
    padding: 0;
}

.sidebar.sidebar-collapsed .sidebar-section-header .sidebar-section-title {
    display: none;
}

.sidebar.sidebar-collapsed .sidebar-add-btn {
    margin: 0.5rem auto;
}

.sidebar.sidebar-collapsed .sidebar-header {
    justify-content: center;
    position: relative;
    padding-bottom: 3.5rem;
}

.sidebar.sidebar-collapsed .sidebar-collapse-btn {
    position: absolute;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex !important;
}

.sidebar.sidebar-collapsed .sidebar-logo {
    justify-content: center;
}

.sidebar.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 0.625rem;
}

.sidebar.sidebar-collapsed .sidebar-link i {
    margin: 0;
}

.sidebar.sidebar-collapsed .sidebar-notifications-button,
.sidebar.sidebar-collapsed .sidebar-user-button {
    justify-content: center;
    padding: 0.625rem;
}

.sidebar.sidebar-collapsed .sidebar-user-avatar {
    margin: 0;
}

.sidebar.sidebar-collapsed .sidebar-notification-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: visible;
}

/* Sidebar Header */
.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--brand-primary, #232323);
    font-weight: 700;
    font-size: 1.25rem;
    text-decoration: none;
    transition: opacity 0.2s;
}

.sidebar-logo:hover {
    opacity: 0.8;
}

.sidebar-logo i {
    font-size: 1.5rem;
}

/* Collapse Button */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    color: #6b7280;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

/* Hide collapse button on mobile */
@media (max-width: 1023px) {
    .sidebar-collapse-btn {
        display: none !important;
    }
}

.sidebar-collapse-btn:hover {
    background: #f3f4f6;
    color: var(--brand-primary, #232323);
}

.sidebar-collapse-btn i {
    font-size: 0.875rem;
}

/* Scrollable Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
}

/* Custom scrollbar for sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

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

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Sidebar Sections */
.sidebar-section {
    margin-bottom: 1.5rem;
    padding: 0 0.75rem;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 0.5rem;
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
}

/* Add Button */
.sidebar-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    background: transparent;
    color: #6b7280;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
}

.sidebar-add-btn:hover {
    background: #f3f4f6;
    color: var(--brand-primary, #232323);
}

/* Sidebar Links */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    color: #374151;
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 0.125rem;
}

.sidebar-link:hover {
    background: #f3f4f6;
    color: var(--brand-primary, #232323);
}

.sidebar-link.active {
    background: #e5e7eb;
    color: var(--brand-primary, #232323);
    font-weight: 600;
}

.sidebar-link i {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

/* Recent Vacancies List */
.sidebar-vacancy-item {
    display: block;
    padding: 0.625rem 0.75rem;
    margin: 0 0.75rem 0.25rem 0.75rem;
    border-radius: 0.5rem;
    text-decoration: none;
    color: #374151;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.sidebar-vacancy-item:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
}

.sidebar-vacancy-title {
    font-size: 0.813rem;
    font-weight: 500;
    color: #111827;
    line-height: 1.3;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-vacancy-meta {
    font-size: 0.75rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    color: #9ca3af;
    text-align: center;
    gap: 0.5rem;
}

.sidebar-empty-state i {
    font-size: 2rem;
    opacity: 0.5;
}

.sidebar-empty-state span {
    font-size: 0.813rem;
}

/* Sidebar Footer - Notifications and User Section */
.sidebar-footer {
    flex-shrink: 0;
    border-top: 1px solid #e5e7eb;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Notifications Button */
.sidebar-notifications {
    position: relative;
}

.sidebar-notifications-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
}

.sidebar-notifications-button:hover {
    background: #f3f4f6;
}

.sidebar-notifications-button i {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-link-text {
    flex: 1;
    min-width: 0;
}

.sidebar-notification-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.25rem;
    font-size: 0.625rem;
    font-weight: 700;
    color: white;
    background: #dc2626;
    border-radius: 9999px;
    flex-shrink: 0;
}

.sidebar-user {
    position: relative;
}

.sidebar-user-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}

.sidebar-user-button:hover {
    background: #f3f4f6;
}

.sidebar-user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-email {
    font-size: 0.75rem;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mobile Floating Buttons */
/* Mobile Sidebar Toggle Button (Top-Left) */
.sidebar-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.75rem;
    background: white;
    border: 1px solid #e5e7eb;
    color: #374151;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease, opacity 0.3s ease, background 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-toggle.hidden {
    transform: translateY(-100px);
    opacity: 0;
    pointer-events: none;
}

.sidebar-toggle:hover {
    background: #f3f4f6;
    color: var(--brand-primary, #232323);
}

.sidebar-toggle i {
    font-size: 1.125rem;
}

/* Mobile Notifications Dropdown Container */
.mobile-notifications-dropdown {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1001;
    display: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.mobile-notifications-dropdown.hidden {
    transform: translateY(-100px);
    opacity: 0;
    pointer-events: none;
}

/* Mobile Notifications Button (Top-Right) */
.mobile-notifications-btn {
    position: relative;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.75rem;
    background: white;
    border: 1px solid #e5e7eb;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.mobile-notifications-btn:hover {
    background: #f3f4f6;
    color: var(--brand-primary, #232323);
}

.mobile-notifications-btn i {
    font-size: 1.125rem;
}

.mobile-notifications-badge {
    position: absolute;
    top: -0.25rem;
    right: -0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.25rem;
    font-size: 0.625rem;
    font-weight: 700;
    color: white;
    background: #dc2626;
    border-radius: 9999px;
    border: 2px solid white;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay-active {
    opacity: 1;
    pointer-events: auto;
}

/* Top Navigation (Guest Only) */
.top-nav {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 100;
    height: 4rem;
}

.top-nav-content {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    max-width: 100%;
}

/* Hide top-nav completely when sidebar exists (logged in state) */
body:has(.sidebar) .top-nav {
    display: none;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Desktop Layout (Sidebar Always Visible) */
@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
    }

    /* Only add margin when sidebar exists (user is logged in) */
    body:has(.sidebar) .main-wrapper {
        margin-left: 260px;
        transition: margin-left 0.3s ease;
    }

    body:has(.sidebar) .main-wrapper.sidebar-collapsed {
        margin-left: 64px;
    }

    .sidebar-toggle {
        display: none !important;
    }

    .sidebar-overlay {
        display: none !important;
    }
}

/* Tablet and Mobile Layout */
@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        max-height: 100vh;
        max-height: 100dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
    }

    .sidebar-toggle,
    .mobile-notifications-dropdown {
        display: flex;
    }

    .main-wrapper {
        margin-left: 0;
        width: 100%;
    }

    /* Add top padding to main content for floating buttons */
    .main-content {
        padding-top: 4.5rem;
        width: 100%;
        box-sizing: border-box;
    }

    .top-nav-content {
        padding-left: 4rem;
    }

    body.sidebar-mobile-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}

/* Small Mobile Adjustments */
@media (max-width: 640px) {
    .sidebar {
        width: 280px;
        max-width: 85vw;
        max-width: min(280px, 85vw);
    }

    .sidebar-logo-text {
        font-size: 1.125rem;
    }

    .sidebar-section-title {
        font-size: 0.688rem;
    }

    .sidebar-link {
        font-size: 0.813rem;
        padding: 0.5rem 0.625rem;
    }

    .top-nav-content {
        padding: 0 1rem 0 3.5rem;
    }

    .top-nav h1 {
        font-size: 1.125rem;
    }
}

/* Loading State */
.recent-vacancies-loading {
    padding: 1rem;
}

.spinner-border-sm {
    width: 1.25rem;
    height: 1.25rem;
    border-width: 2px;
}

/* Dropdowns open to the right */
.sidebar-dropdown-right {
    position: fixed !important;
    z-index: 1050 !important;
}

/* Ensure dropdowns are properly positioned */
.sidebar-notifications,
.sidebar-user {
    position: relative !important;
}

.sidebar-notifications .dropdown-menu,
.sidebar-user .dropdown-menu {
    position: fixed !important;
    z-index: 1050 !important;
}

/* Ensure dropdown shows when open */
.sidebar-notifications .dropdown-menu.show,
.sidebar-user .dropdown-menu.show {
    display: block !important;
}

/* Mobile specific dropdown positioning fix */
@media (max-width: 1023px) {
    /* On mobile, when sidebar uses transform, we need to position dropdowns differently */
    .sidebar-user .dropdown-menu {
        position: fixed !important;
        z-index: 9999 !important; /* Higher than sidebar z-index (1000) */
        /* Remove any transform inheritance issues */
        transform: none !important;
        /* Position relative to viewport, not transformed parent */
        right: 1rem !important;
        left: auto !important;
        top: 4.5rem !important; /* Below the mobile header */
        min-width: 280px !important;
        max-width: calc(100vw - 2rem) !important;
    }

    .sidebar-notifications .dropdown-menu {
        position: fixed !important;
        z-index: 9999 !important;
        transform: none !important;
        right: 1rem !important;
        left: auto !important;
        top: 4.5rem !important;
        min-width: 280px !important;
        max-width: calc(100vw - 2rem) !important;
    }

    /* Ensure the dropdown parent doesn't interfere with mobile positioning */
    .sidebar-open .sidebar-user,
    .sidebar-open .sidebar-notifications {
        position: static !important;
    }
}

/* Accessibility */
.sidebar-link:focus,
.sidebar-user-button:focus,
.sidebar-notifications-button:focus,
.sidebar-toggle:focus,
.sidebar-collapse-btn:focus,
.sidebar-add-btn:focus {
    outline: 2px solid var(--brand-primary, #232323);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .sidebar,
    .sidebar-toggle,
    .sidebar-overlay,
    .top-nav {
        display: none !important;
    }

    .main-wrapper {
        margin-left: 0 !important;
    }
}
