/* ========================================
   WORKPASS 2.0 - PHASE 5.2
   Chat System Enhanced Styling
   ======================================== */

/* === DISCORD-STYLE CHAT LAYOUT === */
.chat-enhanced {
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-rows: 1fr auto;
    height: 100%;
    gap: 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    overflow: hidden;
}

/* === LEFT SIDEBAR - CHANNEL SELECTOR (Discord Style) === */
.channel-sidebar {
    grid-column: 1;
    grid-row: 1 / -1;
    background: #2B2D31;
    /* Discord's exact dark gray */
    border-right: none;
    /* Discord doesn't have a border */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.channel-sidebar-header {
    padding: 12px 16px 16px 16px;
    border-bottom: 1px solid #1e1f22;
    background: #2B2D31;
    box-shadow: 0 1px 0 rgba(4, 4, 5, 0.2), 0 1.5px 0 rgba(6, 6, 7, 0.05), 0 2px 0 rgba(4, 4, 5, 0.05);
}

.channel-sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #F2F3F5;
    letter-spacing: 0;
    text-transform: none;
    /* Discord doesn't use uppercase */
}

.channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* Minimal gap like Discord */
}

/* Custom scrollbar like Discord */
.channel-list::-webkit-scrollbar {
    width: 8px;
}

.channel-list::-webkit-scrollbar-track {
    background: transparent;
}

.channel-list::-webkit-scrollbar-thumb {
    background: #1a1b1e;
    border-radius: 4px;
}

.channel-list::-webkit-scrollbar-thumb:hover {
    background: #1e1f22;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin: 0 4px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    position: relative;
}

/* Remove the left indicator bar */
.channel-item::before {
    display: none;
}

.channel-item:hover {
    background: #35373C;
    /* Discord hover color */
}

.channel-item.active {
    background: #404249;
    /* Discord active channel color */
}

.channel-icon {
    width: 20px;
    height: 20px;
    color: #80848E;
    /* Discord's muted icon color */
    flex-shrink: 0;
}

.channel-item.active .channel-icon {
    color: #F2F3F5;
    /* White when active */
}

.channel-name {
    font-weight: 500;
    font-size: 16px;
    color: #949BA4;
    /* Discord's muted text */
    flex: 1;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.channel-item.active .channel-name {
    color: #F2F3F5;
    /* White when active */
    font-weight: 500;
}

.unread-badge {
    background: #F23F42;
    color: white;
    font-size: 12px;
    font-weight: 600;
    padding: 0 6px;
    height: 16px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
    line-height: 16px;
}

/* Request Channel Special Styling */
.channel-item[data-type="requests"] .channel-icon {
    color: #F0B232;
    /* Orange/yellow for special channels */
}

.channel-item[data-type="requests"].active .channel-name {
    color: #F2F3F5;
}

.channel-item[data-type="requests"] .channel-name {
    color: #F0B232;
}

/* === RIGHT SIDE - CHAT MESSAGES === */
.chat-main-area {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #313338;
    /* Discord's main chat area color */
}

.chat-header {
    background: #313338;
    padding: 12px 16px;
    border-bottom: 1px solid #26272B;
    flex-shrink: 0;
    box-shadow: 0 1px 0 rgba(4, 4, 5, 0.2), 0 1.5px 0 rgba(6, 6, 7, 0.05), 0 2px 0 rgba(4, 4, 5, 0.05);
}

.chat-header h3 {
    margin: 0 0 2px 0;
    font-size: 16px;
    font-weight: 600;
    color: #F2F3F5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header h3 i {
    width: 20px;
    height: 20px;
    color: #80848E;
}

#channel-description {
    font-size: 12px;
    color: #B5BAC1;
    font-style: normal;
    margin: 0;
}

/* === ENHANCED MESSAGE BUBBLES (WhatsApp Style) === */
.chat-messages-enhanced {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    /* Reduced from 12px */
    max-height: 450px;
    /* FIXED HEIGHT */
    min-height: 450px;
    /* MINIMUM HEIGHT */
}

/* Custom scrollbar for messages */
.chat-messages-enhanced::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages-enhanced::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    transition: background 0.2s;
}

.chat-messages-enhanced::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.message-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* Tighter gap */
    max-width: 65%;
    /* Narrower like WhatsApp */
    animation: messageSlideIn 0.2s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-item.own {
    align-self: flex-end;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    /* Smaller */
    padding: 0 4px;
}

.message-sender {
    font-weight: 600;
    color: #00d4ff;
    font-size: 11px;
    /* Smaller */
}

.message-sender[data-role="admin"] {
    color: #ffd700;
}

.message-sender[data-role="admin"]::before {
    content: '👑 ';
}

.message-time {
    color: rgba(255, 255, 255, 0.4);
    font-size: 10px;
    /* Smaller */
}

.message-bubble {
    position: relative;
    padding: 8px 12px;
    /* Reduced from 12px 16px */
    border-radius: 12px 12px 12px 2px;
    /* WhatsApp-style tail */
    background: rgba(35, 35, 35, 0.8);
    /* Darker, more WhatsApp-like */
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    transition: all 0.15s ease;
    max-width: 100%;
}

.message-bubble:hover {
    background: rgba(45, 45, 45, 0.9);
    transform: translateY(-1px);
}

.message-item.own .message-bubble {
    background: rgba(0, 90, 90, 0.5);
    /* Teal green like WhatsApp */
    border-color: rgba(0, 212, 255, 0.2);
    border-radius: 12px 12px 2px 12px;
    /* Tail on right for own messages */
}

.message-item.own .message-bubble:hover {
    background: rgba(0, 100, 100, 0.6);
}

.message-text {
    margin: 0;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.4;
    /* Tighter line height */
    font-size: 13px;
    /* Smaller font */
    word-wrap: break-word;
}

/* Request Message Special Styling */
.request-message .message-bubble {
    background: linear-gradient(135deg, rgba(255, 107, 0, 0.15), rgba(255, 157, 0, 0.1));
    border-color: rgba(255, 107, 0, 0.3);
    border-left: 3px solid #ff6b00;
}

.request-message .message-sender {
    color: #ff6b00;
}

/* Pinned Message */
.message-item.pinned {
    max-width: 100%;
}

.message-item.pinned .message-bubble {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 193, 7, 0.05));
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-left: 3px solid #ffd700;
}

.pin-btn {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
}

.message-bubble:hover .pin-btn {
    opacity: 1;
}

.pin-btn:hover {
    background: rgba(255, 215, 0, 0.2);
}

.pin-btn.active {
    opacity: 1;
    background: rgba(255, 215, 0, 0.3);
    color: #ffd700;
}

.pin-btn i {
    width: 14px;
    height: 14px;
}

/* === MESSAGE ACTIONS (Delete & Pin) === */
.message-actions {
    position: absolute;
    right: 8px;
    top: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.delete-msg-btn {
    width: 24px;
    height: 24px;
    background: rgba(237, 66, 69, 0.1);
    /* Discord's red color */
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #ED4245;
}

.delete-msg-btn:hover {
    background: rgba(237, 66, 69, 0.2);
    transform: scale(1.1);
}

.delete-msg-btn i {
    width: 14px;
    height: 14px;
}

/* === CHAT INPUT === */
.chat-input-container {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid rgba(0, 212, 255, 0.15);
}

#chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 12px 20px;
    color: white;
    font-size: 14px;
    transition: all 0.3s ease;
}

#chat-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    border-color: #00d4ff;
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#send-message-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff, #00ff9d);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#send-message-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.5);
}

#send-message-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#send-message-btn i {
    width: 20px;
    height: 20px;
    color: #001a28;
}

/* === CHANNEL MANAGER MODAL === */
.channel-manager-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.channel-manager-modal.active {
    opacity: 1;
    pointer-events: all;
}

.channel-manager-content {
    background: linear-gradient(135deg, #001a28, #002838);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.channel-manager-modal.active .channel-manager-content {
    transform: scale(1);
}

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

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: #00d4ff;
}

.close-modal-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s ease;
}

.close-modal-btn:hover {
    color: #ff4444;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    color: white;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #00d4ff;
    background: rgba(255, 255, 255, 0.08);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.color-picker-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
    gap: 8px;
}

.color-option {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: white;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-btn {
    flex: 1;
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-btn-primary {
    background: linear-gradient(135deg, #00d4ff, #00ff9d);
    color: #001a28;
}

.modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4);
}

.modal-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .channel-list {
        flex-direction: column;
    }

    .channel-item {
        width: 100%;
    }

    .message-item {
        max-width: 90%;
    }

    .channel-manager-content {
        padding: 20px;
        width: 95%;
    }
}