/* EchoBot Custom Styles */

/* Theme Studio Variables */
:root {
    --mood-color: var(--teal-400);
    --mood-glow: rgba(20, 184, 166, 0.1);
}

body.theme-cyberpunk {
    --bg-0: #050505; --bg-1: #0a0a0a; --bg-2: #1a1a1a; --border-subtle: #ff003c; --border-glow: #00f3ff;
    --mood-color: #ff003c; --text-primary: #f0f0f0;
}
body.theme-forest {
    --bg-0: #06110a; --bg-1: #0a180e; --bg-2: #14281a; --border-subtle: #10b981; --border-glow: #34d399;
    --mood-color: #10b981;
}
body.theme-sahara {
    --bg-0: #110d06; --bg-1: #18130a; --bg-2: #281d14; --border-subtle: #f59e0b; --border-glow: #fbbf24;
    --mood-color: #f59e0b;
}

.chat-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100vh - var(--nav-height));
    margin-top: var(--nav-height);
    background: var(--bg-0);
    overflow: hidden;
    transition: background 1s ease;
    position: relative;
}

#sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1400;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Sidebar */
.chat-sidebar {
    background: var(--bg-1);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: var(--space-4);
    transition: transform 0.3s ease;
}

.sidebar-header {
    margin-bottom: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem 0.5rem 2rem;
    font-size: 0.8rem;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

.search-box input:focus {
    border-color: var(--mood-color);
    box-shadow: 0 0 10px var(--mood-glow);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
}

/* Sidebar Memory Section */
.sidebar-memory {
    background: rgba(30, 41, 59, 0.3);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.memory-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--teal-400);
}

.memory-header i { font-size: 1rem; }

.memory-content {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.memory-fact {
    background: rgba(59, 130, 246, 0.08);
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    animation: fadeIn 0.4s ease-out;
}

.empty-memory {
    opacity: 0.5;
    font-style: italic;
    text-align: center;
    padding: var(--space-2);
}

/* Scrollbar Customization */
.history-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-track,
.messages-container::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb { 
    background: var(--border-subtle); 
    border-radius: 10px; 
}
.history-list::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover { background: var(--border-glow); }

.history-item {
    padding: var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Adjusted to allow for delete button */
    gap: var(--space-2);
}

.history-item i:first-child { flex-shrink: 0; }
.history-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.history-item .btn-delete {
    opacity: 0;
    padding: 2px;
    font-size: 1rem;
    color: var(--text-muted);
}

.history-item:hover .btn-delete { opacity: 1; }
.history-item .btn-delete:hover { color: var(--purple-400); }

.history-item:hover {
    background: rgba(59, 130, 246, 0.05);
    color: var(--text-primary);
}

.history-item.active {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--border-glow);
    color: var(--text-primary);
}

.sidebar-footer {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-subtle);
}

/* Main Chat Area with Mood Glow */
.chat-main {
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at 50% 50%, var(--mood-glow) 0%, transparent 70%);
    position: relative;
    transition: background 1s ease;
}

.chat-main::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 60%; height: 60%;
    background: var(--mood-glow);
    filter: blur(100px);
    opacity: 0.2;
    z-index: 0;
    pointer-events: none;
    transition: background 1s ease;
}

.chat-header {
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(2, 4, 8, 0.5);
    backdrop-filter: blur(10px);
}

.bot-info {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.bot-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--mood-color), var(--blue-600));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    position: relative;
    box-shadow: 0 0 15px var(--mood-glow);
    transition: all 1s ease;
}

.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-1);
}

.status-indicator.online { background: #10b981; }
.status-indicator.busy { background: #f59e0b; }

.bot-name {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.2;
}

.bot-status {
    font-size: 0.75rem;
    color: var(--teal-400);
    font-weight: 500;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-8) var(--space-12);
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    scroll-behavior: smooth;
}

.message {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    animation: fadeIn 0.3s ease-out;
}

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

.bot-message {
    align-self: flex-start;
}

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

.message-content {
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-xl);
    font-size: var(--text-base);
    line-height: 1.6;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.bot-message .message-content {
    border-bottom-left-radius: var(--radius-sm);
}

.user-message .message-content {
    border-bottom-right-radius: var(--radius-sm);
}

/* Markdown Specifics */
.message-content ul, .message-content ol {
    margin-top: var(--space-2);
    margin-left: var(--space-6);
    list-style-type: disc;
}
.message-content li { margin-bottom: var(--space-1); }
.message-content code {
    background: rgba(0,0,0,0.3);
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    color: var(--teal-400);
}
.message-content pre {
    background: rgba(15, 23, 42, 0.6);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    margin: var(--space-3) 0;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.message-content pre::before {
    content: 'Code';
    position: absolute;
    top: 0; right: 0;
    padding: 0.2rem 0.5rem;
    font-size: 0.65rem;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border-bottom-left-radius: var(--radius-sm);
}

.message-content pre code { background: none; padding: 0; color: #e2e8f0; font-family: 'Fira Code', monospace; }

/* Interactive Charts */
.chart-container {
    margin: var(--space-3) 0;
    padding: var(--space-4);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.chart-svg {
    width: 100%;
    height: 150px;
}

.chart-bar {
    fill: var(--mood-color);
    filter: drop-shadow(0 0 5px var(--mood-glow));
    transition: all 0.5s ease;
}

.chart-axis { stroke: var(--text-muted); stroke-width: 1; }
.chart-label { fill: var(--text-muted); font-size: 10px; }

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-subtle);
}
.status-badge.online i { color: #10b981; }
.status-badge.offline i { color: #ef4444; }

.mobile-only { display: none; }

/* Copy Button */
.btn-copy {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-2);
    border: 1px solid var(--border-subtle);
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-md);
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
}

.message-actions {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 0;
    transition: all 0.2s ease;
}

.bot-message .message-actions { right: -40px; }
.user-message .message-actions { left: -40px; }

.message:hover .message-actions { opacity: 1; }
.message-actions .btn-copy { position: static; transform: none; opacity: 1; }
.btn-copy:hover { border-color: var(--teal-400); color: var(--teal-400); }

.btn-icon {
    padding: 4px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}
.btn-icon:hover { background: rgba(255, 255, 255, 0.1); }

.bot-message .message-content {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    backdrop-filter: blur(5px);
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--blue-600), var(--blue-700));
    color: white;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

.message-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    padding: 0 var(--space-2);
}

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

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: var(--space-2) var(--space-4);
    background: var(--bg-2);
    border-radius: var(--radius-full);
    width: fit-content;
    margin-bottom: var(--space-4);
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--teal-400);
    border-radius: 50%;
    animation: bounce 1s infinite alternate;
}

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

@keyframes bounce {
    from { transform: translateY(0); opacity: 0.4; }
    to { transform: translateY(-4px); opacity: 1; }
}

/* Input Area */
.input-container {
    padding: var(--space-6) var(--space-12) var(--space-8);
    background: linear-gradient(to top, var(--bg-0) 80%, transparent);
}

.chat-form {
    display: flex;
    gap: var(--space-3);
    background: var(--bg-3);
    padding: var(--space-2);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.chat-form:focus-within {
    border-color: var(--border-glow);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.1);
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: var(--space-3) var(--space-4);
    resize: none;
    outline: none;
    font-size: var(--text-base);
    line-height: 1.5;
    max-height: 200px;
}

.input-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: var(--space-3);
    text-align: center;
}

#llm-url-display {
    color: var(--teal-400);
    font-weight: 600;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-card {
    width: 100%;
    max-width: 450px;
    padding: var(--space-8);
}

.form-group {
    margin-bottom: var(--space-6);
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-input {
    width: 100%;
    background: var(--bg-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s ease;
}

.form-input:focus {
    border-color: var(--blue-400);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-8);
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
    margin-top: var(--space-2);
}

.theme-option {
    background: var(--bg-2);
    border: 2px solid transparent;
    padding: var(--space-2);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s;
}

.theme-option span {
    display: block;
    width: 100%;
    height: 20px;
    border-radius: var(--radius-sm);
}

.theme-option.active {
    border-color: var(--mood-color);
    background: var(--bg-3);
}

/* Onboarding Tour */
#onboarding-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 5000;
    display: none;
    pointer-events: none;
}

#onboarding-spotlight {
    position: absolute;
    width: 100px; height: 100px;
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.7);
    z-index: 5001;
    transition: all 0.3s ease;
}

#onboarding-tooltip {
    position: absolute;
    z-index: 5002;
    width: 250px;
    pointer-events: auto;
    animation: tourPop 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes tourPop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.tour-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-4);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 992px) {
    .chat-container {
        grid-template-columns: 1fr;
    }
    .mobile-only { display: block; }
    .chat-sidebar {
        position: fixed;
        left: 0;
        top: var(--nav-height);
        bottom: 0;
        z-index: 1500;
        transform: translateX(-100%);
        width: 250px;
        background: var(--bg-1);
        box-shadow: 20px 0 60px rgba(0,0,0,0.5);
    }
    .chat-sidebar.open { transform: translateX(0); }
    .messages-container { padding: var(--space-4); }
    .input-container { padding: var(--space-4); }
    .chat-header { padding: var(--space-4); }
    .status-badge span { display: none; } /* Hide text on small screens */
}
