/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-hover: #f0f1f3;
    --border: #e5e7eb;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --danger: #ef4444;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
    --transition: all 0.2s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Public Chat ─────────────────────────────────── */
.public-chat {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

.public-header {
    text-align: center;
    padding: 40px 0 20px;
}

.public-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.public-header p {
    color: var(--text-secondary);
    margin-top: 8px;
    font-size: 15px;
}

.public-logo {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.public-logo svg {
    width: 28px;
    height: 28px;
    color: white;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.message.bot .message-avatar {
    background: var(--primary);
    color: white;
}

.message.user .message-avatar {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.message-content {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.6;
}

.message.bot .message-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.message.user .message-content {
    background: var(--primary);
    color: white;
}

.message-content p { margin-bottom: 8px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content code {
    background: rgba(0,0,0,0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}
.message-content pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}
.message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.chat-input-area {
    padding: 20px 0 30px;
    position: relative;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 6px 6px 6px 16px;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.chat-input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    background: transparent;
    color: var(--text);
    padding: 10px 0;
}

.chat-input-wrapper input::placeholder {
    color: var(--text-secondary);
}

.btn-send {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-send:hover { background: var(--primary-dark); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing 1.4s infinite;
}

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

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

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

/* ── Admin Layout ────────────────────────────────── */
.admin-layout {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 24px 20px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand .brand-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
}

.sidebar-section {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 20px 8px 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

.sidebar-link:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.sidebar-link.active {
    background: var(--primary-light);
    color: var(--primary);
}

.sidebar-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-footer .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.sidebar-footer .user-info {
    flex: 1;
}

.sidebar-footer .user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.sidebar-footer .user-role {
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-footer .logout-btn {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition);
}

.sidebar-footer .logout-btn:hover {
    background: var(--bg-hover);
    color: var(--danger);
}

/* ── Main Content ────────────────────────────────── */
.main-content {
    flex: 1;
    background: var(--bg-secondary);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.page-header {
    padding: 24px 32px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.page-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.page-body {
    padding: 24px 32px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ── Admin Chat ──────────────────────────────────── */
.admin-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.admin-chat .chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.admin-chat .chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

/* ── Cards & Forms ───────────────────────────────── */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: var(--transition);
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: 1.5px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

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

.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

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

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

/* ── Table ───────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

table tr:hover td { background: var(--bg-secondary); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: var(--primary-light);
    color: var(--primary);
}

/* ── Upload Area ─────────────────────────────────── */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-area svg {
    width: 40px;
    height: 40px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.upload-area p {
    color: var(--text-secondary);
    font-size: 14px;
}

.upload-area .upload-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Login ───────────────────────────────────────── */
.login-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
}

.login-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-card .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-card .form-group { text-align: left; }

.login-card .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
}

.error-msg {
    background: #fef2f2;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ── Stats ───────────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Toast ───────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideUp 0.3s ease;
    color: white;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }

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

/* ── Image Upload Box ────────────────────────────── */
.img-upload-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.img-upload-box:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .message { max-width: 95%; }
    .page-body { padding: 16px; }
}

/* ── Empty State ─────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text);
}

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.2s ease;
}

.modal h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ── Powered by ──────────────────────────────────── */
.powered-by {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 8px 0;
}
