/* ===================================
   MODERN STEAM MESSENGER - MATCHES FORUM DESIGN
   =================================== */

/* Main Messenger Container */
.steam-messenger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 420px;
    height: 600px;
    background: var(--bg-dark) !important;
    border: 2px solid var(--border-color) !important;
    border-radius: 16px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1 !important;
}

/* Larger size on wider screens */
@media (min-width: 1200px) {
    .steam-messenger {
        width: 480px;
        height: 650px;
    }
}

@media (min-width: 1600px) {
    .steam-messenger {
        width: 550px;
        height: 700px;
    }
}

.steam-messenger.active {
    display: flex;
}

.steam-messenger.minimized {
    height: 50px;
    overflow: hidden;
}

/* Header - Modern Style */
.steam-messenger-header {
    background: var(--bg-light) !important;
    border-bottom: 2px solid var(--border-color);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.steam-messenger-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 700;
}

.steam-messenger-title i {
    font-size: 18px;
    color: var(--primary-color);
}

.steam-messenger-controls {
    display: flex;
    gap: 6px;
}

.steam-control-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.steam-control-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

/* Tabs - Modern Toggle Style */
.steam-messenger-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-darker);
    border-bottom: 2px solid var(--border-color);
    padding: 8px 12px;
    flex-shrink: 0;
}

/* Hide tabs when in active conversation - they're not needed */
.steam-messenger-body.chat-active ~ .steam-messenger-tabs,
.steam-messenger.chat-active .steam-messenger-tabs {
    display: none;
}

.steam-tab {
    flex: 1;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.steam-tab:hover {
    color: var(--text-primary);
    background: var(--bg-light);
}

.steam-tab.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(168, 85, 247, 0.4);
}

.steam-tab i {
    font-size: 13px;
}

/* Messenger Body */
.steam-messenger-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: var(--bg-darker) !important;
    position: relative;
}

/* Friends/Conversations List */
.steam-friends-list {
    width: 200px;
    background: var(--bg-dark) !important;
    border-right: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

/* Always hide friends list when chat is active - consistent behavior on all screens */
.steam-messenger-body.chat-active .steam-friends-list {
    display: none;
}

.steam-friends-header {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    align-items: center;
}

.steam-new-group-btn {
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.steam-new-group-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.steam-search-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-darker);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s;
}

.steam-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

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

.steam-conversations {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Conversation Item - Modern Card Style */
.steam-conversation {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 3px solid transparent;
    gap: 10px;
}

.steam-conversation:hover {
    background: var(--bg-light);
    border-left-color: var(--primary-color);
}

.steam-conversation.active {
    background: var(--bg-light);
    border-left-color: var(--primary-color);
}

.steam-conversation.unread {
    background: rgba(168, 85, 247, 0.05);
}

.steam-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--border-color);
}

.steam-avatar-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
    font-size: 16px;
}

.steam-conversation-info {
    flex: 1;
    min-width: 0;
}

.steam-conversation-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.steam-conversation.unread .steam-conversation-name {
    color: var(--primary-color);
}

.steam-conversation-preview {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.steam-unread-badge {
    background: var(--primary-color);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
}

/* Empty States */
.steam-no-chats {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    text-align: center;
}

.steam-no-chats i {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 12px;
}

.steam-no-chats p {
    font-size: 13px;
}

/* Chat Area */
.steam-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-darker) !important;
    min-width: 0; /* Allow shrinking */
}

.steam-no-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    padding: 40px;
    text-align: center;
}

.steam-no-chat i {
    font-size: 64px;
    opacity: 0.2;
    margin-bottom: 16px;
}

.steam-no-chat p {
    font-size: 14px;
}

.steam-chat-header {
    padding: 12px 16px;
    background: var(--bg-light);
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* Back button to return to friends list */
.steam-back-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.steam-back-btn:hover {
    background: var(--bg-darker);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: scale(1.05);
}

/* Always show back button when chat is active - consistent behavior on all screens */
.steam-messenger-body.chat-active .steam-back-btn {
    display: flex;
}

.steam-chat-user-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Messages Area */
.steam-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.steam-date-divider {
    text-align: center;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 8px 0;
    position: relative;
}

.steam-date-divider::before,
.steam-date-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border-color);
}

.steam-date-divider::before {
    left: 0;
}

.steam-date-divider::after {
    right: 0;
}

/* Message Bubbles - Modern Style */
.steam-message {
    display: flex;
    margin-bottom: 4px;
    animation: fadeIn 0.2s;
}

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

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

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

.steam-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    position: relative;
}

.steam-message-sent .steam-bubble {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.steam-message-received .steam-bubble {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.steam-text {
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.steam-time {
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.7;
}

.steam-message-sent .steam-time {
    color: rgba(255, 255, 255, 0.8);
    text-align: right;
}

.steam-message-received .steam-time {
    color: var(--text-secondary);
    text-align: left;
}

/* Input Area - Modern Style */
.steam-input-container {
    padding: 12px 16px;
    background: var(--bg-light);
    border-top: 2px solid var(--border-color);
    flex-shrink: 0;
    position: relative;
    z-index: 20;
}

.steam-input-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.steam-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-darker);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s;
    font-family: inherit;
    /* Mobile tap/click fixes */
    -webkit-user-select: text;
    user-select: text;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    pointer-events: auto;
}

.steam-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

.steam-send-btn {
    padding: 10px 18px;
    background: var(--primary-color);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.steam-send-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

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

/* Floating Chat Button - Modern */
.floating-chat-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--primary-color) !important;
    border: none;
    border-radius: 16px;
    color: white !important;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.4);
    z-index: 999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1 !important;
}

.floating-chat-btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 6px 24px rgba(168, 85, 247, 0.6);
    transform: scale(1.1);
}

.floating-chat-btn:active {
    transform: scale(0.95);
}

.floating-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 7px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    border: 2px solid var(--bg-secondary);
}

/* Custom Scrollbars - Modern */
.steam-conversations::-webkit-scrollbar,
.steam-messages::-webkit-scrollbar {
    width: 8px;
}

.steam-conversations::-webkit-scrollbar-track,
.steam-messages::-webkit-scrollbar-track {
    background: transparent;
}

.steam-conversations::-webkit-scrollbar-thumb,
.steam-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.steam-conversations::-webkit-scrollbar-thumb:hover,
.steam-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Online Status Indicator */
.steam-online-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid var(--bg-secondary);
    position: absolute;
    bottom: 0;
    right: 0;
}

.steam-online-status.offline {
    background: #6b7280;
}

/* ===================================
   MOBILE RESPONSIVE - NATIVE APP FEEL
   =================================== */

@media (max-width: 768px) {
    /* Full screen on mobile - native app style */
    .steam-messenger {
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important; /* Dynamic viewport height for mobile browsers */
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0;
        border: none;
        z-index: 99999; /* Above everything */
    }

    /* On mobile, show ONLY friends list initially (not both columns) */
    .steam-messenger-body:not(.chat-active) .steam-chat-area {
        display: none;
    }

    /* Friends list takes full width when chat is not active */
    .steam-messenger-body:not(.chat-active) .steam-friends-list {
        width: 100%;
        border-right: none;
    }

    /* When chat is active, friends list is hidden and chat takes full width */
    .steam-messenger-body.chat-active .steam-friends-list {
        display: none;
    }

    .steam-messenger-body.chat-active .steam-chat-area {
        display: flex;
        width: 100%;
    }

    /* Prevent body scroll when messenger is open */
    body.messenger-open {
        overflow: hidden !important;
    }

    .steam-messenger-body {
        overflow-x: hidden;
        max-width: 100%;
    }

    .steam-chat-area,
    .steam-friends-list {
        max-width: 100%;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    /* Narrower friends list on mobile */
    .steam-friends-list {
        width: 100px;
    }

    .steam-conversation {
        padding: 10px 8px;
        gap: 8px;
    }

    .steam-avatar,
    .steam-avatar-placeholder {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .steam-conversation-name {
        font-size: 13px;
    }

    .steam-conversation-preview {
        font-size: 11px;
    }

    .steam-bubble {
        max-width: 85%;
    }

    .steam-messages {
        padding: 12px;
    }

    .steam-input-container {
        padding: 10px 12px;
        position: sticky;
        bottom: 0;
        z-index: 10;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }

    .steam-search-input {
        font-size: 16px !important; /* Prevent mobile zoom */
        padding: 10px 12px;
    }

    .steam-input {
        font-size: 16px !important; /* Prevent mobile zoom */
        padding: 10px 14px;
        min-height: 44px; /* Better mobile touch target */
    }

    /* Slide up animation */
    .steam-messenger.active {
        animation: slideUpMobile 0.3s ease-out;
    }

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

    /* Smooth scrolling */
    .steam-messages,
    .steam-conversations {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Better touch targets */
    .steam-conversation,
    .steam-control-btn,
    .steam-send-btn {
        min-height: 44px;
    }

    .floating-chat-btn {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        font-size: 22px;
    }

    /* Keep message previews visible - they're important context */
    .steam-conversation-preview {
        font-size: 11px;
        line-height: 1.3;
    }

    .steam-messenger-title span {
        display: inline;
    }

    .steam-send-btn {
        padding: 10px 14px;
    }
}

@media (max-width: 480px) {
    /* Extra compact on very small screens */
    .steam-friends-list {
        width: 100px;
    }

    .steam-conversation-info {
        display: flex;
        flex-direction: column;
    }

    .steam-conversation-name {
        font-size: 12px;
    }

    .steam-conversation-preview {
        font-size: 10px;
        line-height: 1.2;
        display: block !important;
    }

    .steam-messenger-title span {
        display: none;
    }

    .steam-messenger-title i {
        font-size: 18px;
    }

    .steam-avatar,
    .steam-avatar-placeholder {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
}
