/* Canon Media Guide — Chat UI */

:root {
    --canon-red: #cc0000;
    --canon-dark: #1a1a1a;
    --canon-gray: #f5f5f5;
    --canon-border: #e0e0e0;
    --canon-text: #333333;
    --canon-light-red: #fff0f0;
    --chat-user-bg: #e8f0fe;
    --chat-assistant-bg: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--canon-gray);
    color: var(--canon-text);
    height: 100vh;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--canon-dark);
    color: #ddd;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: margin-left 0.2s;
}

.sidebar.collapsed { margin-left: -260px; }

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid #333;
}

.new-chat-btn {
    width: 100%;
    background: none;
    border: 1px solid #555;
    border-radius: 8px;
    color: #ddd;
    padding: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.new-chat-btn:hover { border-color: #aaa; color: white; }

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conv-item {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.15s;
}

.conv-item:hover { background: #333; }
.conv-item.active { background: #444; color: white; }

.conv-item .conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.conv-item .conv-delete {
    display: none;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    flex-shrink: 0;
}

.conv-item:hover .conv-delete { display: block; }
.conv-item .conv-delete:hover { color: var(--canon-red); }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid #333;
}

.user-menu {
    font-size: 13px;
}

.user-menu a {
    color: #aaa;
    text-decoration: none;
    display: block;
    padding: 6px 0;
}

.user-menu a:hover { color: white; }

.user-info {
    font-weight: 500;
    color: white;
    margin-bottom: 4px;
    font-size: 14px;
}

/* Main content area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    border-radius: 4px;
}

.sidebar-toggle:hover { background: var(--canon-gray); }

/* Header */
.header {
    background: white;
    border-bottom: 3px solid var(--canon-red);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    z-index: 10;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo svg {
    height: 32px;
    width: auto;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--canon-dark);
}

.header-subtitle {
    font-size: 12px;
    color: #888;
    margin-left: auto;
}


/* Chat area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.2s ease-in;
}

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.message-user .message-avatar {
    background: var(--chat-user-bg);
    color: #1a73e8;
}

.message-assistant .message-avatar {
    background: var(--canon-light-red);
    color: var(--canon-red);
}

.message-bubble {
    max-width: 90%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 14px;
    overflow-x: auto;
}

.message-user .message-bubble {
    background: var(--chat-user-bg);
    border-bottom-right-radius: 4px;
}

.message-assistant .message-bubble {
    background: white;
    border: 1px solid var(--canon-border);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

/* Markdown rendering inside messages */
.message-bubble p { margin: 8px 0; }
.message-bubble p:first-child { margin-top: 0; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble strong { font-weight: 600; }
.message-bubble code {
    background: var(--canon-gray);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: "SF Mono", "Fira Code", monospace;
}
.message-bubble ul, .message-bubble ol {
    margin: 8px 0;
    padding-left: 24px;
}
.message-bubble li { margin: 4px 0; }
.message-bubble a {
    color: var(--canon-red);
    text-decoration: none;
}
.message-bubble a:hover { text-decoration: underline; }

/* Tables */
.message-bubble table {
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
    width: 100%;
}
.message-bubble th, .message-bubble td {
    border: 1px solid var(--canon-border);
    padding: 6px 10px;
    text-align: left;
}
.message-bubble th {
    background: var(--canon-gray);
    font-weight: 600;
}

/* Tool call indicator */
.tool-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--canon-light-red);
    border-radius: 8px;
    font-size: 12px;
    color: #666;
    margin: 4px 0 4px 44px;
}

.tool-indicator::before {
    content: "";
    width: 8px;
    height: 8px;
    background: var(--canon-red);
    border-radius: 50%;
    animation: pulse 1s infinite;
}

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

/* Input area */
.input-area {
    background: white;
    border-top: 1px solid var(--canon-border);
    padding: 16px 24px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

.input-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-wrapper textarea {
    flex: 1;
    border: 2px solid var(--canon-border);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.4;
    transition: border-color 0.2s;
}

.input-wrapper textarea:focus {
    border-color: var(--canon-red);
}

.input-wrapper textarea::placeholder {
    color: #aaa;
}

.send-btn {
    background: var(--canon-red);
    color: white;
    border: none;
    border-radius: 12px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.send-btn:hover { background: #a00; }
.send-btn:disabled { background: #ccc; cursor: not-allowed; }

.send-btn svg {
    width: 20px;
    height: 20px;
}

/* Welcome message */
.welcome {
    text-align: center;
    padding: 48px 24px;
    color: #888;
}

.welcome h2 {
    color: var(--canon-dark);
    margin-bottom: 8px;
    font-size: 20px;
}

.welcome p {
    font-size: 14px;
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.6;
}

.welcome-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}

.welcome-example {
    background: white;
    border: 1px solid var(--canon-border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.welcome-example:hover {
    border-color: var(--canon-red);
    color: var(--canon-red);
}

/* Thinking indicator (three bouncing dots) */
.thinking-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
    align-items: center;
}

.thinking-indicator span {
    width: 8px;
    height: 8px;
    background: #bbb;
    border-radius: 50%;
    animation: bounce 1.2s infinite ease-in-out;
}

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

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

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Responsive */
@media (max-width: 640px) {
    .message-bubble { max-width: 90%; }
    .header { padding: 10px 16px; }
    .chat-container { padding: 16px; }
    .input-area { padding: 12px 16px; }
}
