:root {
    --bg-color: #ffffff;
    --text-color: #374151;
    /* Gray 700 */
    --primary-color: #10a37f;
    /* ChatGPT Green ish */
    --secondary-color: #6b7280;
    /* Gray 500 */
    --card-bg: #f9fafb;
    /* Gray 50 */
    --border-color: #e5e7eb;
    /* Gray 200 */
    --accent-color: #10a37f;

    --user-msg-bg: #f3f4f6;
    /* Gray 100 */
    --user-msg-text: #1f2937;

    --agent-msg-bg: transparent;
    --agent-msg-text: #111827;

    --tool-msg-bg: #eff6ff;
    /* Blue 50 */
    --thinking-msg-bg: #fdf2f8;
    /* Pink 50 or similar light */
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #0d8a6a;
}

.container {
    max-width: 800px;
    /* ChatGPT style is often centered and contained */
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

/* Auth Page */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.auth-card {
    background: white;
    padding: 2.5rem;
    border-radius: 8px;
    /* Softer radius */
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: #111827;
    font-weight: 700;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    background: var(--primary-color);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: #0d8a6a;
}

.error-msg {
    color: #ef4444;
    text-align: center;
    margin-bottom: 1rem;
    background: #fef2f2;
    padding: 10px;
    border-radius: 6px;
}

/* Share Buttons */
.share-btn {
    background: transparent;
    border: none;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    color: #6b7280;
    /* Default Gray (Private) */
}

.share-btn:hover {
    background: #f3f4f6;
}

.share-btn.public {
    color: #3b82f6;
    /* Blue (Public) */
}

.share-btn.public:hover {
    background: #eff6ff;
}

/* Chat List */
.room-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0;
}

.room-card-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.room-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.25rem;
    transition: all 0.2s;
    cursor: pointer;
    display: block;
    flex: 1;
    /* Take remaining space */
}

.room-card:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.delete-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    /* Red-500 */
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.delete-btn:hover {
    background: #fee2e2;
    /* Red-100 */
}

.room-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: #111827;
}

.room-meta {
    color: var(--secondary-color);
    font-size: 0.85rem;
}

/* User Groups for Admin */
.user-group {
    margin-bottom: 2rem;
}

.group-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.empty-state {
    text-align: center;
    padding: 4rem;
    color: var(--secondary-color);
}

/* Chat History */
.chat-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    /* More spacing like ChatGPT */
    padding-bottom: 4rem;
}

.message-row {
    display: flex;
    width: 100%;
    gap: 1rem;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.other {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 90%;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    line-height: 1.6;
    position: relative;
    font-size: 1rem;
}

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

.message-row.other .message-bubble {
    background: transparent;
    color: var(--agent-msg-text);
    padding: 0;
    /* Remove padding for non-bubble look */
    max-width: 100%;
}

.type-tool .message-bubble {
    font-family: monospace;
    background: var(--tool-msg-bg) !important;
    padding: 1rem !important;
    border-radius: 8px !important;
    color: #1e3a8a !important;
}

.type-thinking .message-bubble {
    color: #6b7280 !important;
    font-style: italic;
}

.timestamp {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-top: 4px;
    display: block;
}

/* Header */
header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo::before {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 4px;
}

.nav-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: background 0.2s;
}

.nav-btn:hover {
    background: #f3f4f6;
}

/* =====================
   History Page Styles
   ===================== */

/* Tool message collapsible card */
.tool-card {
    background: #f3f4f6;
    border-radius: 8px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    color: #4b5563;
    font-size: 0.9rem;
    font-weight: 500;
    user-select: none;
}

.tool-header:hover {
    background: #e5e7eb;
}

.tool-arrow {
    transition: transform 0.2s;
    font-size: 0.75rem;
}

.tool-card.expanded .tool-arrow {
    transform: rotate(180deg);
}

.tool-content {
    display: none;
    padding: 0 1rem 1rem 1rem;
    color: #374151;
    font-family: monospace;
    font-size: 0.85rem;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
}

.tool-card.expanded .tool-content {
    display: block;
}

/* System message card */
.system-card {
    background: #fef2f2;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    color: #dc2626;
    font-size: 0.9rem;
    font-family: monospace;
    word-break: break-word;
}

/* Markdown content styling */
.markdown-content {
    line-height: 1.7;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: #111827;
}

.markdown-content h1 {
    font-size: 1.5rem;
}

.markdown-content h2 {
    font-size: 1.25rem;
}

.markdown-content h3 {
    font-size: 1.1rem;
}

.markdown-content p {
    margin: 0.75rem 0;
}

.markdown-content code {
    background: #f3f4f6;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.markdown-content pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
}

.markdown-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.markdown-content ul,
.markdown-content ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.markdown-content li {
    margin: 0.25rem 0;
}

.markdown-content blockquote {
    border-left: 3px solid #d1d5db;
    margin: 1rem 0;
    padding-left: 1rem;
    color: #6b7280;
}

.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid #d1d5db;
    padding: 0.5rem;
    text-align: left;
}

.markdown-content th {
    background: #f3f4f6;
}

/* Thinking message */
.thinking-content {
    color: #6b7280;
    font-style: italic;
}