/* ============================================================
   AI Chat Assistant — Stylesheet
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #ececf1;
    background: #343541;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ====== Auth pages ====== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 20px;
}
.auth-container {
    background: #fff;
    color: #1f2937;
    width: 100%;
    max-width: 420px;
    padding: 40px 36px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.auth-container h1 {
    text-align: center;
    margin-bottom: 6px;
    font-size: 24px;
    color: #111827;
}
.auth-subtitle { text-align: center; color: #6b7280; margin-bottom: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-footer { text-align: center; margin-top: 16px; color: #6b7280; font-size: 14px; }
.auth-footer a { color: #10a37f; font-weight: 500; text-decoration: none; }

/* ====== Form basics ====== */
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: #111827;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #10a37f;
    box-shadow: 0 0 0 3px rgba(16,163,127,0.15);
}
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }

/* ====== Buttons ====== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.btn-primary { background: #10a37f; color: #fff; }
.btn-primary:hover { background: #0d8a6a; }
.btn-secondary { background: #6b7280; color: #fff; }
.btn-secondary:hover { background: #4b5563; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon {
    background: transparent;
    border: 1px solid #565869;
    color: inherit;
    padding: 6px 10px;
    border-radius: 6px;
    margin-right: 4px;
}
.btn-icon:hover { background: rgba(255,255,255,0.05); }
.btn-icon.btn-danger { border-color: #dc2626; color: #fca5a5; }

/* ====== Alerts ====== */
.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* ====== Artifact Pane ====== */
.artifact-pane {
    width: 0;
    transition: width 0.3s ease;
    background: #ffffff;
    color: #111827;
    border-left: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    visibility: hidden;
}
.artifact-pane.open { width: 50vw; max-width: 800px; min-width: 300px; border-left: 1px solid rgba(0,0,0,0.1); visibility: visible; }
.artifact-header {
    padding: 12px 18px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
}
.artifact-header h3 { font-size: 15px; font-weight: 600; margin: 0; }
.artifact-header .btn-icon { color: #6b7280; border: none; }
.artifact-body { flex: 1; padding: 0; overflow: hidden; background: #fff; }
.artifact-body iframe { width: 100%; height: 100%; border: none; background: #fff; }


/* ====== Sidebar ====== */
.sidebar {
    width: 280px;
    background: #202123;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 14px;
    color: #ececf1;
}
.sidebar-header h2 i { color: #10a37f; margin-right: 6px; }

.new-chat-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.18);
    color: #ececf1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    transition: background .15s;
}
.new-chat-btn:hover { background: rgba(255,255,255,0.06); }

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.conversation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 6px;
    cursor: pointer;
    color: #ececf1;
    font-size: 14px;
    position: relative;
}
.conversation-item:hover { background: rgba(255,255,255,0.06); }
.conversation-item.active { background: #343541; }
.conversation-item i { color: #8e8ea0; flex-shrink: 0; }
.conv-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conversation-item .del-btn {
    background: transparent;
    border: none;
    color: #8e8ea0;
    opacity: 0;
    transition: opacity .15s;
    padding: 4px;
}
.conversation-item:hover .del-btn { opacity: 1; }
.conversation-item .del-btn:hover { color: #ef4444; }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    color: #ececf1;
    font-size: 14px;
}
.user-info i { font-size: 24px; color: #10a37f; }
.footer-actions { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.footer-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 6px;
    color: #c5c5d2; text-decoration: none; font-size: 13px;
}
.footer-link:hover { background: rgba(255,255,255,0.06); }

/* ====== Main chat area ====== */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #343541;
    overflow: hidden;
}
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: #343541;
}
.hamburger {
    background: transparent; border: none; color: #ececf1;
    font-size: 18px; padding: 6px 10px; display: none;
}
.model-selector { flex: 1; max-width: 360px; }
.model-selector select {
    width: 100%;
    padding: 8px 10px;
    background: #40414f;
    color: #ececf1;
    border: 1px solid #565869;
    border-radius: 6px;
    font-size: 14px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
}
.welcome-screen {
    text-align: center;
    padding: 80px 20px;
    color: #c5c5d2;
}
.welcome-screen h1 { font-size: 64px; color: #10a37f; margin-bottom: 16px; }
.welcome-screen h2 { font-size: 26px; font-weight: 600; margin-bottom: 6px; color: #ececf1; }
.welcome-screen p  { font-size: 14px; }

/* Messages */
.message {
    max-width: 820px;
    margin: 0 auto 16px;
    display: flex;
    gap: 14px;
    padding: 16px;
    border-radius: 10px;
}
.user-message       { background: #444654; }
.assistant-message  { background: transparent; border: 1px solid rgba(255,255,255,0.06); }
.message.error      { background: #401717; border-color: #7f1d1d; }
.message-avatar {
    width: 30px; height: 30px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}
.user-message .message-avatar      { background: #5b3aff; color: #fff; }
.assistant-message .message-avatar { background: #10a37f; color: #fff; }
.message-body { flex: 1; min-width: 0; }
.message-author { font-weight: 600; font-size: 13px; margin-bottom: 4px; color: #c5c5d2; }
.message-content { font-size: 15px; line-height: 1.65; word-wrap: break-word; color: #ececf1; }

/* Rich Code Blocks */
.code-container { margin: 12px 0; border-radius: 8px; overflow: hidden; background: #1e1e2e; }
.code-header {
    display: flex; justify-content: space-between; align-items: center;
    background: #2d2d3b; padding: 8px 12px;
}
.code-lang { font-size: 12px; font-weight: 600; color: #a1a1aa; text-transform: uppercase; }
.code-actions button {
    background: transparent; border: 1px solid #4b4b5c; color: #ececf1;
    font-size: 12px; padding: 4px 8px; border-radius: 4px; margin-left: 6px; transition: 0.15s;
}
.code-actions button:hover { background: #4b4b5c; color: #fff; }
.message-content pre {
    background: transparent;
    color: #f8f8f2;
    padding: 14px;
    overflow-x: auto;
    font-size: 13px;
    margin: 0;
}

.message-content code {
    background: rgba(255,255,255,0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}
.message-content pre code { background: transparent; padding: 0; }

/* Loader dots */
.dots { display: inline-flex; gap: 4px; padding: 6px 0; }
.dots span {
    width: 8px; height: 8px; border-radius: 50%;
    background: #10a37f;
    animation: bounce 1.4s infinite ease-in-out both;
}
.dots span:nth-child(1) { animation-delay: -0.32s; }
.dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
    0%,80%,100% { transform: scale(0); opacity: .3; }
    40%         { transform: scale(1); opacity: 1; }
}

/* ====== Input ====== */
.chat-input-area {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: #343541;
}
.attachment-preview {
    max-width: 820px;
    margin: 0 auto 10px;
    display: flex; gap: 8px; flex-wrap: wrap;
}
.preview-item {
    position: relative; background: #444654; border-radius: 8px; padding: 6px;
    border: 1px solid #565869; display: flex; align-items: center; gap: 8px;
}
.preview-item img { height: 48px; border-radius: 4px; object-fit: contain; }
.preview-item .doc-icon { font-size: 24px; color: #10a37f; width: 48px; text-align: center; }
.preview-item .remove-btn {
    position: absolute; top: -6px; right: -6px;
    background: #dc2626; color: #fff; border: none; border-radius: 50%;
    width: 20px; height: 20px; font-size: 10px; cursor: pointer;
    display: flex; justify-content: center; align-items: center;
}
.input-container {
    position: relative;
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    background: #40414f;
    border: 1px solid #565869;
    border-radius: 12px;
}
.input-container:focus-within {
    border-color: #10a37f;
    box-shadow: 0 0 0 3px rgba(16,163,127,0.15);
}
.attach-btn {
    background: transparent; border: none; color: #8e8ea0;
    padding: 14px 16px; font-size: 18px; cursor: pointer;
}
.attach-btn:hover { color: #ececf1; }
.input-container textarea {
    flex: 1;
    padding: 14px 44px 14px 0;
    background: transparent;
    color: #ececf1;
    border: none;
    resize: none;
    font-size: 15px;
    line-height: 1.5;
    min-height: 52px;
    max-height: 200px;
}
.input-container textarea:focus {
    outline: none;
}
.send-btn {
    position: absolute;
    right: 8px; bottom: 8px;
    width: 36px; height: 36px;
    background: #10a37f;
    border: none;
    border-radius: 8px;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
}
.send-btn:hover { background: #0d8a6a; }
.send-btn:disabled { background: #565869; cursor: not-allowed; }
.input-footer { text-align: center; margin-top: 8px; color: #8e8ea0; font-size: 12px; }

/* ====== Modal ====== */
.modal {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    align-items: center; justify-content: center;
    z-index: 1000;
}
.modal.open { display: flex; }
.modal-content {
    background: #fff;
    color: #1f2937;
    border-radius: 12px;
    width: 90%; max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid #e5e7eb;
}
.modal-body  { padding: 20px; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid #e5e7eb;
    display: flex; justify-content: flex-end; gap: 10px;
}
.close-btn {
    background: transparent; border: none;
    font-size: 26px; line-height: 1;
    color: #6b7280;
}

/* ====== Toast ====== */
.toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translateX(-50%);
    background: #10a37f; color: #fff;
    padding: 10px 18px; border-radius: 8px;
    font-size: 14px; z-index: 2000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* ============================================================
   ADMIN
   ============================================================ */
.admin-body { background: #f3f4f6; color: #111827; }
.admin-header {
    background: #fff;
    padding: 16px 24px;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.admin-header h1 { font-size: 20px; }
.admin-header h1 i { color: #10a37f; margin-right: 8px; }
.admin-layout { display: flex; min-height: calc(100vh - 60px); }
.admin-sidebar {
    width: 240px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
}
.admin-menu { list-style: none; padding: 16px 0; }
.admin-menu li { margin-bottom: 2px; }
.admin-menu a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px;
    color: #4b5563;
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.admin-menu a:hover { background: #f9fafb; }
.admin-menu a.active {
    background: #ecfdf5;
    color: #047857;
    border-left-color: #10a37f;
    font-weight: 500;
}
.admin-main { flex: 1; padding: 28px; overflow-y: auto; }
.admin-section h2 { margin-bottom: 20px; font-size: 22px; }
.admin-card {
    background: #fff; border-radius: 10px; padding: 22px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 22px;
}
.admin-card h3 { font-size: 16px; margin-bottom: 16px; color: #111827; }
.admin-form { display: flex; flex-direction: column; gap: 14px; }

.table-container { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
    padding: 12px 14px; text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
}
.admin-table th {
    background: #f9fafb; font-weight: 600;
    color: #4b5563; font-size: 12px; text-transform: uppercase;
}
.admin-table tr:hover { background: #f9fafb; }
.admin-table code {
    background: #f3f4f6; padding: 2px 6px; border-radius: 4px;
    font-size: 12px;
}
.admin-table select {
    padding: 4px 8px; border: 1px solid #d1d5db;
    border-radius: 6px; font-size: 13px;
}
.admin-table .btn-icon {
    border: 1px solid #d1d5db;
    color: #4b5563; background: #fff;
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px; font-weight: 500;
}
.status-badge.active   { background: #d1fae5; color: #065f46; }
.status-badge.inactive { background: #fee2e2; color: #991b1b; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat-card {
    background: #fff; border-radius: 10px; padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex; align-items: center; gap: 16px;
}
.stat-icon {
    width: 52px; height: 52px;
    background: linear-gradient(135deg, #10a37f, #0d8a6a);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 22px;
}
.stat-info h3 { font-size: 12px; color: #6b7280; margin-bottom: 4px; text-transform: uppercase; }
.stat-number  { font-size: 26px; font-weight: 700; color: #111827; }

/* ====== Mobile ====== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform .25s;
    }
    .sidebar.open { transform: translateX(0); }
    .hamburger { display: inline-block; }
    .form-row { flex-direction: column; }
    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; }
    .admin-menu { display: flex; overflow-x: auto; padding: 0; }
    .admin-menu li { white-space: nowrap; }
}
