/* ═══════════════════════════════════════════
   EA Chat Rooms — v1.0.0
   EasyAccurate Brand: Blue #1e6fcf, warm grays
   ═══════════════════════════════════════════ */

:root {
    --ea-blue:       #1e6fcf;
    --ea-blue-light: #e8f0fd;
    --ea-blue-dark:  #154d94;
    --ea-cyan:       #0891b2;
    --ea-green:      #16a34a;
    --ea-purple:     #9333ea;
    --ea-red:        #dc2626;
    --ea-gray-50:    #f8f9fa;
    --ea-gray-100:   #f1f3f5;
    --ea-gray-200:   #e5e7eb;
    --ea-gray-300:   #d1d5db;
    --ea-gray-500:   #6b7280;
    --ea-gray-700:   #374151;
    --ea-gray-900:   #111827;
    --ea-chat-bg:    #f5f5f7;
    --ea-msg-own:    #1e6fcf;
    --ea-msg-other:  #ffffff;
    --ea-msg-ai:     #f0f9ff;
    --ea-radius:     12px;
    --ea-radius-sm:  8px;
    --ea-font:       'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --ea-shadow-sm:  0 1px 3px rgba(0,0,0,0.06);
    --ea-shadow-md:  0 4px 12px rgba(0,0,0,0.08);
}

/* ── App Shell ── */
.ea-chat-app {
    display: flex;
    height: 680px;
    max-height: 80vh;
    border-radius: var(--ea-radius);
    overflow: hidden;
    box-shadow: var(--ea-shadow-md);
    font-family: var(--ea-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ea-gray-900);
    background: var(--ea-chat-bg);
    border: 1px solid var(--ea-gray-200);
}

/* ── Sidebar ── */
.ea-chat-sidebar {
    width: 280px;
    min-width: 280px;
    background: #fff;
    border-right: 1px solid var(--ea-gray-200);
    display: flex;
    flex-direction: column;
}

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

.ea-chat-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 17px;
    color: var(--ea-blue);
}

.ea-chat-logo-icon {
    font-size: 22px;
}

/* Room list */
.ea-chat-room-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.ea-chat-room-btn {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: var(--ea-radius-sm);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
    position: relative;
}

.ea-chat-room-btn:hover {
    background: var(--ea-gray-50);
}

.ea-chat-room-btn.active {
    background: var(--ea-blue-light);
}

.ea-chat-room-btn.active .ea-room-title {
    color: var(--ea-blue);
    font-weight: 600;
}

.ea-room-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ea-gray-100);
    border-radius: 8px;
    font-size: 16px;
    color: var(--ea-gray-500);
}

.ea-chat-room-btn.active .ea-room-icon {
    background: var(--ea-blue);
    color: #fff;
}

.ea-room-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.ea-room-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--ea-gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ea-room-desc {
    font-size: 11px;
    color: var(--ea-gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ea-room-ai-badge {
    flex-shrink: 0;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--ea-cyan);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 2px;
}

/* User card */
.ea-chat-user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--ea-gray-100);
    background: var(--ea-gray-50);
}

.ea-chat-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.ea-chat-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ea-chat-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--ea-gray-900);
}

.ea-chat-user-role {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    padding: 1px 8px;
    border-radius: 10px;
    width: fit-content;
}

/* ── Main Chat Area ── */
.ea-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--ea-chat-bg);
}

/* Header */
.ea-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid var(--ea-gray-200);
    min-height: 56px;
}

.ea-chat-hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    color: var(--ea-gray-700);
}

.ea-chat-header-info {
    flex: 1;
    min-width: 0;
}

.ea-chat-room-name {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--ea-gray-900);
}

.ea-chat-room-description {
    margin: 0;
    font-size: 12px;
    color: var(--ea-gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ea-chat-header-badge {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--ea-cyan);
    background: rgba(8, 145, 178, 0.08);
    padding: 4px 12px;
    border-radius: 20px;
}

.ea-chat-header-badge code {
    background: rgba(8, 145, 178, 0.15);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 10px;
}

.ea-ai-dot {
    width: 7px;
    height: 7px;
    background: var(--ea-cyan);
    border-radius: 50%;
    animation: ea-pulse 2s infinite;
}

@keyframes ea-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* ── Messages Container ── */
.ea-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Welcome state */
.ea-chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    color: var(--ea-gray-500);
    padding: 40px;
}

.ea-chat-welcome-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.ea-chat-welcome h3 {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 700;
    color: var(--ea-gray-700);
}

.ea-chat-welcome p {
    margin: 0;
    font-size: 14px;
}

/* Loading */
.ea-chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: var(--ea-gray-500);
    font-size: 13px;
}

.ea-chat-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--ea-gray-200);
    border-top-color: var(--ea-blue);
    border-radius: 50%;
    animation: ea-spin 0.6s linear infinite;
}

@keyframes ea-spin {
    to { transform: rotate(360deg); }
}

/* ── Individual Message ── */
.ea-chat-msg {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: ea-msg-in 0.2s ease-out;
}

@keyframes ea-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ea-chat-msg--own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ea-chat-msg--ai {
    max-width: 90%;
}

.ea-chat-msg-avatar {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    margin-top: 4px;
}

.ea-chat-msg--ai .ea-chat-msg-avatar {
    background: var(--ea-cyan);
    padding: 4px;
    border-radius: 50%;
}

.ea-chat-msg-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ea-chat-msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.ea-chat-msg--own .ea-chat-msg-meta {
    flex-direction: row-reverse;
}

.ea-chat-msg-name {
    font-weight: 600;
    color: var(--ea-gray-700);
}

.ea-chat-msg-role {
    font-size: 9px;
    font-weight: 600;
    color: #fff;
    padding: 1px 6px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ea-chat-msg-time {
    color: var(--ea-gray-500);
    font-size: 10px;
}

.ea-chat-msg-bubble {
    padding: 8px 14px;
    border-radius: 14px 14px 14px 4px;
    background: var(--ea-msg-other);
    box-shadow: var(--ea-shadow-sm);
    word-break: break-word;
    font-size: 13.5px;
    line-height: 1.55;
}

.ea-chat-msg--own .ea-chat-msg-bubble {
    background: var(--ea-msg-own);
    color: #fff;
    border-radius: 14px 14px 4px 14px;
}

.ea-chat-msg--ai .ea-chat-msg-bubble {
    background: var(--ea-msg-ai);
    border: 1px solid rgba(8, 145, 178, 0.15);
    border-radius: 14px 14px 14px 4px;
}

.ea-chat-msg-bubble p {
    margin: 0 0 6px;
}

.ea-chat-msg-bubble p:last-child {
    margin-bottom: 0;
}

.ea-chat-msg-bubble code {
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
}

.ea-chat-msg--own .ea-chat-msg-bubble code {
    background: rgba(255,255,255,0.2);
}

.ea-chat-msg-delete {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    color: var(--ea-gray-500);
    padding: 2px 4px;
}

.ea-chat-msg:hover .ea-chat-msg-delete {
    display: inline;
}

/* Date separator */
.ea-chat-date-sep {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--ea-gray-500);
    font-weight: 500;
    margin: 12px 0;
}

.ea-chat-date-sep::before,
.ea-chat-date-sep::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--ea-gray-200);
}

/* AI typing indicator */
.ea-chat-ai-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--ea-cyan);
    font-style: italic;
}

.ea-chat-ai-typing .ea-typing-dots span {
    display: inline-block;
    width: 5px;
    height: 5px;
    background: var(--ea-cyan);
    border-radius: 50%;
    margin: 0 1px;
    animation: ea-typing 1.2s infinite;
}

.ea-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ea-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ea-typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30%           { opacity: 1; transform: translateY(-3px); }
}

/* ── Compose Bar ── */
.ea-chat-compose {
    padding: 12px 20px 16px;
    background: #fff;
    border-top: 1px solid var(--ea-gray-200);
}

.ea-chat-compose-inner {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--ea-gray-50);
    border: 1px solid var(--ea-gray-200);
    border-radius: 22px;
    padding: 6px 6px 6px 16px;
    transition: border-color 0.15s;
}

.ea-chat-compose-inner:focus-within {
    border-color: var(--ea-blue);
    box-shadow: 0 0 0 3px rgba(30, 111, 207, 0.1);
}

.ea-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--ea-font);
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    min-height: 22px;
    max-height: 120px;
    padding: 4px 0;
    outline: none;
    color: var(--ea-gray-900);
}

.ea-chat-input::placeholder {
    color: var(--ea-gray-500);
}

.ea-chat-send {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--ea-blue);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
}

.ea-chat-send:hover {
    background: var(--ea-blue-dark);
}

.ea-chat-send:active {
    transform: scale(0.92);
}

.ea-chat-send:disabled {
    background: var(--ea-gray-300);
    cursor: not-allowed;
}

.ea-chat-compose-hint {
    font-size: 11px;
    color: var(--ea-gray-500);
    padding: 4px 16px 0;
    min-height: 16px;
}

/* Login prompt */
.ea-chat-login-prompt {
    text-align: center;
    padding: 8px;
}

.ea-chat-login-prompt p {
    margin: 0;
    font-size: 13px;
    color: var(--ea-gray-700);
}

.ea-chat-login-prompt a {
    color: var(--ea-blue);
    font-weight: 600;
    text-decoration: none;
}

.ea-chat-login-prompt a:hover {
    text-decoration: underline;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .ea-chat-app {
        height: 85vh;
        max-height: none;
        border-radius: 0;
    }

    .ea-chat-sidebar {
        position: absolute;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 100;
        transition: left 0.25s ease;
        box-shadow: var(--ea-shadow-md);
    }

    .ea-chat-sidebar.open {
        left: 0;
    }

    .ea-chat-app {
        position: relative;
    }

    .ea-chat-hamburger {
        display: block;
    }

    .ea-chat-header-badge {
        display: none;
    }

    .ea-chat-msg {
        max-width: 92%;
    }

    .ea-chat-messages {
        padding: 12px;
    }
}

/* ── Scrollbar ── */
.ea-chat-messages::-webkit-scrollbar,
.ea-chat-room-list::-webkit-scrollbar {
    width: 5px;
}

.ea-chat-messages::-webkit-scrollbar-thumb,
.ea-chat-room-list::-webkit-scrollbar-thumb {
    background: var(--ea-gray-300);
    border-radius: 3px;
}

.ea-chat-messages::-webkit-scrollbar-track,
.ea-chat-room-list::-webkit-scrollbar-track {
    background: transparent;
}

/* ── Load More ── */
.ea-chat-load-more {
    text-align: center;
    padding: 8px;
}

.ea-chat-load-more button {
    background: none;
    border: 1px solid var(--ea-gray-300);
    color: var(--ea-gray-500);
    font-size: 12px;
    padding: 4px 16px;
    border-radius: 16px;
    cursor: pointer;
    font-family: var(--ea-font);
    transition: all 0.15s;
}

.ea-chat-load-more button:hover {
    border-color: var(--ea-blue);
    color: var(--ea-blue);
}

/* ── Overlay for mobile sidebar ── */
.ea-chat-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 99;
}

.ea-chat-overlay.active {
    display: block;
}
