/* ========================================
   Couples Thing - Chat Styles
   WhatsApp-inspired messaging UI
   ======================================== */

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-primary);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(15, 8, 12, 0.98);
    border-bottom: 1px solid var(--glass-border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-sizing: border-box;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rose-gold), var(--rose-gold-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.chat-partner-name {
    font-weight: 600;
    color: var(--text-primary);
}

.chat-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chat-close-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.chat-close-btn:hover {
    background: var(--glass-bg);
}

/* Messages Area - WhatsApp style */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    padding-top: 70px; /* Account for fixed header */
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: linear-gradient(180deg, rgba(15, 5, 10, 0.95) 0%, rgba(25, 10, 20, 0.9) 100%);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23e4a0a0' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(228, 160, 160, 0.3);
    border-radius: 4px;
}

/* Message Bubbles - WhatsApp Style */
.message {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    animation: messageIn 0.2s ease;
    margin-bottom: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

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

/* Sent messages (right side) - Rose gold theme */
.message.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, #e4a0a0 0%, #d48888 100%);
    color: #1a0a0a;
    border-radius: 16px 16px 4px 16px;
    margin-right: 8px;
}

/* Message tail for sent */
.message.sent::after {
    content: '';
    position: absolute;
    right: -6px;
    bottom: 0;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-left-color: #d48888;
    border-bottom-color: #d48888;
    border-right: 0;
    border-bottom-right-radius: 4px;
}

/* Received messages (left side) */
.message.received {
    align-self: flex-start;
    background: rgba(45, 25, 35, 0.9);
    color: var(--text-primary);
    border: 1px solid rgba(228, 160, 160, 0.2);
    border-radius: 16px 16px 16px 4px;
    margin-left: 8px;
}

/* Message tail for received */
.message.received::after {
    content: '';
    position: absolute;
    left: -6px;
    bottom: 0;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-right-color: rgba(45, 25, 35, 0.9);
    border-bottom-color: rgba(45, 25, 35, 0.9);
    border-left: 0;
    border-bottom-left-radius: 4px;
}

.message-text {
    font-size: 0.95rem;
    line-height: 1.45;
    word-wrap: break-word;
    margin: 0;
}

/* Time and read status */
.message-time {
    font-size: 0.68rem;
    text-align: right;
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.message.sent .message-time {
    color: rgba(40, 20, 20, 0.7);
}

.message.received .message-time {
    color: rgba(255, 255, 255, 0.5);
}

/* Double tick for read receipts */
.message.sent .message-time::after {
    content: '✓✓';
    font-size: 0.7rem;
    margin-left: 2px;
    color: rgba(40, 20, 20, 0.6);
}

/* Date divider like WhatsApp */
.chat-date-divider {
    align-self: center;
    background: rgba(228, 160, 160, 0.15);
    color: rgba(255, 255, 255, 0.7);
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    margin: 12px 0;
}

/* Chat Input - WhatsApp Style */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 12px));
    background: rgba(25, 12, 18, 0.98);
    border-top: 1px solid rgba(228, 160, 160, 0.15);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    min-width: 0;
    padding: 10px 16px;
    background: rgba(40, 20, 30, 0.8);
    border: 1px solid rgba(228, 160, 160, 0.2);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 16px;
    resize: none;
    max-height: 100px;
    font-family: var(--font-body);
    line-height: 1.4;
}

.chat-input:focus {
    outline: none;
    border-color: rgba(228, 160, 160, 0.5);
    background: rgba(50, 25, 35, 0.9);
}

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

.chat-send-btn {
    width: 46px;
    height: 46px;
    min-width: 46px;
    background: linear-gradient(135deg, #e4a0a0 0%, #d48888 100%);
    border: none;
    border-radius: 50%;
    color: #1a0a0a;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(228, 160, 160, 0.3);
}

.chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 15px rgba(228, 160, 160, 0.5);
}

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

/* Empty State */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-secondary);
}

.chat-empty-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.chat-empty-text {
    font-size: 1rem;
}

/* Chat Toggle Button (on game screen) */
.chat-toggle-btn {
    position: fixed;
    bottom: 100px;
    right: var(--spacing-md);
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--rose-gold), var(--rose-gold-dark));
    border: none;
    border-radius: 50%;
    color: var(--bg-primary);
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(228, 160, 160, 0.4);
    z-index: 50;
    transition: all 0.3s ease;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
}

.chat-toggle-btn .unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: var(--crimson);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Overlay (Mobile) */
.chat-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.chat-overlay.open {
    transform: translateX(0);
}

/* Desktop: Chat Sidebar */
@media (min-width: 768px) {
    .chat-overlay {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        left: auto;
        width: 350px;
        border-left: 1px solid var(--glass-border);
        transform: translateX(100%);
    }
    
    .chat-overlay.open {
        transform: translateX(0);
    }
    
    .chat-toggle-btn {
        bottom: 120px;
    }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--rose-gold);
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Photo Button */
.chat-photo-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    background: var(--bg-primary);
    border: 2px solid var(--glass-border);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chat-photo-btn:hover, .chat-photo-btn:active {
    background: var(--glass-bg);
    border-color: var(--rose-gold);
}

/* Photo Message Bubble */
.message.photo {
    padding: var(--spacing-xs);
    max-width: 200px;
}

.photo-preview {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(20px);
}

.photo-preview.revealed img {
    filter: none;
}

.photo-preview .photo-lock {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    color: white;
}

.photo-preview.revealed .photo-lock {
    display: none;
}

.photo-preview .photo-lock span {
    font-size: 2rem;
    margin-bottom: var(--spacing-xs);
}

.photo-preview .photo-lock small {
    font-size: 0.7rem;
    opacity: 0.8;
}

.photo-preview.viewed {
    opacity: 0.5;
    pointer-events: none;
}

.photo-preview.viewed::after {
    content: 'Opened';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Sender can always view their photos */
.photo-preview.sender-photo {
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
}

.photo-preview.sender-photo img {
    filter: none;
}

.photo-sent-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
}

/* View Once Modal */
.view-once-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
}

.view-once-modal.hidden {
    display: none;
}

.view-once-container {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.view-once-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.view-once-label {
    font-size: 0.9rem;
    font-weight: 500;
}

.view-once-timer {
    font-size: 0.8rem;
    color: var(--rose-gold);
}

.view-once-image-container {
    position: relative;
    width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-secondary);
    min-height: 200px;
    min-width: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-once-image-container img {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    display: block;
    visibility: hidden;
}

.view-once-image-container img.visible {
    visibility: visible;
}

.view-once-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    cursor: pointer;
}

.view-once-overlay.hidden {
    display: none;
}

.view-once-overlay span {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
}

.view-once-overlay p {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.view-once-overlay small {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.view-once-close {
    margin-top: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-xl);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.view-once-close:hover {
    background: var(--bg-secondary);
    border-color: var(--rose-gold);
}

