/**
 * Talk With Me - Live Messenger & Chat System Stylesheet
 * Complete Modern Mobile UI/UX with Smooth Transitions & Touch Interactions
 */

.chat-app-wrapper {
    height: calc(100vh - 72px);
    height: calc(100dvh - 72px);
    display: flex;
    overflow: hidden;
    position: relative;
    background: var(--bg-dark);
}

/* Chat Sidebar */
.chat-sidebar {
    width: 340px;
    border-right: 1px solid var(--border-glass);
    background: rgba(22, 7, 15, 0.94);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.chat-sidebar-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-glass);
}

.chat-conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    -webkit-overflow-scrolling: touch;
}

.conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border-radius: 14px;
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-bottom: 6px;
    border: 1px solid transparent;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.conv-item:hover {
    background: rgba(255, 107, 139, 0.08);
}

.conv-item:active {
    transform: scale(0.98);
}

.conv-item.active {
    background: rgba(255, 107, 139, 0.15);
    border-color: rgba(255, 107, 139, 0.3);
}

.conv-avatar {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--rose-primary), var(--wine-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.05rem;
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(255, 107, 139, 0.2);
}

.conv-avatar.human {
    background: linear-gradient(135deg, #f59e0b, #b45309);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.status-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid var(--bg-dark);
}

.status-dot.waiting {
    background: #f59e0b;
    animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

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

.conv-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 3px;
}

.conv-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.conv-preview {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat Main View */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top right, rgba(45, 12, 28, 0.4), transparent 60%), var(--bg-dark);
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.chat-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(22, 7, 15, 0.88);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 5;
}

.chat-partner-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-partner-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.chat-partner-status {
    font-size: 0.76rem;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* User Active Location Badge in Chat Header */
.user-active-loc-badge {
    background: rgba(255, 107, 139, 0.12);
    border: 1px solid rgba(255, 107, 139, 0.3) !important;
    color: var(--rose-primary);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.74rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    -webkit-tap-highlight-color: transparent;
}

.user-active-loc-badge:hover {
    background: rgba(255, 107, 139, 0.25);
    color: #fff;
    transform: translateY(-1px);
}

/* Waiting for Human Connection Banner */
.waiting-banner {
    background: rgba(245, 158, 11, 0.14);
    border-bottom: 1px solid rgba(245, 158, 11, 0.25);
    padding: 8px 16px;
    font-size: 0.82rem;
    color: #fcd34d;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Message Stream */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    -webkit-overflow-scrolling: touch;
}

.chat-date-separator {
    text-align: center;
    margin: 8px 0;
    position: relative;
}

.chat-date-separator span {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 3px 12px;
    border-radius: 20px;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 78%;
    animation: fadeInMsg 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.message-wrapper.outgoing {
    align-self: flex-end;
    align-items: flex-end;
}

.message-wrapper.incoming {
    align-self: flex-start;
    align-items: flex-start;
}

.message-bubble {
    padding: 11px 16px;
    border-radius: 18px;
    font-size: 0.92rem;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
    white-space: pre-wrap;
}

.message-wrapper.outgoing .message-bubble {
    background: linear-gradient(135deg, var(--rose-primary), var(--wine-accent));
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 14px var(--rose-glow);
}

.message-wrapper.incoming .message-bubble {
    background: rgba(45, 16, 32, 0.9);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 3px;
    padding: 0 3px;
}

.message-wrapper.outgoing .message-meta {
    color: rgba(255, 255, 255, 0.7);
}

.read-ticks {
    color: #60a5fa;
}

/* Typing Indicator Animation */
.typing-indicator-box {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 9px 15px;
    background: rgba(45, 16, 32, 0.88);
    border: 1px solid var(--border-glass);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--rose-primary);
    animation: typingBounce 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; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Quick Topic Chips */
.quick-topics-row {
    padding: 8px 16px 2px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.quick-topics-row::-webkit-scrollbar {
    display: none;
}

.topic-chip {
    background: rgba(255, 107, 139, 0.08);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 6px 13px;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition-smooth);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.topic-chip:hover,
.topic-chip:active {
    background: rgba(255, 107, 139, 0.22);
    color: #fff;
    border-color: var(--rose-primary);
    transform: translateY(-1px);
}

/* Chat Location Locked Notice Bar */
.chat-location-locked-bar {
    padding: 8px 18px 0;
    animation: fadeInSlideUp 0.3s ease;
}

.chat-location-locked-bar > div {
    background: rgba(255, 107, 139, 0.14);
    border: 1px solid rgba(255, 107, 139, 0.35);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

/* Chat Input Bar */
.chat-input-area {
    padding: 10px 18px calc(10px + var(--safe-area-bottom));
    background: rgba(22, 7, 15, 0.92);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border-glass);
}

.chat-input-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 26px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition-smooth);
}

.chat-input-box.locked {
    opacity: 0.65;
    border-color: rgba(255, 107, 139, 0.25);
    background: rgba(255, 255, 255, 0.02);
    cursor: not-allowed;
}

.chat-input-box:focus-within:not(.locked) {
    border-color: var(--rose-primary);
    box-shadow: 0 0 15px var(--rose-glow);
    background: rgba(255, 255, 255, 0.08);
}

.chat-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.94rem;
    resize: none;
    max-height: 110px;
    line-height: 1.4;
    padding: 5px 0;
}

.chat-textarea:disabled {
    cursor: not-allowed;
}

.chat-textarea::placeholder {
    color: var(--text-muted);
}

.btn-send-msg {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rose-primary), var(--wine-accent));
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    flex-shrink: 0;
    box-shadow: 0 3px 10px var(--rose-glow);
    -webkit-tap-highlight-color: transparent;
}

.btn-send-msg:hover,
.btn-send-msg:active {
    transform: scale(1.06);
    box-shadow: 0 4px 15px var(--rose-glow);
}

.btn-send-msg:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Mandatory Location Modal */
.location-mandatory-modal .modal-content {
    background: rgba(18, 5, 13, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 107, 139, 0.3);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), 0 0 30px rgba(255, 107, 139, 0.15);
}

.location-pulse-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--rose-primary), var(--wine-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    box-shadow: 0 0 15px var(--rose-glow);
    animation: locationRadarPulse 2s infinite;
    flex-shrink: 0;
}

@keyframes locationRadarPulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 107, 139, 0.7); }
    70% { box-shadow: 0 0 0 12px rgba(255, 107, 139, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 107, 139, 0); }
}

.modal-or-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.78rem;
    font-weight: 500;
}

.modal-or-divider::before,
.modal-or-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-or-divider span {
    padding: 0 12px;
}

.map-locate-floating-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 600;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    background: rgba(18, 5, 13, 0.88);
    border: 1px solid rgba(255, 107, 139, 0.4);
    color: #fff;
    padding: 4px 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    transition: var(--transition-smooth);
}

.map-locate-floating-btn:hover {
    background: rgba(255, 107, 139, 0.25);
    border-color: var(--rose-primary);
    color: #fff;
    transform: translateY(-1px);
}

.map-hint-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    background: rgba(10, 3, 7, 0.85);
    backdrop-filter: blur(6px);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    pointer-events: none;
    z-index: 500;
}

.selected-loc-preview-card {
    background: rgba(255, 107, 139, 0.08);
    border: 1px solid rgba(255, 107, 139, 0.2);
}
