/* Creatibog Chat - Estilo mejorado */
:root {
    --cb-chat-primary: var(--creatibog-color-primary, #FB5F34);
    --cb-chat-primary-hover: color-mix(in srgb, var(--cb-chat-primary), black 12%);
    --cb-chat-bg: #ffffff;
    --cb-chat-sidebar-bg: #f8fafc;
    --cb-chat-messages-bg: #f1f5f9;
    --cb-chat-border: #e2e8f0;
    --cb-chat-text: #1e293b;
    --cb-chat-text-muted: #64748b;
    --cb-chat-mine-bg: var(--cb-chat-primary);
    --cb-chat-theirs-bg: #ffffff;
    --cb-chat-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --cb-chat-radius: 12px;
    --cb-chat-radius-sm: 8px;
}

.cb-chat-container {
    display: flex;
    height: 540px;
    border: 1px solid var(--cb-chat-border);
    border-radius: var(--cb-chat-radius);
    overflow: hidden;
    background: var(--cb-chat-bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: var(--cb-chat-shadow);
}

.cb-chat-sidebar {
    width: 280px;
    min-width: 280px;
    border-right: 1px solid var(--cb-chat-border);
    background: var(--cb-chat-sidebar-bg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.cb-chat-sidebar::-webkit-scrollbar {
    width: 6px;
}

.cb-chat-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.cb-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--cb-chat-bg);
}

/* Header del chat */
.cb-chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--cb-chat-border);
    font-weight: 600;
    font-size: 1.05rem;
    background: var(--cb-chat-bg);
    color: var(--cb-chat-text);
    display: flex;
    align-items: center;
    gap: 12px;
}

.cb-chat-header:empty::before {
    content: 'Selecciona una conversación';
    color: var(--cb-chat-text-muted);
    font-weight: 500;
}

/* Área de mensajes */
.cb-chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--cb-chat-messages-bg);
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(251, 95, 52, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(251, 95, 52, 0.02) 0%, transparent 50%);
}

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

.cb-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Estado vacío - Selecciona conversación */
.cb-chat-main:has(.cb-chat-messages:empty) .cb-chat-messages,
.cb-chat-messages:only-child {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Estado vacío - sin conversación seleccionada */
.cb-empty-state {
    text-align: center;
    color: var(--cb-chat-text-muted);
    font-size: 1rem;
    margin: auto;
    padding: 48px 32px;
    max-width: 360px;
    line-height: 1.7;
}

.cb-chat-messages > p:only-child {
    text-align: center;
    color: var(--cb-chat-text-muted);
    font-size: 1rem;
    margin: 0;
    padding: 40px 24px;
    max-width: 320px;
    line-height: 1.6;
}

/* Área de input */
.cb-chat-input-area {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--cb-chat-border);
    display: flex;
    gap: 12px;
    background: var(--cb-chat-bg);
    align-items: flex-end;
}

.cb-chat-input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.cb-chat-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--cb-chat-border);
    border-radius: var(--cb-chat-radius-sm);
    font-size: 15px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cb-chat-input:focus {
    outline: none;
    border-color: var(--cb-chat-primary);
    box-shadow: 0 0 0 3px rgba(251, 95, 52, 0.12);
}

.cb-chat-input:disabled {
    background: #f8fafc;
    color: var(--cb-chat-text-muted);
}

.cb-chat-btn {
    background: var(--cb-chat-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--cb-chat-radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s, transform 0.15s;
    height: 44px;
    flex-shrink: 0;
}

.cb-chat-btn:hover:not(:disabled) {
    background: var(--cb-chat-primary-hover);
    transform: translateY(-1px);
}

.cb-chat-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

.cb-attach-btn {
    background: var(--cb-chat-sidebar-bg);
    color: var(--cb-chat-text-muted);
    border: 1px solid var(--cb-chat-border);
    padding: 0 14px;
    border-radius: var(--cb-chat-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
}

.cb-attach-btn:hover {
    background: #e2e8f0;
    color: var(--cb-chat-primary);
}

.cb-file-preview {
    font-size: 0.85rem;
    color: var(--cb-chat-text-muted);
    padding: 8px 12px;
    background: var(--cb-chat-sidebar-bg);
    border-radius: var(--cb-chat-radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px dashed var(--cb-chat-border);
}

.cb-remove-file {
    cursor: pointer;
    color: #ef4444;
    font-weight: bold;
    font-size: 1.2em;
    line-height: 1;
    margin-left: 4px;
}

.cb-remove-file:hover {
    color: #dc2626;
}

/* Mensajes */
.cb-message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.cb-message.mine {
    align-self: flex-end;
    background: var(--cb-chat-mine-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

.cb-message.theirs {
    align-self: flex-start;
    background: var(--cb-chat-theirs-bg);
    color: var(--cb-chat-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--cb-chat-border);
}

.cb-message-time {
    font-size: 0.7rem;
    opacity: 0.85;
    margin-top: 6px;
    display: block;
    text-align: right;
}

.cb-message.theirs .cb-message-time {
    color: var(--cb-chat-text-muted);
}

.cb-message-attachment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: var(--cb-chat-radius-sm);
    color: inherit;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.cb-message.theirs .cb-message-attachment {
    background: rgba(0, 0, 0, 0.04);
}

.cb-message-attachment:hover {
    background: rgba(255, 255, 255, 0.35);
}

.cb-message.theirs .cb-message-attachment:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Items de conversación - Sidebar */
.cb-conversation-item {
    padding: 14px 18px;
    border-bottom: 1px solid var(--cb-chat-border);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 14px;
}

.cb-conversation-item:hover {
    background: rgba(251, 95, 52, 0.06);
}

.cb-conversation-item.active {
    background: rgba(251, 95, 52, 0.1);
    border-left: 3px solid var(--cb-chat-primary);
}

.cb-conv-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--cb-chat-text);
}

.cb-conv-preview {
    font-size: 0.8rem;
    color: var(--cb-chat-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

/* Avatar y badge */
.cb-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.cb-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--cb-chat-border);
    display: block;
}

.cb-conversation-item.active .cb-avatar {
    border-color: var(--cb-chat-primary);
}

.cb-conv-info {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.cb-unread-badge {
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
}
