/* ============================================
   MAEDO AGENT CHAT - STYLES
   Theme: Deep Void (Premium Glassmorphism)
   ============================================ */

:root {
    /* Color Palette - Deep Void */
    --bg-void: #030014;
    --bg-depth: #0f0a1f;
    --bg-surface: rgba(18, 12, 33, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-heavy: rgba(15, 10, 30, 0.85);

    --accent-primary: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.4);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent-text: #818cf8;

    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;

    --border-light: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(99, 102, 241, 0.3);

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    /* Spacing & Sizes */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --header-height: 70px;

    /* Effects */
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
    --blur-strength: 12px;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-void);
    background-image:
        radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.08) 0%, transparent 40%);
    color: var(--text-primary);
    font-family: var(--font-sans);
    height: 100vh;
    overflow: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Layout Grid */
.app-container {
    display: grid;
    grid-template-areas:
        "chat panels";
    grid-template-columns: 1fr 340px;
    /* Chat | Side Panels */
    grid-template-rows: 1fr;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
}

/* ================= HEADER REMOVED ================= */
/* .header styles removed */

/* ================= CHAT AREA ================= */
.chat-container {
    grid-area: chat;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 1rem;
    max-width: 85%;
    animation: slideUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-light);
}

.message.user .message-avatar {
    background: var(--accent-gradient);
    border: none;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message.user .message-content {
    align-items: flex-end;
}

.message-header {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 2px;
}

.message-text {
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    transition: transform 0.2s;
}

.message.assistant .message-text {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-top-left-radius: 4px;
    color: var(--text-secondary);
}

.message.user .message-text {
    background: var(--accent-primary);
    /* Fallback */
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.1));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-top-right-radius: 4px;
    color: #fff;
    backdrop-filter: blur(5px);
}

/* Welcome Screen */
.welcome-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    max-width: 500px;
    width: 100%;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.welcome-message.hidden {
    opacity: 0;
    pointer-events: none;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    filter: drop-shadow(0 0 20px var(--accent-glow));
    animation: float 6s ease-in-out infinite;
}

.welcome-message h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, #a5a6f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-message p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.quick-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.quick-action {
    background: var(--bg-glass);
    border: 1px solid var(--border-light);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-action:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
    color: #fff;
}

/* ================= INPUT AREA ================= */
.input-area {
    padding: 1.5rem 2rem;
    background: transparent;
    /* Seamless blend */
    position: relative;
    z-index: 5;
}

.input-form {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
}

.input-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    padding: 8px 8px 8px 20px;
    display: flex;
    align-items: flex-end;
    /* Align bottom for multiline */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2), 0 8px 30px rgba(0, 0, 0, 0.3);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 0.95rem;
    padding: 12px 0;
    max-height: 120px;
    resize: none;
    font-family: inherit;
}

textarea:focus {
    outline: none;
}

.send-button {
    background: var(--accent-gradient);
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    margin-left: 10px;
    transition: transform 0.2s, opacity 0.2s;
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #333;
}

.send-button:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--accent-glow);
}

.input-footer {
    position: absolute;
    bottom: -24px;
    left: 24px;
    right: 24px;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* ================= PANELS (RIGHT SIDEBAR) ================= */
.panels-container {
    grid-area: panels;
    background: rgba(10, 5, 20, 0.4);
    border-left: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Profile Panel embedded in sidebar */
.profile-panel-mini {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.profile-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 1.25rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.profile-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, rgba(99, 102, 241, 0.1), transparent);
    z-index: 0;
}

.profile-avatar-large {
    width: 64px;
    height: 64px;
    margin: 0 auto 0.75rem;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    position: relative;
    z-index: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.profile-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    position: relative;
    z-index: 1;
}

.profile-location {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    position: relative;
    z-index: 1;
}

/* Debug / Tools Panel */
.tools-panel {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.panel-section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-grid {
    display: grid;
    gap: 1rem;
}

.config-item label {
    display: block;
    font-size: 0.75rem;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.config-item input {
    width: 100%;
    background: var(--bg-glass);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.config-item input:focus {
    border-color: var(--accent-primary);
    outline: none;
    background: rgba(255, 255, 255, 0.05);
}

.config-item input[readonly] {
    opacity: 0.7;
    cursor: default;
    background: transparent;
    border-color: transparent;
    padding-left: 0;
}

/* Thinking Block */
.thinking-block {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
    font-size: 0.8rem;
}

.thinking-summary {
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-tertiary);
    user-select: none;
    transition: color 0.2s;
    font-weight: 500;
}

.thinking-summary:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
}

.thinking-icon {
    width: 12px;
    height: 12px;
    opacity: 0.7;
}

.thinking-content {
    padding: 0 10px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
}

.step-item {
    margin-top: 8px;
    padding-left: 8px;
    border-left: 2px solid var(--accent-primary);
}

.step-header {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent-text);
    margin-bottom: 4px;
    opacity: 0.9;
}

/* Data Lists for Sidebar */
.data-list-mini {
    list-style: none;
    padding: 0;
    margin: 0;
}

.data-list-mini li {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 6px 0;
    border-bottom: 1px dashed var(--border-light);
    display: flex;
    gap: 8px;
}

.data-list-mini li::before {
    content: '•';
    color: var(--accent-primary);
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pref-tag {
    font-size: 0.75rem;
    padding: 4px 8px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 4px;
    color: var(--accent-text);
}

.pref-tag .key {
    color: var(--text-tertiary);
    margin-right: 4px;
}

/* Debug Output Box */
.debug-box {
    background: #000;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.debug-step {
    border-left: 2px solid var(--accent-primary);
    padding-left: 8px;
    margin-bottom: 8px;
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

/* Responsive */
@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "chat";
    }

    .panels-container {
        display: none;
        /* Hide panels on mobile for now or make collapsible */
    }
}