/* AI Workbench - Modern Sidebar Layout */

:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --info-color: #17a2b8;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --sidebar-width: 320px;
    --sidebar-collapsed-width: 70px;
    --header-height: 60px;
    --sidebar-bg: #1a1d29;
    --sidebar-hover: #2c3142;
    --sidebar-active: #007bff;
    --content-bg: #f5f6fa;
    /* Viewport boundary spacing */
    --viewport-margin: 10px;
    --mobile-viewport-margin: 10px;
}

/* Layout Structure */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: white;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transition: all 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.app-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    background: var(--content-bg);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.app-main.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* Footer adjustments for sidebar layout */
/* Footer positioning - only add margin when sidebar exists */
.app-sidebar ~ .app-main ~ footer {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
}

.sidebar-collapsed + .app-main + footer,
.app-main.sidebar-collapsed ~ footer {
    margin-left: var(--sidebar-collapsed-width);
}

/* Header */
.app-header {
    background: white;
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: between;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: relative;
    z-index: 1050;
    overflow: visible;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
    position: relative;
    overflow: visible;
    z-index: 1060;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--dark-color);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.sidebar-toggle:hover {
    background-color: #f8f9fa;
}

/* Bootstrap Dropdown Fixes for Header - Viewport-aware positioning */
.app-header .dropdown-menu {
    position: fixed !important;
    z-index: 9999 !important;
    transform: none !important;
    will-change: transform, opacity;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12) !important;
    border: 1px solid #e0e6ed !important;
    border-radius: 8px !important;
    top: var(--header-height) !important;
    /* Viewport-aware positioning - align with dropdown arrow */
    right: max(10px, min(20px, calc(100vw - var(--dropdown-width, 200px) - 10px))) !important;
    left: auto !important;
    margin: 0 !important;
    inset: auto !important;
    min-width: 200px;
    --dropdown-width: 200px;
    /* Ensure dropdown never exceeds viewport width minus padding */
    max-width: calc(100vw - 20px);
}

/* User profile dropdown - standard width */
.app-header .dropdown-menu:not([style*="width"]) {
    --dropdown-width: 200px;
    min-width: 200px;
}

/* Notifications dropdown - wider */
.app-header .dropdown-menu[style*="width: 320px"] {
    --dropdown-width: 320px;
    min-width: 320px;
    max-width: min(320px, calc(100vw - 20px));
}

/* Dynamic positioning for ultra-wide screens */
@media (min-width: 1600px) {
    .app-header .dropdown-menu {
        right: max(10px, min(20px, calc(100vw - var(--dropdown-width, 200px) - 10px))) !important;
    }
}

/* Large screens - standard positioning */
@media (min-width: 1200px) and (max-width: 1599px) {
    .app-header .dropdown-menu {
        right: max(10px, min(20px, calc(100vw - var(--dropdown-width, 200px) - 10px))) !important;
    }
}

/* Medium screens - closer to edge */
@media (min-width: 768px) and (max-width: 1199px) {
    .app-header .dropdown-menu {
        right: max(10px, min(20px, calc(100vw - var(--dropdown-width, 200px) - 10px))) !important;
        min-width: min(200px, calc(100vw - 20px));
    }
    
    .app-header .dropdown-menu[style*="width: 320px"] {
        min-width: min(280px, calc(100vw - 20px));
        max-width: calc(100vw - 20px);
    }
}

/* Small screens - always 10px from edge */
@media (max-width: 767px) {
    .app-header .dropdown-menu {
        right: 10px !important;
        min-width: min(180px, calc(100vw - 20px));
        max-width: calc(100vw - 20px);
    }
    
    .app-header .dropdown-menu[style*="width: 320px"] {
        min-width: min(250px, calc(100vw - 20px));
        max-width: calc(100vw - 20px);
    }
}

/* Extra small screens - full width minus margin */
@media (max-width: 479px) {
    .app-header .dropdown-menu {
        right: 10px !important;
        left: 10px !important;
        min-width: auto;
        max-width: none;
        width: calc(100vw - 20px);
    }
}

/* Ensure dropdown containers in header have static positioning to not interfere */
.app-header .dropdown {
    position: static !important;
    z-index: auto;
}


/* Sidebar Components */
.sidebar-brand {
    padding: 15px 20px;
    border-bottom: 1px solid #2c3142;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
    position: sticky;
    top: 0;
    background: var(--sidebar-bg);
    z-index: 10;
}

.sidebar-brand:hover {
    color: white;
    text-decoration: none;
}

.sidebar-brand-icon {
    font-size: 24px;
    color: var(--primary-color);
}

.sidebar-brand-text {
    font-weight: bold;
    font-size: 18px;
    transition: opacity 0.3s ease;
}

.app-sidebar.collapsed .sidebar-brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-nav {
    padding: 10px 0;
    margin: 0;
    list-style: none;
}

.sidebar-section {
    padding: 15px 20px 10px 20px;
    border-bottom: 1px solid #2c3142;
    margin-bottom: 10px;
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #6c7293;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.app-sidebar.collapsed .sidebar-section-title {
    opacity: 0;
    height: 0;
    margin: 0;
    overflow: hidden;
}

.sidebar-mini-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin: 10px 15px;
    padding: 12px;
    border: 1px solid #2c3142;
}

.sidebar-mini-section h6 {
    color: white;
    font-size: 12px;
    margin-bottom: 8px;
    font-weight: 600;
}

.sidebar-mini-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    color: #8b92a5;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

.sidebar-mini-item:hover {
    background: var(--sidebar-hover);
    color: white;
    text-decoration: none;
}

.sidebar-mini-item i {
    width: 16px;
    margin-right: 8px;
    font-size: 14px;
}

.sidebar-mini-count {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
}

.app-sidebar.collapsed .sidebar-mini-section {
    display: none;
}

.sidebar-nav-item {
    position: relative;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: #8b92a5;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
    margin: 2px 8px;
    border-radius: 6px;
}

.sidebar-nav-link:hover {
    color: white;
    background: var(--sidebar-hover);
    text-decoration: none;
    transform: translateX(2px);
}

.sidebar-nav-link.active {
    color: white;
    background: var(--sidebar-active);
    box-shadow: inset 3px 0 0 var(--primary-color);
}

.sidebar-nav-icon {
    width: 20px;
    margin-right: 12px;
    font-size: 18px;
    text-align: center;
}

.sidebar-nav-text {
    transition: opacity 0.3s ease;
    flex: 1;
}

.app-sidebar.collapsed .sidebar-nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-nav-arrow {
    font-size: 12px;
    transition: all 0.3s ease;
    opacity: 0.7;
    margin-left: auto;
}

.sidebar-nav-link:hover .sidebar-nav-arrow {
    opacity: 1;
}

.sidebar-nav-link[aria-expanded="true"] .sidebar-nav-arrow {
    transform: rotate(90deg);
    color: var(--primary-color);
    opacity: 1;
}

/* Improved hover states for dropdown triggers */
.sidebar-nav-link[data-bs-toggle="collapse"]:hover {
    background: var(--sidebar-hover);
    color: white;
}

.sidebar-nav-link[aria-expanded="true"] {
    background: var(--sidebar-hover);
    color: white;
}

/* Dropdown Menus - Kept for potential future use */
.sidebar-dropdown {
    background: #151821;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease;
    border-radius: 0 0 6px 6px;
    margin: 0 8px;
}

.sidebar-dropdown.show {
    max-height: 300px;
    opacity: 1;
    padding: 4px 0;
}

.sidebar-dropdown-item {
    padding: 8px 20px 8px 52px;
    font-size: 13px;
    margin: 1px 0;
    border-radius: 4px;
    position: relative;
}

.sidebar-dropdown-item::before {
    content: '';
    position: absolute;
    left: 32px;
    top: 50%;
    width: 8px;
    height: 1px;
    background: #6c7293;
    transform: translateY(-50%);
}

.sidebar-dropdown-item:hover::before {
    background: var(--primary-color);
}

/* Collapsed sidebar dropdown behavior */
.app-sidebar.collapsed .sidebar-dropdown {
    display: none;
}

/* Content Area */
.app-content {
    padding: 0 20px 20px 20px;
    min-height: calc(100vh - var(--header-height));
    width: 100%;
    max-width: calc(100vw - var(--sidebar-width));
    box-sizing: border-box;
    position: relative;
    z-index: 1020;
    transition: max-width 0.3s ease;
}

/* Content area expansion when sidebar collapsed */
.app-main.sidebar-collapsed .app-content {
    max-width: calc(100vw - var(--sidebar-collapsed-width));
}

/* Content containers should respect sidebar layout */
.app-main .container-fluid {
    max-width: calc(100vw - var(--sidebar-width));
    padding-left: 0;
    padding-right: 0;
    padding-top: 0;
    transition: max-width 0.3s ease;
    width: 100%;
}

.app-main.sidebar-collapsed .container-fluid {
    max-width: calc(100vw - var(--sidebar-collapsed-width));
}

/* Ensure all content containers expand smoothly */
.app-main .main-container {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* Card and form responsiveness improvements */
.app-main .card,
.app-main .form-control,
.app-main .input-group,
.app-main .table-responsive {
    transition: all 0.3s ease;
    max-width: 100%;
}

/* Tab content areas */
.app-main .tab-content,
.app-main .tab-pane {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* Navigation tabs */
.app-main .nav-tabs {
    transition: all 0.3s ease;
}

/* Grid system improvements */
.app-main .row {
    transition: all 0.3s ease;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.app-main .row > [class*="col-"] {
    transition: all 0.3s ease;
}

/* Ensure chat containers and components don't overflow */
.chat-container,
.main-container {
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible !important; /* Allow dropdowns to show above container */
    box-sizing: border-box;
    position: relative;
}

/* Chat Interface Specific */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height) - 40px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

/* Chat interface expansion */
.app-main.sidebar-collapsed .chat-container {
    width: 100%;
    max-width: 100%;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.chat-input-area {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

/* Message Styles */
.message {
    margin-bottom: 20px;
}

.message-user {
    text-align: right;
}

.message-ai {
    text-align: left;
}

.message-content {
    display: inline-block;
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
}

.message-user .message-content {
    background: var(--primary-color);
    color: white;
}

.message-ai .message-content {
    background: #e9ecef;
    color: var(--dark-color);
}

/* Desktop-First Responsive Design */

/* Extra Large Screens (1400px+) */
@media (min-width: 1400px) {
    :root {
        --sidebar-width: 360px;
    }
    
    .app-content {
        padding: 0 30px 30px 30px;
    }
    
    .sidebar-mini-section {
        margin: 15px 20px;
        padding: 15px;
    }
    
    .lightbox-container.size-xl {
        width: 1400px;
    }
}

/* Large Screens (1200px+) */
@media (min-width: 1200px) {
    .app-content {
        padding: 0 25px 25px 25px;
        max-width: calc(100vw - var(--sidebar-width));
    }
    
    .chat-container {
        max-width: 100%;
    }
    
    .app-main .container-fluid {
        max-width: calc(100vw - var(--sidebar-width));
    }
    
    .app-main.sidebar-collapsed .container-fluid {
        max-width: calc(100vw - var(--sidebar-collapsed-width));
    }
    
    .header-right .btn {
        margin: 0 2px;
    }
}

/* Desktop and Tablet - Ensure sidebar layout (768px and up) */
@media (min-width: 768px) {
    .app-main {
        margin-left: var(--sidebar-width) !important;
    }
    
    .app-main.sidebar-collapsed {
        margin-left: var(--sidebar-collapsed-width) !important;
    }
}

/* Desktop (992px to 1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
    .sidebar-mini-section h6 {
        font-size: 11px;
    }
    
    .sidebar-mini-item {
        padding: 5px 6px;
        font-size: 12px;
    }
    
    .header-right .position-relative {
        width: 240px !important;
    }
}

/* Tablet Landscape (768px to 991px) */
@media (max-width: 991px) and (min-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }
    
    .sidebar-nav-text {
        font-size: 14px;
    }
    
    .app-content {
        padding: 0 20px 20px 20px;
        max-width: calc(100vw - var(--sidebar-width));
    }
    
    .app-main .container-fluid {
        max-width: calc(100vw - var(--sidebar-width));
    }
    
    .app-main.sidebar-collapsed .container-fluid {
        max-width: calc(100vw - var(--sidebar-collapsed-width));
    }
    
    .sidebar-mini-section {
        margin: 8px 12px;
        padding: 10px;
    }
    
    .sidebar-mini-section h6 {
        font-size: 11px;
    }
    
    .header-right .d-none.d-lg-block {
        display: none !important;
    }
    
    .header-right .d-none.d-md-inline-flex {
        display: none !important;
    }
    
    /* Simplified header for tablets */
    .app-header h5 {
        font-size: 1.1rem;
    }
}

/* Tablet Portrait & Mobile Landscape (480px to 767px) */
@media (max-width: 767px) and (min-width: 480px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        box-shadow: none;
    }
    
    .app-sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.3);
    }
    
    .app-main {
        margin-left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }
    
    /* Enhanced mobile dropdown behavior */
    .sidebar-dropdown.show {
        max-height: 200px; /* Smaller on tablet */
    }
    
    .app-content {
        padding: 0 15px 15px 15px;
        max-width: 100vw;
    }
    
    .app-main .container-fluid {
        max-width: 100vw;
    }
    
    .chat-container {
        height: calc(100vh - var(--header-height) - 30px);
        margin: 0;
        max-width: 100%;
    }
    
    /* Tablet header adjustments */
    .app-header h5 {
        font-size: 1rem;
    }
    
    .header-right .d-none.d-md-inline-flex,
    .header-right .d-none.d-lg-block {
        display: none !important;
    }
    
    /* Tablet cards */
    .main-container {
        margin-bottom: 15px;
    }
    
    /* Tablet message bubbles */
    .message-content {
        max-width: 80%;
    }
    
    /* Simplified sidebar for tablets */
    .sidebar-mini-section {
        display: block;
    }
    
    .sidebar-section-title {
        font-size: 10px;
    }
}

/* Mobile Portrait (320px to 479px) */
@media (max-width: 479px) {
    :root {
        --sidebar-width: 100vw;
        --header-height: 50px;
    }
    
    .app-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        box-shadow: none;
    }
    
    .app-sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    }
    
    .app-main {
        margin-left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.6);
        z-index: 999;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }
    
    /* Mobile-specific dropdown behavior */
    .sidebar-dropdown.show {
        max-height: 150px; /* Even smaller on mobile */
    }
    
    /* Ensure dropdowns don't get cut off on mobile */
    .sidebar-nav-item:last-child .sidebar-dropdown.show {
        max-height: 120px;
    }
    
    .app-content {
        padding: 0 12px 12px 12px;
        max-width: 100vw;
    }
    
    .app-main .container-fluid {
        max-width: 100vw;
    }
    
    .app-header {
        height: var(--header-height);
        padding: 0 15px;
    }
    
    .chat-container {
        height: calc(100vh - var(--header-height) - 24px);
        margin: 0;
        max-width: 100%;
    }
    
    /* Mobile header - minimal */
    .app-header h5 {
        font-size: 0.9rem;
        display: none; /* Hide on very small screens */
    }
    
    .header-right > *:not(.dropdown) {
        display: none !important;
    }
    
    .header-right .dropdown .btn {
        padding: 4px 8px;
    }
    
    /* Mobile sidebar - hide mini sections */
    .sidebar-mini-section {
        display: none;
    }
    
    .sidebar-section-title {
        font-size: 9px;
        margin-bottom: 8px;
    }
    
    .sidebar-nav-link {
        padding: 8px 15px;
        font-size: 13px;
    }
    
    .sidebar-brand {
        padding: 12px 15px;
    }
    
    /* Mobile cards - full width */
    .main-container {
        margin-bottom: 12px;
        border-radius: 8px;
    }
    
    /* Mobile message bubbles - larger */
    .message-content {
        max-width: 90%;
        font-size: 14px;
    }
    
    /* Mobile lightboxes - respect viewport boundaries */
    :root {
        --mobile-viewport-margin: 10px;
    }
    
    .lightbox-container {
        width: calc(100vw - 2 * var(--mobile-viewport-margin)) !important;
        height: calc(100vh - 2 * var(--mobile-viewport-margin)) !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 8px;
    }
    
    .lightbox-header {
        padding: 12px 15px;
    }
    
    .lightbox-content {
        padding: 15px;
        max-height: calc(100vh - 2 * var(--mobile-viewport-margin) - 120px);
    }
    
    .lightbox-title {
        font-size: 1.1rem;
    }
}

/* Ultra-wide screens (1600px+) - Enhanced desktop experience */
@media (min-width: 1600px) {
    :root {
        --sidebar-width: 380px;
    }
    
    .app-content {
        padding: 0 35px 35px 35px;
        max-width: calc(100vw - var(--sidebar-width));
    }
    
    .app-main .container-fluid {
        max-width: calc(100vw - var(--sidebar-width));
    }
    
    .app-main.sidebar-collapsed .container-fluid {
        max-width: calc(100vw - var(--sidebar-collapsed-width));
    }
    
    .sidebar-mini-section {
        margin: 15px 25px;
        padding: 18px;
    }
    
    .sidebar-brand {
        padding: 20px 25px;
    }
    
    .sidebar-nav-link {
        padding: 12px 25px;
    }
    
    .header-right .position-relative input {
        width: 320px !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .sidebar-nav-link:hover {
        transform: none; /* Disable hover transform on touch devices */
    }
    
    .card:hover {
        transform: none;
    }
    
    .btn:hover {
        transform: none;
    }
    
    /* Larger touch targets */
    .sidebar-nav-link {
        padding: 14px 20px;
        min-height: 48px; /* Ensure minimum touch target size */
    }
    
    .sidebar-dropdown-item {
        padding: 12px 20px 12px 52px;
        min-height: 44px;
    }
    
    .lightbox-close {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    
    /* Improved dropdown arrow for touch */
    .sidebar-nav-arrow {
        font-size: 16px;
        padding: 4px;
    }
}

/* Utility Classes */
.main-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.btn-primary {
    background: linear-gradient(45deg, #007bff, #0056b3);
    border: none;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

/* Form Controls */
.form-control {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Enhanced form responsiveness */
.app-main textarea,
.app-main input[type="text"],
.app-main input[type="email"],
.app-main input[type="password"],
.app-main input[type="search"],
.app-main select {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Input groups */
.app-main .input-group {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

.app-main .input-group .form-control {
    flex: 1;
    min-width: 0;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.15);
}

/* Ensure input groups don't overflow */
.input-group {
    width: 100%;
    max-width: 100%;
}

/* Table responsiveness */
.table-responsive {
    overflow-x: auto;
    max-width: 100%;
}

/* Card responsiveness */
.card {
    max-width: 100%;
    overflow-x: hidden;
}

/* Ensure rows don't overflow horizontally but allow vertical overflow for dropdowns */
.row {
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
}

/* Enhanced responsive layout for all content */
.app-main .container-fluid .row {
    margin-left: 0;
    margin-right: 0;
    transition: all 0.3s ease;
    width: 100%;
}

.app-main .container-fluid .row > [class*="col-"] {
    padding-left: 12px;
    padding-right: 12px;
    transition: all 0.3s ease;
    min-width: 0;
    word-wrap: break-word;
}

/* Ensure main-container in all layouts has proper responsive behavior */
.app-main .row .main-container {
    margin-bottom: 0;
    height: auto;
    min-height: 100%;
    box-sizing: border-box;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
    overflow: visible !important;
}

/* Fix for Bootstrap grid gutters with g-4 class */
.app-main .row.g-4 {
    --bs-gutter-x: 1.5rem;
    --bs-gutter-y: 1.5rem;
    transition: all 0.3s ease;
}

/* Enhanced column responsiveness */
.app-main .col-lg-9 .main-container,
.app-main .col-lg-3 .main-container,
.app-main .col-md-8 .main-container,
.app-main .col-md-4 .main-container,
.app-main .col-12 .main-container {
    border-radius: 12px;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* Project tabs and navigation */
.app-main .nav-tabs-custom {
    transition: all 0.3s ease;
}

.app-main .tab-content .tab-pane {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* Interactive elements expansion */
.app-main .btn-group,
.app-main .dropdown,
.app-main .modal-dialog {
    transition: all 0.3s ease;
}

/* Content areas within tabs */
.app-main .conversations-list,
.app-main .project-steps,
.app-main .agent-configuration,
.app-main .workflow-config {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* Message areas and chat interfaces */
.app-main .message-container,
.app-main .message-input-area,
.app-main .chat-header {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* Responsive conversation layout fixes */
@media (max-width: 991px) {
    .app-main .col-lg-9,
    .app-main .col-lg-3 {
        margin-bottom: 1rem;
    }
    
    .app-main .col-lg-9 .main-container {
        height: calc(100vh - 280px) !important;
        min-height: 500px !important;
    }
}

/* Specific fixes for chat interface components */
.message-bubble {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

.message-content pre,
.message-content code {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Form inputs in sidebar layout */
.app-main textarea,
.app-main input[type="text"],
.app-main input[type="email"],
.app-main input[type="password"],
.app-main select {
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure message items don't cause horizontal scroll */
.message-item {
    max-width: 100%;
    overflow-wrap: break-word;
}

/* Make sure Bootstrap columns behave properly */
.app-main [class*="col-"] {
    min-width: 0;
    word-wrap: break-word;
}

/* Fix for any remaining width issues */
.app-main * {
    box-sizing: border-box;
}

/* Orchestrator page specific fixes */
.orchestrator-panel,
.orchestrator-status {
    max-width: 100%;
    overflow-x: hidden;
}

/* Alerts - Base Styling */
.alert {
    border-radius: 8px;
    border: none;
}

/* Floating Toast Notifications */
.alert-toast {
    position: fixed !important;
    top: 20px;
    right: 20px;
    z-index: 10000 !important;
    min-width: 320px;
    max-width: 420px;
    margin: 0;
    padding: 12px 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    backdrop-filter: blur(10px);
    animation: slideInRight 0.3s ease-out;
    transform-origin: top right;
    will-change: transform, opacity;
    pointer-events: auto;
}

/* Toast animation */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Toast fade out animation */
.alert-toast.fade:not(.show) {
    animation: slideOutRight 0.3s ease-in forwards;
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(100%) scale(0.9);
    }
}

/* Dynamic stacking managed by JavaScript - initial position */
.alert-toast {
    /* JavaScript will dynamically set top position based on visible toasts */
}

/* Enhanced toast styling */
.alert-toast.alert-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.alert-toast.alert-danger {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.alert-toast.alert-warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    color: #212529;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

.alert-toast.alert-info {
    background: linear-gradient(135deg, #17a2b8 0%, #007bff 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

/* Toast close button styling */
.alert-toast .btn-close {
    color: inherit;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.alert-toast .btn-close:hover {
    opacity: 1;
}

/* Toast icons */
.alert-toast i {
    margin-right: 8px;
    font-weight: bold;
}

/* Responsive toast positioning */
@media (max-width: 768px) {
    .alert-toast {
        top: 10px;
        right: 10px;
        left: 10px;
        min-width: auto;
        max-width: none;
        width: calc(100vw - 20px);
    }

    /* Mobile stacking - dynamically managed by JavaScript */
}

@media (max-width: 480px) {
    .alert-toast {
        padding: 10px 12px;
        font-size: 14px;
    }

    /* Mobile stacking - dynamically managed by JavaScript */
}

/* Debug info */
.debug-info {
    font-family: monospace;
    font-size: 0.9em;
}

/* Badge Styles */
.badge {
    border-radius: 6px;
}

/* Project Cards */
.project-card {
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    overflow: visible !important;
}

.project-card.h-100 {
    height: auto !important;
    min-height: 100%;
}

.project-card .card-body {
    overflow: visible !important;
    position: relative;
}

.project-card .card-body.d-flex.flex-column {
    overflow: visible !important;
}

/* Ensure project card columns allow overflow */
.col-xl-3:has(.project-card),
.col-lg-4:has(.project-card),
.col-md-6:has(.project-card) {
    overflow: visible !important;
}

.project-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

/* Project card dropdown fixes - copied from project.php conversation cards */
.project-card .dropdown {
    position: relative;
}

/* Force dropdown to stay in position - override Popper.js */
.project-card .dropdown-menu[data-bs-popper] {
    position: absolute !important;
    inset: 0px auto auto 0px !important;
    margin: 0px !important;
    transform: translate3d(0px, 38px, 0px) !important;
    z-index: 1070 !important;
}

.project-card .dropdown-menu.show[data-bs-popper] {
    position: absolute !important;
    inset: 0px auto auto 0px !important;
    margin: 0px !important;
    transform: translate3d(0px, 38px, 0px) !important;
    z-index: 1070 !important;
}

.project-card .dropdown-menu.dropdown-menu-end[data-bs-popper] {
    position: absolute !important;
    inset: 0px 0px auto auto !important;
    margin: 0px !important;
    transform: translate3d(0px, 38px, 0px) !important;
    right: 0 !important;
    left: auto !important;
    z-index: 1070 !important;
}

/* Ensure nav tabs don't cover dropdowns */
.nav-tabs {
    position: relative;
    z-index: 1050 !important;
}

/* Removed problematic custom lightbox system - use Bootstrap modals instead */

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(50px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* Global Search Dropdown */
#globalSearchContainer {
    position: relative;
    z-index: 10000;
    overflow: visible;
}

.search-dropdown {
    position: fixed;
    top: calc(var(--header-height) + 4px);
    left: var(--viewport-margin);
    right: auto;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    max-height: min(400px, calc(100vh - var(--header-height) - 2 * var(--viewport-margin)));
    contain: layout style paint;
    will-change: transform, opacity;
    overflow-y: auto;
    margin-top: 4px;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    /* Viewport-aware width - always stay within boundaries */
    width: min(600px, calc(100vw - 2 * var(--viewport-margin)));
    max-width: calc(100vw - 2 * var(--viewport-margin));
    box-sizing: border-box;
    visibility: hidden;
}

.search-dropdown.align-right {
    left: auto;
    right: var(--viewport-margin);
}

/* Ensure dropdown is fully contained within viewport */
body {
    overflow-x: auto; /* Allow horizontal scroll if needed, but dropdown won't cause it */
}

/* Prevent any child elements from causing horizontal overflow */
.search-dropdown * {
    max-width: 100%;
    box-sizing: border-box;
}

.search-dropdown.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
    visibility: visible;
}

.search-results {
    max-height: 350px;
    overflow-y: auto;
    padding: 8px 0;
}

.search-section {
    margin-bottom: 16px;
}

.search-section:last-child {
    margin-bottom: 0;
}

.search-section-title {
    padding: 8px 16px 4px 16px;
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 4px;
    background: #f8f9fa;
}

.search-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background-color: #f8f9fa;
}

.search-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 2px;
    flex-shrink: 0;
}

.search-item-icon.project {
    background-color: #e3f2fd;
    color: #1976d2;
}

.search-item-icon.agent {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.search-item-icon.document {
    background-color: #e3f2fd;
    color: #1976d2;
}

.bg-purple {
    background-color: #7b1fa2 !important;
}

.search-item-content {
    flex: 1;
    min-width: 0;
}

.search-item-title {
    font-weight: 600;
    font-size: 14px;
    color: #212529;
    margin-bottom: 2px;
    line-height: 1.3;
}

.search-item-description {
    font-size: 13px;
    color: #6c757d;
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-wrap: break-word;
    hyphens: auto;
}

.search-item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #868e96;
}

.search-item-meta .badge {
    font-size: 10px;
    padding: 2px 6px;
}

.search-empty,
.search-loading,
.search-error {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
}

.search-empty i,
.search-loading i,
.search-error i {
    font-size: 32px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.6;
}

.search-loading .spinner-border {
    width: 32px;
    height: 32px;
    margin-bottom: 12px;
}

.search-empty p,
.search-loading p,
.search-error p {
    margin: 0 0 4px 0;
    font-size: 14px;
}

.search-empty small,
.search-loading small,
.search-error small {
    font-size: 12px;
    color: #868e96;
}

/* Mobile responsiveness for search dropdown */
@media (max-width: 991px) {
    #globalSearchContainer {
        display: none !important;
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    #globalSearch {
        width: 240px !important;
    }
    
    .search-dropdown {
        width: min(500px, calc(100vw - 2 * var(--viewport-margin)));
        min-width: min(400px, calc(100vw - 2 * var(--viewport-margin)));
    }
}

@media (min-width: 1200px) and (max-width: 1399px) {
    .search-dropdown {
        width: min(600px, calc(100vw - 2 * var(--viewport-margin)));
        min-width: min(450px, calc(100vw - 2 * var(--viewport-margin)));
    }
}

@media (min-width: 1400px) {
    #globalSearch {
        width: 320px !important;
    }
    
    .search-dropdown {
        width: min(720px, calc(100vw - 2 * var(--viewport-margin)));
        min-width: min(500px, calc(100vw - 2 * var(--viewport-margin)));
    }
}

@media (min-width: 1600px) {
    .search-dropdown {
        width: min(800px, calc(100vw - 2 * var(--viewport-margin)));
        min-width: min(600px, calc(100vw - 2 * var(--viewport-margin)));
    }
}

/* Ensure no element in the header can cause horizontal overflow but allow vertical overflow for dropdowns */
.app-header {
    overflow-x: hidden;
    overflow-y: visible;
}

/* Ensure header-right doesn't clip the dropdown */
.header-right {
    position: relative;
    overflow: visible;
    z-index: 1060;
}

#globalSearchContainer {
    overflow: visible; /* Allow dropdown to show outside container */
}

/* Additional dropdown positioning fixes */
.app-header .dropdown-toggle::after {
    margin-left: 0.5em;
}

/* Main Container Dropdown Fixes - Ensure proper overlay positioning */
.main-container .dropdown {
    position: static; /* Ensure dropdown trigger doesn't interfere */
}

.main-container .dropdown-menu {
    position: absolute !important;
    z-index: 1055 !important; /* Above modals and main content */
    will-change: transform, opacity;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid #e0e6ed !important;
    border-radius: 8px !important;
    margin: 0 !important;
    inset: auto !important;
    transform: none !important;
}

/* Ensure dropdown-menu-end works properly within main-container */
.main-container .dropdown-menu.dropdown-menu-end {
    right: 0 !important;
    left: auto !important;
}

/* Tab content within main-container should allow overflow for dropdowns */
.main-container .tab-content,
.main-container .tab-pane {
    overflow: visible !important;
    position: relative;
    z-index: 1;
}

/* Cards within main-container should allow dropdown overflow */
.main-container .card {
    overflow: visible !important;
    position: relative;
    z-index: 1;
}

/* Conversation cards and project cards dropdown fixes */
.main-container .conversation-card .dropdown,
.main-container .project-card .dropdown,
.main-container .card .dropdown {
    position: relative;
    z-index: auto;
}

.main-container .conversation-card .dropdown-menu,
.main-container .project-card .dropdown-menu,
.main-container .card .dropdown-menu {
    position: absolute !important;
    z-index: 1055 !important;
    inset: auto !important;
}

/* Three-dots menu dropdown positioning improvements */
.main-container .btn-outline-secondary.dropdown-toggle {
    position: relative;
}

/* Ensure dropdown menus stay within viewport boundaries */
.main-container .dropdown-menu {
    min-width: 160px;
    max-width: min(250px, calc(100vw - 40px));
}

/* Mobile responsive dropdown behavior within main-container */
@media (max-width: 767px) {
    .main-container .dropdown-menu {
        position: fixed !important;
        z-index: 1060 !important;
        min-width: 180px;
        max-width: calc(100vw - 20px);
        /* Center dropdown on mobile for better accessibility */
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        margin-top: 5px !important;
    }

    .main-container .dropdown-menu.dropdown-menu-end {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
    }
}

/* Small tablet responsive behavior */
@media (min-width: 768px) and (max-width: 991px) {
    .main-container .dropdown-menu {
        max-width: min(220px, calc(100vw - 30px));
    }
}

/* Project Header Dropdown - Specific Fix for Header Three-Dots Menu */
.main-container .d-flex .dropdown {
    position: static !important;
    z-index: auto;
}

.main-container .d-flex .dropdown-menu {
    position: fixed !important;
    z-index: 1060 !important;
    transform: none !important;
    will-change: transform, opacity;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid #e0e6ed !important;
    border-radius: 8px !important;
    margin: 0 !important;
    inset: auto !important;
    min-width: 180px;
    max-width: min(250px, calc(100vw - 40px));
}

/* Specific positioning for project header dropdown-menu-end */
.main-container .d-flex .dropdown-menu.dropdown-menu-end {
    right: 20px !important;
    left: auto !important;
    top: auto !important;
    /* Position dropdown below the three dots button with proper spacing */
    margin-top: 8px !important;
}

/* Dynamic positioning for three-dots dropdown in project header */
.main-container .dropdown-toggle[data-bs-toggle="dropdown"] + .dropdown-menu {
    position: fixed !important;
    z-index: 1060 !important;
}

/* Ensure project header container allows overflow for dropdowns */
.main-container .d-flex.align-items-center.justify-content-between {
    overflow: visible !important;
    position: relative;
    z-index: 1;
}

/* Project header main container should allow dropdown overflow */
.main-container.py-2.px-3 {
    overflow: visible !important;
    position: relative;
    z-index: 1040;
}

/* Ensure all project header row and column containers allow dropdown overflow */
.container-fluid .row .col-12 .main-container {
    overflow: visible !important;
    position: relative;
    z-index: 1040;
}

.container-fluid .row .col-12 {
    overflow: visible !important;
    position: relative;
}

.container-fluid .row {
    overflow: visible !important;
    position: relative;
}

/* Specific fix for project page container structure */
.container-fluid {
    overflow-x: hidden;
    overflow-y: visible !important;
}

/* Enhanced Interactive Element Responsiveness */

/* Button groups and toolbars */
.app-main .btn-toolbar,
.app-main .btn-group {
    transition: all 0.3s ease;
    flex-wrap: wrap;
}

/* Pagination and navigation */
.app-main .pagination {
    transition: all 0.3s ease;
    flex-wrap: wrap;
    justify-content: center;
}

/* Responsive tables */
.app-main .table-responsive {
    transition: all 0.3s ease;
    overflow-x: auto;
    max-width: 100%;
}

.app-main .table {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* Progress bars and indicators */
.app-main .progress {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* Accordion and collapsible content */
.app-main .accordion,
.app-main .collapse {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* List groups */
.app-main .list-group {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* Carousel and media components */
.app-main .carousel,
.app-main .embed-responsive {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* Custom workbench components */
.app-main .agent-card,
.app-main .project-card,
.app-main .conversation-card {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* Sidebar state-specific optimizations */
.app-main.sidebar-collapsed .container-fluid {
    transition: all 0.3s ease;
}

.app-main.sidebar-collapsed .main-container {
    transition: all 0.3s ease;
}

/* Enhanced form layout responsiveness */
.app-main .form-row,
.app-main .form-group {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* Text areas with auto-resize */
.app-main textarea {
    transition: all 0.3s ease;
    resize: vertical;
    min-height: 80px;
}

/* Select and multi-select elements */
.app-main select[multiple] {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* File upload areas */
.app-main .file-upload-area,
.app-main .dropzone {
    transition: all 0.3s ease;
    width: 100%;
    max-width: 100%;
}

/* Code editors and syntax highlighting */
.app-main .code-editor,
.app-main .highlight,
.app-main pre {
    transition: all 0.3s ease;
    max-width: 100%;
    overflow-x: auto;
}

/* Ensure dropdown menus are not cut off by main content */
.app-main {
    position: relative;
    z-index: 1030;
}

/* Force header dropdowns above all content */
.app-header {
    z-index: 1050 !important;
}

.header-right {
    z-index: 1070 !important;
}

/* Clean Bootstrap Modal Fixes - Minimal and Effective */
/* Force backdrop to be behind modal - using negative stacking */
.modal-backdrop,
.modal-backdrop.fade,
.modal-backdrop.show,
div.modal-backdrop {
    z-index: 1040 !important;
    position: fixed !important;
}

/* Force modal container to be above backdrop */
.modal,
.modal.fade,
.modal.show,
div.modal {
    z-index: 1055 !important;
    position: fixed !important;
}

/* Ensure modal dialog and content create proper stacking context */
.modal-dialog,
.modal-content {
    position: relative !important;
    z-index: auto !important;
}

/* Specific fix for tips modal */
#tipsModal {
    z-index: 1056 !important;
}

#tipsModal .modal-dialog {
    position: relative !important;
}

/* Ensure sidebar and header don't interfere with modals */
body.modal-open .app-sidebar,
body.modal-open .app-header,
body.modal-open .app-main {
    z-index: 1030;
}

/* Perfect Modal Centering */
.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 1rem);
}

.modal-dialog-centered::before {
    content: "";
    display: block;
    height: calc(100vh - 1rem);
    height: -webkit-min-content;
    height: -moz-min-content;
    height: min-content;
}

/* Tips Modal - Welcome Message Centering */
#tipsModal .modal-dialog {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 3.5rem);
    margin: 1.75rem auto;
}

#tipsModal .modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* New Conversation Modal - Enhanced Centering */
#newConversationModal .modal-dialog {
    margin: 1rem auto;
    max-width: 90%;
    width: 100%;
    max-height: calc(100vh - 2rem);
}

#newConversationModal .modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* Responsive modal fixes */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    #newConversationModal .modal-dialog {
        margin: 0.5rem auto;
        max-width: calc(100% - 1rem);
        max-height: calc(100vh - 1rem);
    }
}

@media (min-width: 576px) {
    #newConversationModal .modal-dialog {
        max-width: 540px;
    }
}

@media (min-width: 992px) {
    #newConversationModal .modal-dialog {
        max-width: 800px;
    }
}

/* Conversation Type Cards in Modal */
.conversation-type-card {
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.conversation-type-card:hover {
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.conversation-type-card.active {
    border-color: #007bff;
    background-color: rgba(0, 123, 255, 0.05);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.15);
}

.conversation-type-card .card-body {
    padding: 1.5rem 1rem;
}

/* Responsive conversation cards */
@media (max-width: 767px) {
    .conversation-type-card .card-body {
        padding: 1rem 0.75rem;
    }

    .conversation-type-card .card-title {
        font-size: 0.95rem;
    }

    .conversation-type-card small {
        font-size: 0.8rem;
    }

    .conversation-type-card i {
        font-size: 2.5rem !important;
    }
}


/* Responsive lightboxes - viewport-aware */
@media (max-width: 768px) {
    :root {
        --viewport-margin: 15px;
    }
    
    .lightbox-container {
        width: calc(100vw - 2 * var(--viewport-margin));
        height: calc(100vh - 2 * var(--viewport-margin));
        max-width: none;
        max-height: none;
    }
    
    .lightbox-container.size-sm,
    .lightbox-container.size-md,
    .lightbox-container.size-lg,
    .lightbox-container.size-xl {
        width: calc(100vw - 2 * var(--viewport-margin));
        height: calc(100vh - 2 * var(--viewport-margin));
    }
    
    .lightbox-header {
        padding: 15px;
    }
    
    .lightbox-content {
        padding: 15px;
        max-height: calc(100vh - 2 * var(--viewport-margin) - 120px);
    }
}

/* Current Project Section in Sidebar */
.current-project-info {
    padding: 8px 12px;
    background: rgba(0, 123, 255, 0.1);
    border-radius: 6px;
    margin-bottom: 8px;
}

.current-project-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.current-project-title i {
    font-size: 1rem;
}

/* Sidebar Button Styling */
.sidebar-nav-button {
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    padding: 0;
    margin: 0;
}

/* Flash Message Layout */
.app-main > .container {
    padding-top: 0;
    padding-bottom: 0;
}

/* Flash message containers should have consistent spacing */
.app-main .container .alert {
    margin-top: 15px;
    margin-bottom: 15px;
}

/* Ensure the first flash message has proper top spacing */
.app-main .container:first-of-type .alert {
    margin-top: 20px;
}

/* Removed conversation page layout fix - now using standard container structure */

/* Ensure conversation content is properly positioned */
.main-container {
    position: relative;
    top: 0;
    margin-top: 0;
}


/* Sidebar Submenu Styles */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-submenu li {
    padding: 0;
}

.sidebar-submenu-link {
    display: flex;
    align-items: center;
    padding: 10px 20px 10px 45px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.sidebar-submenu-link:hover {
    background: var(--sidebar-hover);
    color: white;
}

.sidebar-submenu-link.active {
    background: linear-gradient(90deg, var(--sidebar-active) 0%, rgba(0, 123, 255, 0.2) 100%);
    color: white;
    border-left: 3px solid var(--sidebar-active);
}

.sidebar-submenu-link i {
    margin-right: 10px;
    font-size: 0.9rem;
}

/* Chevron rotation for collapsed menus */
.sidebar-nav-link[data-bs-toggle="collapse"] .bi-chevron-down {
    transition: transform 0.3s ease;
}

.sidebar-nav-link[data-bs-toggle="collapse"][aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}
