/* ChatStir.AI Dashboard */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --success: #22c55e;
    --error: #ef4444;
    --sidebar-bg: #1e293b;
    --sidebar-text: #e2e8f0;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Login */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

.login-card {
    background: white;
    padding: 48px 40px;
    border-radius: 16px;
    width: 400px;
    max-width: 90vw;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-card h1 {
    font-size: 32px;
    margin-bottom: 4px;
}

.brand-dot { color: var(--primary); }

.subtitle {
    color: var(--text-light);
    margin-bottom: 32px;
}

.login-card input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 12px;
    outline: none;
}

.login-card input:focus { border-color: var(--primary); }

.error { color: var(--error); font-size: 13px; margin-top: 8px; }

.google-btn {
    width: 100%;
    padding: 11px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.15s;
    margin-bottom: 0;
}

.google-btn:hover {
    background: #f8fafc;
    border-color: var(--border-hover);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.auth-switch {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 16px;
    text-align: center;
}

.auth-switch a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.auth-switch a:hover { text-decoration: underline; }

/* Onboarding */
.onboarding-card {
    background: white;
    padding: 48px 40px;
    border-radius: 16px;
    width: 520px;
    max-width: 90vw;
    margin: 0 auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

#onboarding-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

.onboarding-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 32px;
}

.onboarding-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
}

.onboarding-step.active { color: var(--primary); }
.onboarding-step.done { color: var(--success); }

.step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.onboarding-step.active .step-num {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.onboarding-step.done .step-num {
    border-color: var(--success);
    background: var(--success);
    color: white;
}

.onboarding-step-line {
    width: 40px;
    height: 2px;
    background: var(--border);
    margin: 0 12px;
}

.ob-step-content h2 {
    font-size: 22px;
    margin-bottom: 8px;
    text-align: center;
}

.ob-desc {
    font-size: 14px;
    color: var(--text-light);
    text-align: center;
    margin-bottom: 24px;
}

.login-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--text-light);
    font-size: 12px;
}

.login-divider::before, .login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.login-divider span { padding: 0 12px; }

#google-signin-container {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}
.success-msg { color: var(--success); font-size: 13px; margin-top: 8px; }

/* Layout */
#dashboard-screen { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    flex-shrink: 0;
}

.logo {
    font-size: 22px;
    font-weight: 700;
    padding: 0 24px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav-links {
    list-style: none;
    margin-top: 16px;
    flex: 1;
}

.nav-links a {
    display: block;
    padding: 10px 24px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s;
}

.nav-links a:hover, .nav-links a.active {
    background: rgba(255,255,255,0.1);
}

.nav-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* Page */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.page-header h2 { font-size: 24px; }

/* Buttons */
.btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.15s;
}

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

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

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

.btn-small { padding: 4px 10px; font-size: 12px; }

.btn-back {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 15px;
    color: var(--primary);
}

.btn-group { display: flex; gap: 8px; }

/* Cards */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.site-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.site-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

.site-card h3 { margin-bottom: 4px; }
.site-card .domain { color: var(--text-light); font-size: 13px; margin-bottom: 12px; }
.site-card .stats { display: flex; gap: 16px; font-size: 13px; color: var(--text-light); }
.site-card .stats strong { color: var(--text); }

.site-card .status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: inherit;
}

.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Forms */
.form-grid {
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
}

.form-grid input, .form-grid textarea, .form-grid select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    color: var(--text);
}

.form-grid input:focus, .form-grid textarea:focus, .form-grid select:focus {
    border-color: var(--primary);
}

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
}

.checkbox-label input { width: auto; }

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.data-table th {
    background: var(--bg);
    padding: 10px 16px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-light);
    font-weight: 600;
}

.data-table td {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.data-table tr:hover td { background: #f8fafc; }

/* Code block */
.code-block {
    background: var(--sidebar-bg);
    color: #e2e8f0;
    padding: 16px 20px;
    border-radius: var(--radius);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    overflow-x: auto;
    margin: 12px 0;
}

.code-block code { flex: 1; word-break: break-all; }
.code-block .btn { flex-shrink: 0; }

.hint { color: var(--text-light); font-size: 13px; }

/* Knowledge Base */
.kb-actions { display: flex; gap: 8px; margin-bottom: 16px; }

.kb-entries { display: flex; flex-direction: column; gap: 8px; }

.kb-entry {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
}

.kb-entry .kb-cat {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 4px;
}

.kb-entry .kb-q { font-weight: 600; margin-bottom: 4px; }
.kb-entry .kb-a { color: var(--text-light); font-size: 13px; }

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

.modal {
    background: white;
    padding: 32px;
    border-radius: 16px;
    width: 480px;
    max-width: 90vw;
}

.modal h3 { margin-bottom: 20px; }

.modal label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 12px;
}

.modal input, .modal textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    width: 100%;
}

/* Transcript */
.transcript-msg {
    padding: 8px 14px;
    margin-bottom: 8px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    max-width: 85%;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.transcript-user {
    background: var(--primary);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.transcript-bot {
    background: var(--bg);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.transcript-time {
    font-size: 10px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.lead-row-clickable { cursor: pointer; }
.lead-row-clickable:hover td { background: #eef2ff !important; }

/* Support Notice */
.support-notice {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 12px;
    color: #1e40af;
    line-height: 1.6;
}

/* Detect Colors */
.detect-colors-box {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.04), rgba(79, 70, 229, 0.08));
    border: 1px solid rgba(79, 70, 229, 0.15);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.detect-colors-info h4 { font-size: 15px; margin-bottom: 4px; }
.detect-colors-info p { font-size: 13px; color: var(--text-light); margin-bottom: 12px; }

.detect-colors-actions { display: flex; align-items: center; gap: 12px; }

.detected-palette {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.palette-swatch {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 12px;
}

.palette-swatch:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.palette-swatch .swatch-dot {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

.palette-swatch .swatch-hex { font-weight: 600; font-family: 'SF Mono', monospace; }
.palette-swatch .swatch-src { color: var(--text-light); }

/* Profile */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 768px) {
    .profile-grid { grid-template-columns: 1fr; }
}

.nav-profile-link {
    color: var(--sidebar-text) !important;
    text-decoration: none;
    cursor: pointer;
    font-size: 13px;
}

.nav-profile-link:hover { text-decoration: underline; }

/* Score Badges */
.score-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: default;
}

.score-hot { background: #fef2f2; color: #dc2626; }
.score-warm { background: #fffbeb; color: #d97706; }
.score-cold { background: #eff6ff; color: #2563eb; }
.score-none { color: var(--text-light); }

/* Analytics */
.analytics-controls {
    display: flex;
    gap: 8px;
}

.analytics-controls select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

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

.stat-highlight {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(79,70,229,0.04), rgba(79,70,229,0.08));
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.stat-highlight .stat-value { color: var(--primary); }

.stat-label {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
    font-weight: 500;
}

.charts-row {
    margin-bottom: 24px;
}

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

.chart-card h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
}

.chart-card canvas {
    width: 100% !important;
    max-height: 280px;
}

.analytics-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.question-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.question-row:last-child { border-bottom: none; }

.question-text {
    flex: 1;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 12px;
}

.question-count {
    flex-shrink: 0;
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
}

.perf-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.perf-row:last-child { border-bottom: none; }

.perf-name { font-weight: 600; }
.perf-stats { display: flex; gap: 16px; color: var(--text-light); font-size: 12px; }
.perf-stats strong { color: var(--text); }

.no-data {
    text-align: center;
    padding: 32px;
    color: var(--text-light);
    font-size: 13px;
}

@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .analytics-bottom { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* Responsive */
@media (max-width: 768px) {
    #dashboard-screen { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; padding: 12px; align-items: center; }
    .nav-links { display: flex; margin: 0; }
    .nav-links a { padding: 8px 12px; }
    .nav-footer { display: none; }
    .content { padding: 16px; }
}
