/* Chat Notification Bubble */
#chatNotificationBubble {
    position: fixed;
    bottom: 20px; /* Same height as language switcher */
    right: 20px; /* Right bottom corner */
    z-index: 1050;
}

/* Hide chat bubble and panel on mobile - use menu instead */
@media (max-width: 768px) {
    #chatNotificationBubble,
    #chatPanel,
    #chatPanelBackdrop {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
        z-index: -1 !important;
    }
}

.chat-notification-bubble {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s;
    text-decoration: none;
    position: relative;
    border: none;
    cursor: pointer;
}

.chat-notification-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    color: white;
    text-decoration: none;
}

.chat-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border-radius: 12px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(245, 158, 11, 0.5);
    }
}

/* Chat Panel Overlay */
.chat-panel {
    position: fixed;
    bottom: -9999px;
    right: -9999px;
    left: auto;
    width: 450px;
    height: calc(50vh - 40px);
    max-height: calc(50vh - 40px);
    min-height: 400px;
    background: white;
    box-shadow: -2px -2px 20px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.05);
    border-radius: 15px;
    z-index: -1;
    transition: right 0.3s ease-in-out, bottom 0.3s ease-in-out, z-index 0s 0.3s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: none !important;
    visibility: hidden !important;
}

.chat-panel.open {
    bottom: 20px;
    right: 0;
    z-index: 1060;
    transition: right 0.3s ease-in-out, bottom 0.3s ease-in-out, z-index 0s 0s;
    pointer-events: all !important;
    visibility: visible !important;
}

.chat-panel-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.chat-panel-header {
    position: relative;
}

.chat-panel-header h5 {
    margin: 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    flex: 1;
}

.chat-panel-header .chat-room-name {
    cursor: help;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    opacity: 0.95;
}

.chat-panel-header .chat-room-name:hover {
    opacity: 1;
}

.chat-panel-header .chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 0.5rem;
}

.chat-panel-header .btn-header-action {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
}

.chat-panel-header .btn-header-action:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
    transform: scale(1.05);
}

.chat-panel-header .btn-header-action.btn-header-danger:hover {
    background: rgba(220, 53, 69, 0.3);
    border-color: rgba(220, 53, 69, 0.5);
}

.chat-panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f8f9fa;
    padding: 1rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-panel-content .chat-index,
.chat-panel-content .chat-view {
    padding: 0;
    margin: 0;
    background: transparent;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-panel-content .container-fluid {
    padding: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Ensure chat view content fills properly */
.chat-panel-content .chat-view .container-fluid {
    height: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-panel-backdrop {
    position: fixed;
    top: -9999px;
    left: -9999px;
    width: 1px;
    height: 1px;
    background: rgba(0,0,0,0.3);
    z-index: -1;
    display: none !important;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none !important;
    visibility: hidden !important;
}

.chat-panel-backdrop.show {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1059;
    display: block !important;
    opacity: 1;
    pointer-events: all !important;
    visibility: visible !important;
}

/* Override chat styles for panel */
.chat-panel-content .chat-container {
    height: 100%;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* In panel mode, show sidebar content (rooms list) and hide the empty main area */
.chat-panel-content .chat-index .chat-sidebar {
    display: flex !important;
    flex-direction: column;
    width: 100% !important;
    border-right: none;
    flex: 1;
    min-height: 0;
}

/* Hide the empty main area in panel mode */
.chat-panel-content .chat-index .chat-main {
    display: none !important;
}

/* Make container show sidebar content in panel */
.chat-panel-content .chat-index .chat-container {
    display: flex !important;
    flex-direction: column;
}

/* Ensure rooms list is visible and scrollable */
.chat-panel-content .chat-rooms-list {
    display: block !important;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* Hide "Chat Rooms" header in panel mode */
.chat-panel-content .chat-sidebar-header {
    display: none !important;
}

/* Show both buttons side by side in panel mode */
.chat-panel-content .create-buttons {
    display: flex !important;
    gap: 0.5rem;
    flex-direction: row;
}

.chat-panel-content .create-buttons .btn {
    flex: 1;
    margin-bottom: 0 !important;
}

/* Hide sidebar in chat view (when viewing a specific chat) */
.chat-panel-content .chat-view .col-md-3,
.chat-panel-content .chat-view .chat-sidebar {
    display: none !important;
}

/* Make main content take full width in panel */
.chat-panel-content .chat-view .col-md-9,
.chat-panel-content .chat-view .row > div:not(.d-none) {
    width: 100% !important;
    flex: 1;
    max-width: 100%;
}

.chat-panel-content .chat-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
}

.chat-panel-content .chat-messages-area {
    height: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Hide inner chat header in panel mode */
.chat-panel-content .chat-header {
    display: none !important;
}

.chat-panel-content .page-header {
    display: none !important;
}

.chat-panel-content .page-header h1 {
    font-size: 1.25rem;
}

.chat-panel-content .page-actions {
    margin-top: 0.5rem;
}

.chat-panel-content .page-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-panel {
        width: calc(100% - 20px);
        right: calc(-100% - 20px);
        left: auto;
        height: calc(80vh - 40px);
        max-height: calc(80vh - 40px);
        min-height: 300px;
        border-radius: 15px;
        bottom: 80px;
        z-index: 1060;
        pointer-events: none;
        visibility: hidden;
    }
    
    .chat-panel.open {
        right: 10px;
        left: auto;
        pointer-events: all;
        visibility: visible;
    }
    
    #chatNotificationBubble {
        bottom: 15px; /* Same height as language switcher on mobile */
        right: 15px;
        z-index: 1050;
    }
    
    .chat-panel-backdrop {
        z-index: 1059;
    }
}

@media (max-width: 480px) {
    .chat-panel {
        width: calc(100% - 20px);
        right: calc(-100% - 20px);
        bottom: 70px;
        height: calc(75vh - 40px);
        max-height: calc(75vh - 40px);
        min-height: 250px;
        pointer-events: none;
        visibility: hidden;
    }
    
    .chat-panel.open {
        right: 10px;
        pointer-events: all;
        visibility: visible;
    }
    
    #chatNotificationBubble {
        bottom: 10px; /* Same height as language switcher on small mobile */
        right: 10px;
    }
    
    .chat-notification-bubble {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }
}

@media (max-width: 360px) {
    .chat-panel {
        width: calc(100% - 16px);
        right: calc(-100% - 16px);
        bottom: 65px;
        height: calc(70vh - 40px);
        max-height: calc(70vh - 40px);
        min-height: 200px;
        pointer-events: none;
        visibility: hidden;
    }
    
    .chat-panel.open {
        right: 8px;
        pointer-events: all;
        visibility: visible;
    }
    
    #chatNotificationBubble {
        bottom: 8px; /* Same height as language switcher on very small mobile */
        right: 8px;
    }
    
    .chat-notification-bubble {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }
}

