/**
 * HiFriendBot Chat Interface Styles
 */

:root {
    --hfb-primary: #6366f1;
    --hfb-primary-dark: #4f46e5;
    --hfb-bg: #f8fafc;
    --hfb-surface: #ffffff;
    --hfb-border: #e2e8f0;
    --hfb-text: #1e293b;
    --hfb-text-muted: #64748b;
    --hfb-user-bg: #6366f1;
    --hfb-user-text: #ffffff;
    --hfb-assistant-bg: #f1f5f9;
    --hfb-assistant-text: #1e293b;
    --hfb-radius: 16px;
    --hfb-radius-sm: 8px;
}

/* Container */
.hfb-chat-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--hfb-surface);
    border-radius: var(--hfb-radius);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 600px;
}

/* Companion Selector */
.hfb-companion-selector {
    border-bottom: 1px solid var(--hfb-border);
    padding: 12px 16px;
    background: var(--hfb-bg);
}

.hfb-companion-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.hfb-companion-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--hfb-surface);
    border: 1px solid var(--hfb-border);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.hfb-companion-tab:hover {
    border-color: var(--hfb-primary);
}

.hfb-companion-tab.active {
    background: var(--hfb-primary);
    border-color: var(--hfb-primary);
    color: white;
}

.hfb-companion-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--hfb-primary) 0%, var(--hfb-primary-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
}

.hfb-companion-tab.active .hfb-companion-avatar {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Header */
.hfb-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--hfb-border);
}

.hfb-companion-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hfb-companion-avatar-large {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--hfb-primary) 0%, var(--hfb-primary-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 20px;
}

.hfb-companion-details h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--hfb-text);
}

.hfb-companion-mode {
    font-size: 13px;
    color: var(--hfb-text-muted);
}

.hfb-usage-indicator {
    font-size: 13px;
    color: var(--hfb-text-muted);
}

.hfb-unlimited {
    color: var(--hfb-primary);
    font-weight: 500;
}

/* Messages Area */
.hfb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--hfb-bg);
}

.hfb-message {
    max-width: 80%;
    animation: hfb-fadeIn 0.3s ease;
}

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

.hfb-message.hfb-user {
    align-self: flex-end;
}

.hfb-message.hfb-assistant {
    align-self: flex-start;
}

.hfb-message-content {
    padding: 12px 16px;
    border-radius: var(--hfb-radius);
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.hfb-user .hfb-message-content {
    background: var(--hfb-user-bg);
    color: var(--hfb-user-text);
    border-bottom-right-radius: 4px;
}

.hfb-assistant .hfb-message-content {
    background: var(--hfb-assistant-bg);
    color: var(--hfb-assistant-text);
    border-bottom-left-radius: 4px;
}

/* Typing indicator */
.hfb-typing {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.hfb-typing span {
    width: 8px;
    height: 8px;
    background: var(--hfb-text-muted);
    border-radius: 50%;
    animation: hfb-bounce 1.4s infinite;
}

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

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

@keyframes hfb-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* Chat Input */
.hfb-chat-input {
    padding: 16px 20px;
    border-top: 1px solid var(--hfb-border);
    background: var(--hfb-surface);
}

#hfb-chat-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#hfb-message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--hfb-border);
    border-radius: 24px;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    max-height: 120px;
    transition: border-color 0.2s;
    font-family: inherit;
}

#hfb-message-input:focus {
    outline: none;
    border-color: var(--hfb-primary);
}

.hfb-send-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--hfb-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.hfb-send-btn:hover {
    background: var(--hfb-primary-dark);
}

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

.hfb-send-btn:disabled {
    background: var(--hfb-border);
    cursor: not-allowed;
}

/* Companion Cards */
.hfb-companions-grid {
    max-width: 1200px;
    margin: 0 auto;
}

.hfb-mode-section {
    margin-bottom: 48px;
}

.hfb-mode-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--hfb-text);
    margin-bottom: 8px;
}

.hfb-mode-description {
    color: var(--hfb-text-muted);
    margin-bottom: 24px;
    font-size: 16px;
}

.hfb-companion-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.hfb-companion-card {
    background: var(--hfb-surface);
    border: 1px solid var(--hfb-border);
    border-radius: var(--hfb-radius);
    padding: 24px;
    text-align: center;
    transition: box-shadow 0.2s, transform 0.2s;
}

.hfb-companion-card:hover {
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    transform: translateY(-2px);
}

.hfb-companion-card.hfb-added {
    border-color: var(--hfb-primary);
}

.hfb-card-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--hfb-primary) 0%, var(--hfb-primary-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 32px;
    margin: 0 auto 16px;
}

.hfb-companion-card h3 {
    margin: 0 0 8px;
    font-size: 20px;
    color: var(--hfb-text);
}

.hfb-card-personality {
    color: var(--hfb-text-muted);
    font-size: 14px;
    margin-bottom: 16px;
}

/* Buttons */
.hfb-btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--hfb-border);
    background: var(--hfb-surface);
    color: var(--hfb-text);
}

.hfb-btn:hover {
    border-color: var(--hfb-primary);
    color: var(--hfb-primary);
}

.hfb-btn-primary {
    background: var(--hfb-primary);
    border-color: var(--hfb-primary);
    color: white;
}

.hfb-btn-primary:hover {
    background: var(--hfb-primary-dark);
    border-color: var(--hfb-primary-dark);
    color: white;
}

.hfb-btn-disabled {
    background: var(--hfb-bg);
    color: var(--hfb-text-muted);
    cursor: not-allowed;
}

/* Login Prompt */
.hfb-login-prompt {
    max-width: 500px;
    margin: 48px auto;
    text-align: center;
    padding: 48px;
    background: var(--hfb-surface);
    border-radius: var(--hfb-radius);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.hfb-login-prompt h2 {
    margin-top: 0;
    color: var(--hfb-text);
}

.hfb-login-prompt p {
    color: var(--hfb-text-muted);
    margin-bottom: 24px;
}

.hfb-login-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* No companions message */
.hfb-no-companions {
    text-align: center;
    padding: 20px;
}

.hfb-no-companions p {
    margin-bottom: 12px;
    color: var(--hfb-text-muted);
}

/* Responsive */
@media (max-width: 640px) {
    .hfb-chat-container {
        border-radius: 0;
        height: calc(100vh - 100px);
    }

    .hfb-message {
        max-width: 90%;
    }

    .hfb-companion-cards {
        grid-template-columns: 1fr;
    }
}
