/* Cibdd Chat - Modern Styling with WebSocket Support */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --dark-bg: #111827;
    --sidebar-bg: #1f2937;
    --chat-bg: #1a1a1a;
    --input-bg: #374151;
    --message-received: #374151;
    --message-sent: #4f46e5;
    --text-light: #f3f4f6;
    --text-secondary: #9ca3af;
    --border-color: #374151;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--dark-bg);
    color: var(--text-light);
    margin: 0;
    height: 100vh;
    overflow: hidden;
}

.chat-container {
    width: 100%;
    display: flex;
    height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 2;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo i {
    font-size: 1.5rem;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.new-chat-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
}

.new-chat-btn:hover {
    background: var(--primary-hover);
}

.search-wrapper {
    padding: 15px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 25px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-bar {
    width: 100%;
    padding: 10px 15px 10px 35px;
    border-radius: 8px;
    border: none;
    background: var(--input-bg);
    color: var(--text-light);
    outline: none;
    transition: var(--transition);
}

.search-bar::placeholder {
    color: var(--text-secondary);
}

.search-bar:focus {
    box-shadow: 0 0 0 2px var(--primary);
}

.chat-categories {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.category {
    margin-bottom: 15px;
}

.category-header {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.category-header i {
    color: var(--text-secondary);
    margin-right: 10px;
}

.category-header h3 {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.chat-list {
    margin-top: 5px;
}

.chat-view {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    transition: var(--transition);
    border-radius: 8px;
    margin: 0 8px 5px 8px;
}

.chat-view:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-view.active {
    background: rgba(79, 70, 229, 0.2);
}

.chat-avatar, .group-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 12px;
    flex-shrink: 0;
}

.group-avatar {
    background: #22c55e;
}

.chat-info {
    flex: 1;
    overflow: hidden;
}

.chat-name {
    font-weight: 500;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-profile {
    display: flex;
    align-items: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border-color);
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #3b82f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 12px;
}

.profile-name {
    flex: 1;
    font-weight: 500;
}

.profile-settings {
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.profile-settings:hover {
    color: var(--text-light);
}

/* Chat Area Styling */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    position: relative;
    z-index: 1;
}

.chat-header {
    background: var(--dark-bg);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.current-chat-info {
    display: flex;
    align-items: center;
}

.current-chat-avatar {
    margin-right: 12px;
}

.current-chat-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.chat-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--input-bg);
    color: var(--text-light);
}

.chat-box {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.message {
    margin-bottom: 15px;
    max-width: 70%;
    animation: fadeIn 0.3s;
    position: relative;
}

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

.message-container {
    display: flex;
    align-items: flex-end;
    margin-bottom: 15px;
}

.message-container.received {
    justify-content: flex-start;
}

.message-container.sent {
    justify-content: flex-end;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    background: #22c55e;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    max-width: 70%;
}

.received .message-content {
    background: var(--message-received);
    border-bottom-left-radius: 4px;
}

.sent .message-content {
    background: var(--message-sent);
    border-bottom-right-radius: 4px;
}

.message-sender {
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.message-text {
    line-height: 1.4;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 5px;
    text-align: right;
}

.chat-input {
    padding: 15px;
    background: var(--dark-bg);
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border-color);
}

.attachment-btn, .emoji-btn, .send-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.attachment-btn:hover, .emoji-btn:hover {
    background: var(--input-bg);
    color: var(--text-light);
}

.send-btn {
    background: var(--primary);
    color: white;
}

.send-btn:hover {
    background: var(--primary-hover);
}

#message-input {
    flex: 1;
    padding: 12px 15px;
    border-radius: 20px;
    border: none;
    outline: none;
    background: var(--input-bg);
    color: var(--text-light);
    font-size: 0.95rem;
}

#message-input::placeholder {
    color: var(--text-secondary);
}

/* Welcome Message */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    color: var(--text-secondary);
    gap: 15px;
    padding: 20px;
}

.welcome-icon {
    font-size: 4rem;
    color: var(--primary);
    opacity: 0.7;
}

.welcome-message h2 {
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-light);
}

.welcome-message p {
    max-width: 400px;
    line-height: 1.6;
}

/* Modal Styles */
.login-modal, .create-chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.login-container, .modal-container {
    background: var(--sidebar-bg);
    border-radius: 8px;
    padding: 30px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s;
}

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

.login-container h2, .modal-container h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-light);
}

.login-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

.tab-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.hidden {
    display: none;
}

.login-container input, .modal-container input, .modal-container select {
    padding: 12px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-light);
    font-size: 14px;
}

.login-container button, .modal-container button {
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 10px;
    transition: var(--transition);
}

.login-container button:hover, .modal-container button:hover {
    background: var(--primary-hover);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-light);
}

.user-checkboxes {
    max-height: 150px;
    overflow-y: auto;
    padding: 10px;
    background: var(--input-bg);
    border-radius: 5px;
}

.user-checkboxes label {
    margin-left: 5px;
    color: var(--text-light);
}

.user-checkboxes input[type="checkbox"] {
    margin-right: 5px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions button {
    padding: 8px 15px;
    margin-top: 0;
}

#cancel-create-chat {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

#cancel-create-chat:hover {
    background: rgba(79, 70, 229, 0.1);
}

/* Connection Status Indicator */
.connection-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--dark-bg);
    padding: 8px 15px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 900;
    transition: var(--transition);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-indicator.online {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.status-indicator.offline {
    background: var(--error);
    box-shadow: 0 0 10px var(--error);
}

.status-indicator.connecting {
    background: var(--warning);
    box-shadow: 0 0 10px var(--warning);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

.status-text {
    color: var(--text-light);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 300px;
}

.toast {
    padding: 12px 15px;
    border-radius: 5px;
    background: var(--dark-bg);
    color: var(--text-light);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s;
    transition: var(--transition);
}

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

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.info {
    border-left: 4px solid var(--primary);
}

.toast-icon {
    font-size: 1.2rem;
}

.toast.success .toast-icon {
    color: var(--success);
}

.toast.error .toast-icon {
    color: var(--error);
}

.toast.info .toast-icon {
    color: var(--primary);
}

.toast-content {
    flex: 1;
}

.toast-message {
    font-size: 0.9rem;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

.toast-close:hover {
    color: var(--text-light);
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .chat-container {
        position: relative;
    }
    
    .sidebar {
        position: absolute;
        left: -320px;
        height: 100%;
        transition: left 0.3s ease;
        z-index: 10;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .mobile-toggle {
        display: block;
        position: absolute;
        top: 15px;
        left: 15px;
        background: transparent;
        border: none;
        color: var(--text-light);
        font-size: 1.5rem;
        cursor: pointer;
        z-index: 11;
    }
    
    .chat-header {
        padding-left: 50px;
    }
}