/* ==========================================================================
   borderschat.com - Full Responsive Messenger UI (Mobile-First & Desktop)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
    --bg-main: #0e1621;
    --bg-sidebar: #17212b;
    --bg-header: #17212b;
    --bg-active-chat: #202b36;
    --bg-hover-chat: #1c2733;
    --bg-chat-feed: #0e1621;
    --bg-input: #17212b;
    --bg-modal: #17212b;

    --border: #242f3d;
    --border-light: rgba(255, 255, 255, 0.07);

    --text-main: #f5f5f5;
    --text-sub: #7f91a4;
    --text-dim: #546577;

    --accent-blue: #5288c1;
    --accent-blue-hover: #4076af;
    --accent-green: #4fae4e;

    --bubble-out: #2b5278;
    --bubble-out-text: #ffffff;
    --bubble-in: #182533;
    --bubble-in-text: #f5f5f5;
}

[data-theme="light"] {
    --bg-main: #f0f2f5;
    --bg-sidebar: #ffffff;
    --bg-header: #ffffff;
    --bg-active-chat: #e7eff7;
    --bg-hover-chat: #f5f7f9;
    --bg-chat-feed: #e6ebee;
    --bg-input: #ffffff;
    --bg-modal: #ffffff;

    --border: #e3e7eb;
    --border-light: rgba(0, 0, 0, 0.08);

    --text-main: #111b21;
    --text-sub: #667781;
    --text-dim: #8696a0;

    --accent-blue: #3390ec;
    --accent-blue-hover: #267fd9;
    --accent-green: #25d366;

    --bubble-out: #eeffde;
    --bubble-out-text: #111b21;
    --bubble-in: #ffffff;
    --bubble-in-text: #111b21;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    height: 100dvh;
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    width: 100%;
    width: 100vw;
    overflow: hidden;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    touch-action: manipulation;
}

/* Force .hidden on all elements regardless of ID specificity */
.hidden,
[hidden],
#main-area.hidden,
#view-active-chat.hidden,
#view-empty-state.hidden,
#sidebar.hidden,
#android-install-banner.hidden,
#modal-start-chat.hidden,
#modal-queue.hidden,
#modal-captcha.hidden,
#modal-settings.hidden {
    display: none !important;
}

/* Custom mobile-friendly scrollbars */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-sub);
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* App Containers */
#app-root {
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    width: 100%;
    overflow: hidden;
    position: relative;
}

#main-area:not(.hidden) {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    position: relative;
}

#view-active-chat:not(.hidden) {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

#messages-container {
    flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* Bottom Input Dock - Strictly Pinned above Android Navigation Buttons */
.chat-input-dock {
    flex-shrink: 0;
    width: 100%;
    z-index: 40;
    background-color: var(--bg-header);
    border-top: 1px solid var(--border);
    padding: 10px 12px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
}

@media (max-width: 640px) {
    .chat-input-dock {
        padding-top: 10px;
        padding-bottom: max(22px, env(safe-area-inset-bottom, 22px));
    }
}

/* Conversation item */
.conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
    min-height: 60px;
}

.conv-item:hover {
    background-color: var(--bg-hover-chat);
}

.conv-item.active {
    background-color: var(--bg-active-chat);
}

/* Message Bubbles */
.msg-row {
    display: flex;
    width: 100%;
    margin-bottom: 8px;
}

.msg-row.self {
    justify-content: flex-end;
}

.msg-row.other {
    justify-content: flex-start;
}

.msg-bubble {
    position: relative;
    max-width: 82%;
    padding: 8px 13px;
    border-radius: 12px;
    font-size: 14.5px;
    line-height: 1.42;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

@media (min-width: 640px) {
    .msg-bubble {
        max-width: 72%;
    }
}

.msg-row.self .msg-bubble {
    background-color: var(--bubble-out);
    color: var(--bubble-out-text);
    border-bottom-right-radius: 2px;
}

.msg-row.other .msg-bubble {
    background-color: var(--bubble-in);
    color: var(--bubble-in-text);
    border-bottom-left-radius: 2px;
    border: 1px solid var(--border-light);
}

.msg-time {
    display: inline-block;
    font-size: 10px;
    margin-left: 8px;
    float: right;
    margin-top: 4px;
    opacity: 0.65;
}

.msg-system {
    width: 100%;
    text-align: center;
    margin: 10px 0;
}

.msg-system span {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-sub);
    font-size: 11.5px;
    font-weight: 500;
}

/* Tag Badges & Pills */
.tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background-color: rgba(82, 136, 193, 0.15);
    color: #8db5e2;
    border: 1px solid rgba(82, 136, 193, 0.25);
    white-space: nowrap;
}

.tag-badge-sm {
    padding: 1px 5px;
    font-size: 10px;
    border-radius: 4px;
}

/* Tag Selection Button */
.tag-select-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    background-color: var(--bg-main);
    color: var(--text-sub);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.tag-select-btn:hover {
    color: #ffffff;
    border-color: var(--accent-blue);
    background-color: rgba(82, 136, 193, 0.1);
}

.tag-select-btn.selected {
    background-color: var(--accent-blue);
    color: #ffffff;
    border-color: var(--accent-blue);
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(82, 136, 193, 0.3);
}

/* Sidebar Tag Filter Pill */
.tag-filter-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    background-color: var(--bg-main);
    color: var(--text-sub);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
}

.tag-filter-pill:hover {
    color: #ffffff;
    border-color: var(--accent-blue);
}

.tag-filter-pill.active {
    background-color: var(--accent-blue);
    color: #ffffff;
    border-color: var(--accent-blue);
    font-weight: 700;
}

/* Typing Dots */
@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.typing-dot {
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--text-sub);
    animation: typing-bounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* Radar Searching Animation */
@keyframes radar-pulse {
    0% { transform: scale(0.9); opacity: 0.8; }
    50% { transform: scale(1.15); opacity: 0.3; }
    100% { transform: scale(0.9); opacity: 0.8; }
}

.radar-pulse {
    animation: radar-pulse 2s infinite ease-in-out;
}

/* Mobile Inputs */
@media (max-width: 640px) {
    input[type="text"] {
        font-size: 16px !important;
    }
}
