/**
 * Character Chat Page Styles
 * 
 * Place this file in: wp-content/themes/red-room-digital/assets/css/character-chat.css
 * 
 * @package Red_Room_Digital
 */

/* ============================================
   CHAT PAGE LAYOUT
   ============================================ */

.rrd-chat-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--rrd-bg-dark, #0a0a0a);
}

.rrd-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    height: calc(100vh - 80px); /* Adjust based on your header height */
}

/* ============================================
   CHAT HEADER
   ============================================ */

.rrd-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--rrd-bg-card, #1a1a1a);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.rrd-chat-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--rrd-text-secondary, #888);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
    min-width: 80px;
}

.rrd-chat-back:hover {
    color: var(--rrd-text-primary, #fff);
}

.rrd-chat-header__character {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.rrd-chat-header__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--rrd-primary, #dc2626);
}

.rrd-chat-header__info {
    text-align: center;
}

.rrd-chat-header__name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--rrd-text-primary, #fff);
    margin: 0;
    font-family: var(--rrd-font-heading, inherit);
}

.rrd-chat-header__status {
    font-size: 0.75rem;
    color: #22c55e;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.rrd-chat-header__status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse-status 2s infinite;
}

@keyframes pulse-status {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.rrd-chat-header__spacer {
    min-width: 80px;
}

/* ============================================
   MESSAGES AREA
   ============================================ */

.rrd-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--rrd-bg-dark, #0a0a0a);
}

/* Scrollbar styling */
.rrd-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.rrd-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.rrd-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.rrd-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ============================================
   MESSAGE BUBBLES
   ============================================ */

.rrd-message {
    display: flex;
    gap: 0.75rem;
    max-width: 80%;
    animation: message-appear 0.3s ease;
}

@keyframes message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User messages - right aligned */
.rrd-message--user {
    flex-direction: row-reverse;
    margin-left: auto;
}

.rrd-message--user .rrd-message__bubble {
    background: linear-gradient(135deg, var(--rrd-primary, #dc2626) 0%, #991b1b 100%);
    border-radius: 1.25rem 1.25rem 0.25rem 1.25rem;
}

/* Assistant messages - left aligned */
.rrd-message--assistant {
    margin-right: auto;
}

.rrd-message--assistant .rrd-message__bubble {
    background: var(--rrd-bg-card, #1a1a1a);
    border-radius: 1.25rem 1.25rem 1.25rem 0.25rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.rrd-message__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.rrd-message__bubble {
    padding: 0.85rem 1.1rem;
}

.rrd-message__text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--rrd-text-primary, #e0e0e0);
    word-wrap: break-word;
}

.rrd-message__text em {
    font-style: italic;
    color: var(--rrd-text-secondary, #aaa);
}

/* Error messages */
.rrd-message--error .rrd-message__bubble {
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 1rem;
}

.rrd-message--error .rrd-message__text {
    color: #fca5a5;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.rrd-typing {
    display: flex;
    gap: 0.75rem;
    max-width: 80%;
    animation: message-appear 0.3s ease;
}

.rrd-typing__dots {
    display: flex;
    gap: 4px;
    padding: 1rem 1.25rem;
    background: var(--rrd-bg-card, #1a1a1a);
    border-radius: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.rrd-typing__dots span {
    width: 8px;
    height: 8px;
    background: var(--rrd-text-secondary, #666);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.rrd-typing__dots span:nth-child(1) { animation-delay: 0s; }
.rrd-typing__dots span:nth-child(2) { animation-delay: 0.2s; }
.rrd-typing__dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ============================================
   INPUT AREA
   ============================================ */

.rrd-chat-input-area {
    padding: 1rem 1.5rem 1.5rem;
    background: var(--rrd-bg-card, #1a1a1a);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.rrd-chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: var(--rrd-bg-medium, #252525);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1.5rem;
    padding: 0.5rem 0.5rem 0.5rem 1.25rem;
    transition: border-color 0.2s ease;
}

.rrd-chat-input-wrapper:focus-within {
    border-color: var(--rrd-primary, #dc2626);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--rrd-text-primary, #e0e0e0);
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    min-height: 24px;
    max-height: 150px;
    padding: 0.5rem 0;
    font-family: inherit;
}

#chat-input::placeholder {
    color: var(--rrd-text-secondary, #666);
}

#chat-input:focus {
    outline: none;
}

.rrd-chat-send {
    background: linear-gradient(135deg, var(--rrd-primary, #dc2626) 0%, #991b1b 100%);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    flex-shrink: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.rrd-chat-send:hover {
    transform: scale(1.05);
}

.rrd-chat-send:active {
    transform: scale(0.95);
}

.rrd-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.rrd-chat-disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--rrd-text-secondary, #666);
    margin: 0.75rem 0 0 0;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .rrd-chat-container {
        height: calc(100vh - 60px);
    }
    
    .rrd-chat-header {
        padding: 0.75rem 1rem;
    }
    
    .rrd-chat-back span {
        display: none;
    }
    
    .rrd-chat-back {
        min-width: auto;
    }
    
    .rrd-chat-header__spacer {
        min-width: 40px;
    }
    
    .rrd-chat-header__avatar {
        width: 38px;
        height: 38px;
    }
    
    .rrd-chat-header__name {
        font-size: 1rem;
    }
    
    .rrd-chat-messages {
        padding: 1rem;
    }
    
    .rrd-message {
        max-width: 90%;
    }
    
    .rrd-chat-input-area {
        padding: 0.75rem 1rem 1rem;
    }
}

/* ============================================
   EMPTY STATE
   ============================================ */

.rrd-chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
    color: var(--rrd-text-secondary, #666);
}

.rrd-chat-empty__icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.rrd-chat-empty__text {
    font-size: 1rem;
    margin: 0;
}