/* Chat Section Design System */
.chat-section {
    max-width: 1300px;
    margin: 40px auto;
    padding: 0 24px;
    font-family: 'Onest', sans-serif;
    color: #F2EBDD;
}

.chat-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    color: #F2EBDD;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Messenger Layout */
.chat-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    height: 650px;
    background-color: transparent;
    border: none;
    overflow: visible;
}

/* Left Sidebar: Partner List */
.chat-sidebar {
    display: flex;
    flex-direction: column;
    background-color: #0D0D0F;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    height: 100%;
}

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

.sidebar-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #F2EBDD;
}

.sidebar-search-container {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.btn-new-chat-icon {
    background: transparent;
    border: none;
    color: #F2EBDD;
    font-size: 16px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-new-chat-icon:hover {
    background-color: var(--border-highlight);
}

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

.partners-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.partner-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin: 4px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.partner-item:hover {
    background-color: rgba(242, 235, 221, 0.03);
    transform: translateY(-1px);
}

.partner-item.active {
    background-color: #323338;
}

.partner-avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    margin-right: 12px;
    background-color: #323338;
    object-fit: cover;
}

.partner-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.partner-name {
    font-family: 'Unbounded', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #F2EBDD;
    margin: 0;
    display: flex;
    align-items: center;
}

.partner-blocked-tag {
    font-size: 10px;
    color: #ef4444;
    font-family: 'Onest', sans-serif;
    font-weight: 600;
    margin-left: 8px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    background-color: rgba(239, 68, 68, 0.08);
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: lowercase;
    line-height: 1.2;
}

.partner-last-msg {
    font-size: 13px;
    color: rgba(242, 235, 221, 0.5);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.partner-time {
    font-size: 12px;
    color: rgba(242, 235, 221, 0.3);
    margin-left: 8px;
    font-family: 'Onest', sans-serif;
}

/* Right Main Panel: Messages Window */
.chat-window {
    display: flex;
    flex-direction: column;
    background-color: #0D0D0F;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    height: 100%;
    position: relative;
}

.chat-window-content {
    display: none;
    height: 100%;
    flex-direction: column;
}

.chat-window-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    background-color: #0D0D0F;
    justify-content: space-between;
}

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

.btn-mobile-back {
    background: transparent;
    border: none;
    color: #F2EBDD;
    margin-right: 16px;
    display: none;
    cursor: pointer;
}

.active-partner-avatar {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    margin-right: 12px;
}

.active-partner-name {
    font-family: 'Unbounded', sans-serif;
    font-size: 16px;
    font-weight: 700;
}

.active-partner-status {
    font-size: 11px;
    color: #3b82f6;
    margin-left: 12px;
    font-weight: 500;
}

.header-actions-container {
    position: relative;
}

.chat-actions-btn {
    background: transparent;
    border: none;
    color: #d1d5db;
    cursor: pointer;
    padding: 8px;
    font-size: 18px;
    transition: opacity 0.15s ease;
}

.chat-actions-btn:hover {
    opacity: 0.8;
}

.actions-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 40px;
    background-color: #0D0D0F;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 180px;
    z-index: 1000;
    transform-origin: top right;
    animation: dropdownReveal 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.actions-dropdown-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: #F2EBDD;
    font-family: 'Onest', sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.actions-dropdown button:hover {
    background-color: var(--border-highlight) !important;
}

.actions-dropdown-btn.danger-top-border {
    border-top: 1px solid var(--border-color);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.no-chat-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(242, 235, 221, 0.4);
    text-align: center;
    padding: 48px;
}

.no-chat-icon {
    font-size: 72px;
    margin-bottom: 24px;
    color: #323338;
}

.no-chat-text {
    font-family: 'Unbounded', sans-serif;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #F2EBDD;
}

.no-chat-desc {
    color: rgba(242, 235, 221, 0.5);
    font-size: 14px;
    max-width: 320px;
    line-height: 1.5;
}

.message-bubble {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 12px;
    line-height: 1.4;
    font-size: 14px;
    word-break: break-word;
    position: relative;
}

.message-bubble.new-incoming {
    animation: messageFadeIn 0.15s ease-out forwards;
}

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

.message-bubble.sent {
    align-self: flex-end;
    background-color: #3b82f6;
    color: #F2EBDD;
}

.message-bubble.sent.last-in-group {
    border-bottom-right-radius: 4px;
    margin-bottom: 8px;
}

.message-bubble.received {
    align-self: flex-start;
    background-color: #323338;
    color: #F2EBDD;
}

.message-bubble.received.last-in-group {
    border-bottom-left-radius: 4px;
    margin-bottom: 8px;
}

.message-text {
    display: inline;
    vertical-align: middle;
}

.message-meta {
    font-size: 10px;
    color: rgba(242, 235, 221, 0.4);
    float: right;
    margin-top: 4px;
    margin-left: 8px;
    user-select: none;
}

.message-bubble.sent .message-meta {
    color: rgba(242, 235, 221, 0.7);
}

/* Message Input Box */
.chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    background-color: #0D0D0F;
}

.chat-input {
    flex: 1;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    color: #F2EBDD;
    font-family: 'Onest', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease;
}

.chat-input:focus {
    border-color: rgba(242, 235, 221, 0.25);
}

.btn-send {
    background-color: #3b82f6;
    color: #ffffff;
    border: none;
    padding: 0 24px;
    border-radius: 8px;
    font-family: 'Unbounded', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.btn-send:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

.btn-send:active {
    opacity: 0.7;
    transform: scale(0.98);
}

/* Modal for New Chat */
.new-chat-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 99999;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #0D0D0F;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 400px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: modalScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

.modal-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 18px;
    font-weight: 700;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 20px;
    cursor: pointer;
}

.player-select-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.select-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.select-item:hover {
    background-color: rgba(242, 235, 221, 0.03);
    transform: translateY(-1px);
}

.select-item:active {
    transform: translateY(0);
}

.select-item-avatar {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    margin-right: 12px;
}

.select-item-name {
    font-family: 'Onest', sans-serif;
    font-size: 14px;
    font-weight: 500;
}

/* Search input in modal */
.search-wrapper {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(242, 235, 221, 0.3);
    font-size: 14px;
    pointer-events: none;
}

.search-input {
    width: 100%;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 12px 12px 36px;
    color: #F2EBDD;
    font-family: 'Onest', sans-serif;
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}

.search-input:focus {
    border-color: rgba(242, 235, 221, 0.25);
}

/* Confirm modal content */
.confirm-modal-content {
    width: 380px;
    padding: 24px;
    text-align: center;
}

.btn-confirm-cancel {
    background-color: #323338;
    color: #F2EBDD;
    padding: 8px 16px;
    font-size: 13px;
}

.btn-confirm-ok {
    background-color: #3b82f6;
    color: #ffffff;
    padding: 8px 16px;
    font-size: 13px;
}

/* Mobile Responsive styles */
@media (max-width: 768px) {
    .chat-section {
        padding: 36px 16px 20px 16px;
        margin: 0;
    }

    .chat-layout {
        grid-template-columns: 1fr;
        height: calc(100vh - 180px);
        height: calc(100dvh - 180px);
        margin: 0;
        border-radius: 12px;
        border: 1px solid var(--border-highlight);
        background: #0A0A0A;
        overflow: hidden;
    }

    .chat-sidebar {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 100%;
        border: none;
        border-radius: 12px;
        background: #0A0A0A;
    }

    .chat-sidebar.hidden-mobile {
        display: none !important;
    }

    .chat-window {
        display: none;
        width: 100%;
        height: 100%;
        border-radius: 0;
        background: #0A0A0A;
    }

    .chat-window.active-mobile {
        display: flex !important;
        flex-direction: column;
    }

    .chat-window-content {
        display: flex;
        flex-direction: column;
        height: 100%;
        width: 100%;
    }

    .chat-window-header {
        padding: 10px 14px;
        border-bottom: 1px solid var(--border-highlight);
        background: #0A0A0A;
    }

    .messages-container {
        flex: 1;
        padding: 12px;
        overflow-y: auto;
    }

    .chat-input-area {
        padding: 10px 12px;
        background: #0A0A0A;
        border-top: 1px solid var(--border-highlight);
        display: flex;
        gap: 8px;
    }

    .btn-mobile-back {
        background: transparent;
        border: 1px solid var(--border-highlight);
        color: var(--text-main);
        width: 34px;
        height: 34px;
        border-radius: 6px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 15px;
        cursor: pointer;
        margin-right: 8px;
        flex-shrink: 0;
        transition: opacity 0.2s;
    }

    .btn-mobile-back:hover {
        opacity: 0.85;
    }

    .btn-mobile-back:active {
        opacity: 0.7;
    }

    .chat-title {
        padding: 0 16px;
        font-size: 20px;
    }
}

/* Keyframe Animations */
@keyframes modalScaleIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

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

.confirm-modal-text {
    font-size: 14px;
    color: rgba(242, 235, 221, 0.7);
    line-height: 1.5;
    margin-bottom: 24px;
    font-family: 'Onest', sans-serif;
}

.confirm-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.danger-icon {
    margin-right: 8px;
    color: #ef4444;
}

.no-partners-notice {
    text-align: center;
    color: #6b7280;
    padding: 24px;
    font-size: 13px;
}

.partner-header-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.mobile-back-icon {
    font-size: 18px;
}
