/* style.css - Final Version with Dark Theme and Polished Chat */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --font-sans: 'Inter', sans-serif;
    --primary-color: #4f46e5; /* Indigo */
    --primary-hover: #4338ca;
    --background-color: #f1f5f9; /* A pleasing slate/grey background */
    --card-bg: #ffffff;
    --header-bg: #1e293b; /* Dark Slate */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #16a34a;
    --error-color: #dc2626;
    --radius-lg: 0.5rem;   /* 8px */
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

*, *::before, *::after { box-sizing: border-box; }

/* --- Global & Body --- */
body { font-family: var(--font-sans); background-color: var(--background-color); color: var(--text-primary); margin: 0; line-height: 1.5; display: flex; flex-direction: column; min-height: 100vh; }
.container { max-width: 1280px; margin: 2rem auto; padding: 0 1.5rem; flex-grow: 1; }
h1, h2, h3 { font-weight: 600; }
h1 { font-size: 2.25rem; }
h2 { font-size: 1.5rem; }
a { color: var(--primary-color); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* --- Header & Navigation --- */
.site-header { background: var(--header-bg); color: white; box-shadow: var(--shadow-md); padding: 1rem 0; width: 100%; }
.header-top { display: flex; justify-content: space-between; align-items: center; max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; }
.logo { font-weight: 700; font-size: 1.5rem; color: white; text-decoration: none; }
.main-nav { display: flex; align-items: center; gap: 0.5rem; }
.main-nav a { text-decoration: none; color: #cbd5e1; padding: 0.5rem 1rem; border-radius: var(--radius-lg); transition: all 0.2s; font-weight: 500; font-size: 0.875rem; }
.main-nav a:hover { color: white; background-color: #334155; }
.main-nav a.active { color: white; background-color: var(--primary-color); }

/* --- Buttons --- */
.button-primary, .button-danger, .button-secondary { padding: 0.75rem 1.25rem; border-radius: var(--radius-lg); font-weight: 600; font-size: 0.875rem; cursor: pointer; border: none; transition: all 0.2s; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
.button-primary { background-color: var(--primary-color); color: white; box-shadow: var(--shadow-md); }
.button-primary:hover:not(:disabled) { background-color: var(--primary-hover); transform: translateY(-2px); }
.button-primary:disabled { background-color: #a5b4fc; cursor: not-allowed; }
.button-danger { background-color: var(--error-color); color: white; }
.button-danger:hover { background-color: #b91c1c; }
.button-secondary { background-color: #e2e8f0; color: var(--text-primary); }
.button-secondary:hover { background-color: #cbd5e1; }

/* --- Forms & Auth Pages --- */
.auth-form-container { max-width: 450px; margin: 3rem auto; padding: 2.5rem; border-radius: var(--radius-lg); background-color: white; box-shadow: var(--shadow-lg); }
.form-group { margin-bottom: 1.5rem; }
label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.875rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"] { width: 100%; padding: 0.75rem 1rem; border: 1px solid var(--border-color); border-radius: var(--radius-lg); font-size: 1rem; box-sizing: border-box; }
input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px #c7d2fe; }
.auth-form-container button[type="submit"] { width: 100%; margin-top: 1rem; }
.auth-switch-link { text-align: center; margin-top: 1.5rem; font-size: 0.875rem; color: var(--text-secondary); }
.form-message { margin-top: 1rem; padding: 0.75rem 1rem; border-radius: var(--radius-lg); font-weight: 500; font-size: 0.875rem; text-align: center; display: none; }
.form-message.visible { display: block; }
.form-message.success { color: #14532d; background-color: #dcfce7; }
.form-message.error { color: #991b1b; background-color: #fee2e2; }

/* --- Dashboard & Prompts --- */
.card { background-color: white; padding: 1.5rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); margin-bottom: 1.5rem; }
.status-active { color: #15803d; background-color: #dcfce7; padding: 0.25rem 0.75rem; border-radius: 9999px; font-weight: 500; font-size: 0.75rem; }
.setup-prompt { background-color: white; padding: 2.5rem; border-radius: var(--radius-lg); margin-top: 2rem; text-align: center; }

/* --- Messages Page UI Redesign --- */
.chat-list-full-page { background-color: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden; display: flex; flex-direction: column; }
.chat-list-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.chat-list-header h2 { margin: 0; font-size: 1.25rem; }
#newMessageBtn { font-size: 1.75rem; font-weight: 300; border: none; background: transparent; cursor: pointer; width: 36px; height: 36px; border-radius: 50%; color: var(--text-secondary); transition: all 0.2s; }
#newMessageBtn:hover { background-color: #f1f5f9; color: var(--text-primary); transform: rotate(90deg); }
#chat-list-loading, .no-chats { padding: 1.5rem; color: var(--text-secondary); text-align: center; }
#chat-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; }
.chat-list-item { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.5rem; cursor: pointer; border-bottom: 1px solid var(--border-color); transition: background-color 0.2s; }
.chat-list-item:hover { background-color: var(--background-color); }
.chat-list-item:last-child { border-bottom: none; }
.chat-info { flex-grow: 1; overflow: hidden; }
.chat-info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.chat-info p { margin: 0.25rem 0 0; font-size: 0.875rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Chat History Modal --- */
.chat-history-modal { width: 90%; max-width: 800px; height: 85vh; padding: 0; display: flex; flex-direction: column; }
#chat-header { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
#chat-header h3 { margin: 0; flex-grow: 1; }
#closeChatHistoryBtn { font-size: 1.75rem; border: none; background: transparent; cursor: pointer; color: var(--text-secondary); padding: 0 0.5rem; line-height: 1; }
#message-display-wrapper { flex-grow: 1; overflow-y: auto; padding: 1.5rem; background-color: var(--background-color); }
#message-display { display: flex; flex-direction: column; gap: 1rem; }
.message-bubble { display: flex; gap: 0.75rem; max-width: 75%; align-items: flex-end; }
.message-bubble.sent { align-self: flex-end; }
.message-bubble.received { align-self: flex-start; }
.message-content { padding: 0.75rem 1rem; border-radius: var(--radius-lg); line-height: 1.5; word-wrap: break-word; box-shadow: var(--shadow-md); }
.message-content strong { display: block; font-size: 0.75rem; margin-bottom: 0.25rem; font-weight: 600; }
.message-content p { margin: 0; }
.received .message-content { background-color: white; border-bottom-left-radius: 0.25rem; }
.sent .message-content { background-color: var(--primary-color); color: white; border-bottom-right-radius: 0.25rem; }
.avatar { flex-shrink: 0; width: 40px; height: 40px; border-radius: 9999px; color: white; font-weight: 600; display: flex; align-items: center; justify-content: center; text-transform: uppercase; font-size: 0.875rem; }
#sendMessageForm { display: flex; padding: 1rem 1.5rem; border-top: 1px solid var(--border-color); gap: 1rem; align-items: center; flex-shrink: 0; background-color: white; }
#sendMessageForm input { flex-grow: 1; background-color: var(--background-color); }
#sendBtn { padding: 0; width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; background-color: var(--primary-color); color: white; }
#sendBtn:hover { background-color: var(--primary-hover); }
#sendBtn svg { width: 24px; height: 24px; }
#sendMessageError { text-align: left; margin: -0.5rem 1.5rem 0.5rem; }

/* --- General Modal Styles --- */
.modal-backdrop { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; }
.modal-content { background: white; padding: 2rem; border-radius: var(--radius-lg); max-width: 500px; width: 100%; box-shadow: var(--shadow-lg); }
.modal-content h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.5rem; }

/* --- Responsive Design --- */
@media (max-width: 768px) {
    .header-top { flex-direction: column; gap: 1rem; }
    .main-nav { flex-wrap: wrap; justify-content: center; }
    .auth-form-container { padding: 1.5rem; margin: 1.5rem auto; }
    .chat-history-modal { width: 100%; height: 100%; border-radius: 0; }
}
