/* Chat Notification Bubble */
#chatNotificationBubble {
    position: fixed;
    bottom: 80px; /* Moved up to avoid Yii debug toolbar */
    right: 30px; /* Moved away from corner */
    z-index: 1050;
}

.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: 20px;
    right: -450px;
    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: 1060;
    transition: right 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-panel.open {
    right: 0;
}

.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: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    z-index: 1059;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.chat-panel-backdrop.show {
    display: block;
    opacity: 1;
}

/* 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: -100%;
        height: calc(60vh - 40px);
        max-height: calc(60vh - 40px);
        border-radius: 15px;
        bottom: 20px;
        left: 10px;
    }
    
    #chatNotificationBubble {
        bottom: 70px;
        right: 20px;
    }
}

