/* Integrated Chat Widget Styles */
.main-container {
    display: flex;
    min-height: calc(100vh - 120px);
}

/* Chat sidebar styles - Hidden since we use the new fixed input */
.chat-sidebar {
    display: none !important;
}

.chat-sidebar.minimized {
    width: 50px;
    overflow: hidden;
}

.chat-sidebar.closed {
    width: 0;
    border-right: none;
    overflow: hidden;
}

.game-content {
    flex: 1;
    transition: all 0.3s ease;
}

/* Chat Header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0, 212, 255, 0.1);
    border-bottom: 1px solid rgba(0, 212, 255, 0.3);
    cursor: pointer;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #00d4ff;
    font-weight: 600;
    font-size: 14px;
}

.chat-icon {
    font-size: 16px;
}

.online-count {
    background: rgba(0, 255, 0, 0.2);
    color: #00ff00;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    min-width: 20px;
    text-align: center;
}

.chat-controls {
    display: flex;
    gap: 5px;
}

.chat-btn {
    background: none;
    border: 1px solid rgba(0, 212, 255, 0.3);
    color: #00d4ff;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.chat-btn:hover {
    background: rgba(0, 212, 255, 0.2);
    border-color: #00d4ff;
}

/* Chat Body */
.chat-body {
    display: flex;
    flex-direction: column;
    height: 400px;
    max-height: 500px;
    min-height: 300px;
}

.chat-sidebar.minimized .chat-body {
    display: none;
}

.chat-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    max-height: 250px;
}

.system-message {
    color: #888;
    font-style: italic;
    font-size: 12px;
    text-align: center;
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 8px;
}

/* Chat Input */
.chat-input-container {
    display: flex;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(0, 212, 255, 0.3);
    gap: 8px;
}

/* Fixed bottom chat input */
.fixed-chat-input {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    padding: 15px 20px;
    background: linear-gradient(135deg, rgba(0, 20, 40, 0.95), rgba(0, 40, 80, 0.95));
    border-top: 2px solid rgba(0, 212, 255, 0.5);
    backdrop-filter: blur(10px);
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.3);
    gap: 12px;
    align-items: center;
}

.fixed-chat-input #chat-input-fixed {
    flex: 1;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(0, 212, 255, 0.4);
    border-radius: 25px;
    padding: 12px 20px;
    color: #ffffff;
    font-family: 'Orbitron', monospace;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    max-width: 600px;
}

.fixed-chat-input #chat-input-fixed:focus {
    border-color: #00d4ff;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
    background: rgba(0, 0, 0, 0.8);
}

.fixed-chat-input #chat-input-fixed::placeholder {
    color: #aaa;
}

.fixed-chat-input .send-btn-fixed {
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    color: #ffffff;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}

.fixed-chat-input .send-btn-fixed:hover {
    background: linear-gradient(135deg, #00b8e6, #0088bb);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.4);
}

.fixed-chat-input .send-btn-fixed:active {
    transform: translateY(0);
}

/* Chat history popup */
.chat-history-popup {
    position: fixed;
    bottom: 80px;
    left: 20px;
    width: 450px;
    max-height: 500px;
    background: linear-gradient(135deg, rgba(0, 20, 40, 0.7), rgba(0, 40, 80, 0.7));
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 15px;
    backdrop-filter: blur(15px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 999;
    display: none;
    overflow: hidden;
}

/* Temporary message popup for new messages */
.temp-message-popup {
    position: fixed;
    bottom: 80px;
    left: 20px;
    width: 400px;
    max-height: 120px;
    background: linear-gradient(135deg, rgba(0, 20, 40, 0.95), rgba(0, 40, 80, 0.95));
    border: 2px solid rgba(0, 212, 255, 0.6);
    border-radius: 12px;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 25px rgba(0, 212, 255, 0.3);
    z-index: 1001;
    display: none;
    overflow: hidden;
    animation: slideInUp 0.4s ease;
}

.temp-message-popup.show {
    display: block;
}

.temp-message-popup.fade-out {
    animation: fadeOut 0.5s ease forwards;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.temp-message-content {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.temp-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.temp-message-title {
    color: #00d4ff;
    font-family: 'Orbitron', monospace;
    font-size: 12px;
    font-weight: bold;
}

.temp-message-close {
    background: none;
    border: none;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.temp-message-close:hover {
    color: #00d4ff;
}

.temp-message-item {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    padding: 8px 10px;
    border-left: 3px solid rgba(0, 212, 255, 0.7);
    margin-bottom: 4px;
}

.temp-message-item:last-child {
    margin-bottom: 0;
}

.temp-message-username {
    color: #00d4ff;
    font-weight: bold;
    font-size: 11px;
    margin-bottom: 2px;
}

.temp-message-text {
    color: #ffffff;
    font-size: 12px;
    line-height: 1.3;
}

.temp-message-time {
    color: #888;
    font-size: 9px;
    float: right;
    margin-top: -16px;
}

.chat-history-popup.show {
    display: block;
    animation: slideUp 0.3s ease;
}

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

.chat-history-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(0, 212, 255, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-history-title {
    color: #00d4ff;
    font-family: 'Orbitron', monospace;
    font-size: 16px;
    font-weight: bold;
}

.chat-history-close {
    background: none;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.chat-history-close:hover {
    color: #00d4ff;
}

.chat-history-messages {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.chat-history-message {
    margin-bottom: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border-left: 3px solid rgba(0, 212, 255, 0.5);
}

.chat-history-message .username {
    color: #00d4ff;
    font-weight: bold;
    font-size: 12px;
}

.chat-history-message .message {
    color: #ffffff;
    font-size: 13px;
    margin-top: 2px;
}

.chat-history-message .timestamp {
    color: #888;
    font-size: 10px;
    float: right;
}

/* Adjust main content to account for fixed input */
body {
    padding-bottom: 80px;
}

#chat-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 6px;
    padding: 8px 12px;
    color: #ffffff;
    font-family: 'Orbitron', monospace;
    font-size: 13px;
    outline: none;
    transition: all 0.2s ease;
}

#chat-input:focus {
    border-color: #00d4ff;
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
}

#chat-input::placeholder {
    color: #888;
}

.send-btn {
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    color: #ffffff;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background: linear-gradient(135deg, #00b8e6, #0088bb);
    transform: translateY(-1px);
}

.send-btn:active {
    transform: translateY(0);
}

/* Chat toggle button */
.chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
    z-index: 1001;
    transition: all 0.3s ease;
    font-size: 20px;
    color: white;
    border: none;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.4);
}

body.chat-closed .chat-toggle {
    opacity: 1;
    pointer-events: all;
}

.chat-widget.has-notification {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 8px 32px rgba(0, 212, 255, 0.5); }
    100% { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); }
}

/* Chat Header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(0, 150, 255, 0.1));
    border-bottom: 1px solid rgba(0, 212, 255, 0.3);
    cursor: grab;
    user-select: none;
}

.chat-header:active {
    cursor: grabbing;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
}

.chat-icon {
    font-size: 16px;
}

.online-count {
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bold;
}

.chat-controls {
    display: flex;
    gap: 5px;
}

.minimize-btn,
.close-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 16px;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.minimize-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.close-btn:hover {
    background: rgba(255, 0, 0, 0.2);
    color: #ff4444;
}

/* Chat Body */
.chat-body {
    display: flex;
    flex-direction: column;
    height: calc(100% - 60px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chat-widget.open .chat-body {
    opacity: 1;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    max-height: 300px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.5);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.7);
}

/* Messages */
.chat-message {
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border-left: 3px solid rgba(0, 212, 255, 0.5);
}

.chat-message.own-message {
    background: rgba(0, 212, 255, 0.1);
    border-left-color: #00d4ff;
    margin-left: 20px;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.username {
    font-weight: 600;
    color: #00d4ff;
    font-size: 12px;
}

.own-message .username {
    color: #ffffff;
}

.timestamp {
    font-size: 10px;
    color: #888;
}

.message-content {
    color: #ffffff;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
}

.system-message {
    text-align: center;
    color: #888;
    font-size: 12px;
    font-style: italic;
    margin: 8px 0;
    padding: 8px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
}

.section-change-message {
    margin: 8px 0;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 150, 255, 0.1));
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 15px;
    animation: slideInSection 0.3s ease-out;
}

.section-change-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}

.section-icon {
    font-size: 1.2em;
    filter: drop-shadow(0 0 3px rgba(0, 255, 255, 0.5));
}

.section-text {
    flex: 1;
    color: #00ffff;
    font-weight: 500;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.3);
}

.section-timestamp {
    font-size: 0.8em;
    color: rgba(0, 255, 255, 0.7);
    opacity: 0.8;
}

@keyframes slideInSection {
    from {
        opacity: 0;
        transform: translateX(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Chat Input */
.chat-input-container {
    display: flex;
    padding: 15px;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
}

#chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 8px 15px;
    color: #ffffff;
    font-size: 13px;
    outline: none;
    transition: all 0.2s ease;
}

#chat-input:focus {
    border-color: #00d4ff;
    background: rgba(255, 255, 255, 0.15);
}

#chat-input::placeholder {
    color: #888;
}

#send-btn {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
}

#send-btn:hover {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    transform: scale(1.05);
}

#send-btn:active {
    transform: scale(0.95);
}

/* Chat Toggle (minimized state) */
.chat-toggle {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-widget.open .chat-toggle {
    display: none;
}

.chat-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: #ffffff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
    60% { transform: translateY(-3px); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-widget {
        width: 300px;
        bottom: 10px;
        right: 10px;
    }
    
    .chat-widget.open {
        height: 400px;
    }
    
    .chat-messages {
        max-height: 250px;
    }
}

@media (max-width: 480px) {
    .chat-widget {
        width: calc(100vw - 20px);
        left: 10px;
        right: 10px;
    }
    
    .chat-widget.open {
        height: 350px;
    }
    
    .chat-messages {
        max-height: 200px;
    }
}