:root {
    /* Palette - Premium/Calm */
    --primary-color: #6366f1;
    /* Indigo */
    --primary-hover: #4f46e5;
    --bg-app: #f8fafc;
    --bg-white: #ffffff;
    --bg-chat-bubble-agent: #f1f5f9;
    --bg-chat-bubble-user: #6366f1;

    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-on-primary: #ffffff;

    --border-color: #e2e8f0;
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;

    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);

    --transition-speed: 0.2s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-main);
    background-color: var(--bg-app);
    height: 100vh;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* --- Chat Section (Main) --- */
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-white);
    position: relative;
    box-shadow: var(--shadow-sm);
    /* visual separation from sidebar */
    z-index: 1;
}

/* Header */
.chat-header {
    height: 70px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
}

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

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.agent-avatar {
    background: var(--bg-chat-bubble-agent);
    color: var(--primary-color);
}

.agent-details h1 {
    font-size: 1rem;
    font-weight: 600;
}

.status-indicator {
    font-size: 0.8rem;
    color: #10b981;
    /* Green */
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-indicator::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* Messages Area */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
    background: #ffffff;
    padding-bottom: 40px;
}

/* Message Bubbles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    /* Slightly wider for premium feel */
    animation: fadeIn 0.3s ease-out;
}

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

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

.message-content {
    padding: 14px 18px;
    border-radius: var(--border-radius-lg);
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
}

.agent-message .message-content {
    background: var(--bg-white);
    /* Cleaner look, relying on shadow/border */
    /* border: 1px solid var(--border-color); optional, if bg is white */
    background: var(--bg-chat-bubble-agent);
    color: var(--text-main);
    border-top-left-radius: 4px;
}

.user-message .message-content {
    background: var(--bg-chat-bubble-user);
    color: var(--text-on-primary);
    border-top-right-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    margin-left: 4px;
}

.user-message .timestamp {
    margin-right: 4px;
}

/* --- Primary Actions Grid --- */
.primary-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 12px;
    width: 100%;
    max-width: 800px;
    /* Prevent stretching too wide on large screens */
}

.action-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.action-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-card.disabled {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(1);
}

.action-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
}

.action-icon {
    font-size: 1.1rem;
}

.action-subtext {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}


/* --- Suggestion Pills (New Style) --- */
.suggestion-pills {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
    margin-left: 0;
    margin-bottom: 4px;
}

.suggestion-pill {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all var(--transition-speed);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.suggestion-pill:hover {
    background: var(--bg-chat-bubble-agent);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}


/* Cards (Rich Content / Summary) */
.chat-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    margin-top: 8px;
    width: 320px;
    /* Fixed width for consistency */
    box-shadow: var(--shadow-md);
}

.chat-card h3 {
    font-size: 1.05rem;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.chat-card .card-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.chat-card .label {
    color: var(--text-muted);
}

.chat-card .value {
    font-weight: 500;
    color: var(--text-main);
    text-align: right;
}

.card-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
}

.card-btn {
    flex: 1;
    padding: 10px;
    border-radius: var(--border-radius-sm);
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
}

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

.card-btn.secondary {
    background: var(--bg-chat-bubble-agent);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.card-btn:hover {
    opacity: 0.9;
}

/* Input Area */
.chat-input-area {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-white);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-app);
    padding: 10px 16px;
    border-radius: 24px;
    border: 1px solid transparent;
    transition: border-color var(--transition-speed);
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    background: var(--bg-white);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-main);
    max-height: 100px;
    padding: 4px 0;
}

.attach-btn,
.send-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.attach-btn:hover {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.05);
}

.send-btn {
    color: var(--primary-color);
}

.send-btn:hover {
    background: rgba(99, 102, 241, 0.1);
}

/* File Preview */
.file-preview-area {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    padding: 0 8px;
}

.preview-item {
    background: var(--bg-app);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border-color);
}

.remove-file {
    cursor: pointer;
    color: #ef4444;
}

/* --- Context Sidebar --- */
.context-sidebar {
    width: 30%;
    min-width: 300px;
    border-left: 1px solid var(--border-color);
    background: var(--bg-app);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    height: 70px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.sidebar-content {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.context-card {
    background: var(--bg-white);
    padding: 16px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

.context-card .card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.context-card .card-value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-main);
}

.status-tag {
    display: inline-block;
    padding: 4px 12px;
    background: #e0e7ff;
    color: #4338ca;
    border-radius: 12px;
    font-size: 0.85rem;
}

.sidebar-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-secondary,
.btn-danger {
    padding: 12px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-secondary {
    background: var(--bg-white);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--bg-app);
}

/* Animations & Utilities */
.hidden {
    display: none !important;
}

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

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

/* Typing Indicator */
.typing-indicator {
    padding: 12px 18px;
    background: var(--bg-chat-bubble-agent);
    border-radius: var(--border-radius-lg);
    width: fit-content;
    display: flex;
    gap: 4px;
    margin-left: 24px;
    /* align with text in avatar */
    margin-bottom: 20px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

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

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Responsive */
.mobile-menu-btn,
.close-sidebar-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-main);
}

@media (max-width: 900px) {
    .context-sidebar {
        position: absolute;
        right: 0;
        top: 0;
        height: 100%;
        width: 80%;
        max-width: 320px;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        box-shadow: -4px 0 10px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    .context-sidebar.open {
        transform: translateX(0);
    }

    .mobile-menu-btn {
        display: block;
    }

    .close-sidebar-btn {
        display: block;
    }
}