/* Chat System CSS */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
}

/* Chat Container */
.chat-container {
    max-width: 100%;
    margin: 20px auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header .robot-icon {
    width: 30px;
    height: 30px;
    background: #4CAF50;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    font-size: 16px;
}

.chat-header h2 {
    font-size: 18px;
    font-weight: 500;
}

.chat-header .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#userInfo {
    display: flex;
    align-items: center;
    gap: 5px;
}

.user-type {
    font-size: 16px;
}

.user-type.registered {
    color: #4CAF50;
}

.user-type.guest {
    color: #FF9800;
}

.username {
    font-weight: bold;
    color: #fff;
    cursor: help;
}

/* User role styles */
.message  .username.administrator,
.username.administrator {
    color: #e74c3c;
    font-weight: 900;
}

.username.editor {
    color: #9b59b6;
    font-weight: 700;
}

.username.author {
    color: #3498db;
    font-weight: 600;
}

.username.contributor {
    color: #2ecc71;
    font-weight: 500;
}

.username.subscriber {
    color: #95a5a6;
}

.username.guest {
    color: #f39c12;
}

/* Timestamp tooltip */
.timestamp {
    cursor: help;
}

/* Admin actions */
.admin-actions {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 3px;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 5px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.message:hover .admin-actions {
    opacity: 1;
}

.admin-btn {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.admin-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.delete-btn:hover {
    background: rgba(231, 76, 60, 0.2);
}

.delete-all-btn:hover {
    background: rgba(231, 76, 60, 0.3);
}

.ban-btn:hover {
    background: rgba(192, 57, 43, 0.2);
}

/* Enhanced tooltip styles */
.username[title], .timestamp[title] {
    position: relative;
}

/* Username tooltip - căn trái */
.username[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.3;
    white-space: pre; /* không xuống dòng giữa câu; chỉ xuống dòng ở \n */
    width: max-content;
    max-width: 90vw;
    overflow-wrap: normal;
    word-break: normal;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    min-width: 180px;
    text-align: left;
    pointer-events: none;
}

.username[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 20px;
    transform: translateY(100%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    pointer-events: none;
}

/* Timestamp tooltip - căn phải */
.timestamp[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.3;
    white-space: pre-line;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    min-width: 150px;
    text-align: center;
    pointer-events: none;
}

.timestamp[title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    right: 20px;
    transform: translateY(100%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    pointer-events: none;
}

.auth-buttons {
    display: flex;
    gap: 10px;
}

.logout-wrapper {
    margin-left: 10px;
}

.auth-btn.logout-btn {
    background: #e74c3c;
    color: #fff;
}

.auth-btn.logout-btn:hover {
    background: #c0392b;
}

.auth-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.login-btn {
    background: #4CAF50;
    color: white;
}

.login-btn:hover {
    background: #45a049;
}

.register-btn {
    background: #2196F3;
    color: white;
}

.register-btn:hover {
    background: #1976D2;
}

.chat-header .user-info span {
    font-size: 14px;
}

/* Chat Messages Area */
.chat-messages {
    height: 400px;
    overflow-y: auto;
    padding: 15px;
    background: #fafafa;
    border-bottom: 1px solid #ddd;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.message {
    margin-bottom: 8px;
    padding: 5px 0;
    word-wrap: break-word;
    position: relative;
}

.message.system {
    background: #e8f5e8;
    border-left: 4px solid #4CAF50;
    font-style: italic;
    padding: 8px 12px;
    border-radius: 8px;
}

.message.user {
    background: white;
    border: none;
}

.message .username {
    color: #000; /* user mặc định đen */
    font-weight: bold;
    margin-right: 5px;
}

.message .timestamp {
    color: #999;
    font-size: 11px;
    position: absolute;
    right: 0;
    top: 0;
}

.message .content {
    color: #333;
    margin-top: 2px;
    display: inline;
}

.message-line {
    display: flex;
    align-items: baseline;
    gap: 5px;
    position: relative;
}

.message-line .timestamp {
    margin-left: auto;
    position: static;
}

/* Chat Input Area */
.chat-input-area {
    padding: 15px 20px;
    background: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.chat-input:focus {
    border-color: #2196F3;
}

.emoji-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.emoji-btn:hover {
    background-color: #f0f0f0;
}

.send-btn {
    background: #2196F3;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.3s;
}

.send-btn:hover {
    background: #1976D2;
}

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.lightbox.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    position: relative;
    animation: slideIn 0.3s ease;
}

.lightbox-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.lightbox-header .icon {
    width: 30px;
    height: 30px;
    background: linear-gradient(45deg, #9c27b0, #ff9800);
    border-radius: 50%;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.lightbox-header h3 {
    color: #333;
    font-size: 18px;
    font-weight: 500;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
}

.close-btn:hover {
    color: #333;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: 500;
}

.form-group .input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.form-group .input-wrapper .icon {
    position: absolute;
    left: 12px;
    color: #999;
    font-size: 16px;
}

.form-group input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: none;
    border-bottom: 2px solid #e0e0e0;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.form-group input:focus {
    border-bottom-color: #2196F3;
}

.submit-btn {
    width: 100%;
    background: #2196F3;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s;
}

.submit-btn:hover {
    background: #1976D2;
}

.switch-form {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.switch-form p {
    margin: 10px 0;
    color: #666;
}

.switch-form a {
    color: #2196F3;
    text-decoration: none;
    font-weight: 500;
}

.switch-form a:hover {
    text-decoration: underline;
}

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

.submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.switch-form {
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
    color: #666;
}

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

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

/* Emoji Picker */
#emojiPicker {
    position: fixed !important;
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    max-width: 200px;
    display: none;
}

#emojiPicker button {
    background: none;
    border: none;
    font-size: 20px;
    padding: 5px;
    margin: 2px;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.2s;
}

#emojiPicker button:hover {
    background: #f0f0f0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-container {
        margin: 10px;
        border-radius: 5px;
    }
    
    .chat-messages {
        height: 300px;
    }
    
    .lightbox-content {
        width: 95%;
        padding: 20px;
    }
    
    .chat-header {
        padding: 10px 15px;
    }
    
    .chat-header h2 {
        font-size: 16px;
    }
    
    .chat-input-area {
        padding: 10px 15px;
    }
    
    #emojiPicker {
        max-width: 150px;
        right: 10px !important;
    }
}