/* Flowstream — tokens e componentes base (ver .claude/skills/flowstream-design-system) */

:root {
    --bg: #ffffff;
    --bg-subtle: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --radius-sm: 8px;
    --radius-md: 12px;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-elevated: 0 8px 24px rgba(0, 0, 0, 0.12);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1220;
        --bg-subtle: #111827;
        --border: #1f2937;
        --text: #f1f5f9;
        --text-muted: #94a3b8;
        --accent: #6366f1;
        --accent-hover: #818cf8;
        --success: #22c55e;
        --success-bg: #052e16;
        --warning: #f59e0b;
        --warning-bg: #451a03;
        --danger: #ef4444;
        --danger-bg: #450a0a;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg-subtle);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

h1, h2, h3 {
    line-height: 1.2;
    margin: 0 0 8px;
}

p {
    margin: 0 0 8px;
}

.text-muted {
    color: var(--text-muted);
}

/* Shell da aplicação */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
}

.sidebar-brand {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 32px;
    padding: 0 8px;
}

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav a {
    display: block;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 500;
}

.sidebar-nav a:hover {
    background: var(--bg-subtle);
}

.sidebar-nav a.active {
    background: var(--accent);
    color: #fff;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 64px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.content {
    flex: 1;
    padding: 32px;
}

/* Cards e métricas */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

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

.metric-card .metric-value {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 4px;
}

.metric-card .metric-label {
    color: var(--text-muted);
    font-size: 13px;
}

/* Badges de status */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }

/* Botões */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-weight: 500;
    cursor: pointer;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

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

/* Alerta */
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--warning-bg);
    color: var(--warning);
    margin-bottom: 24px;
    font-weight: 500;
}

/* Conversas — bolhas de mensagem */
.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 4px;
}

.msg {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
}

.msg-cliente {
    align-self: flex-start;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    color: var(--text);
}

.msg-ia, .msg-humano, .msg-sistema {
    align-self: flex-end;
    color: #fff;
}

.msg-ia { background: var(--accent); }
.msg-humano { background: var(--success); }
.msg-sistema { background: var(--text-muted); }

.msg-meta {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 4px;
}

.msg-error {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

.msg-ia .msg-meta, .msg-humano .msg-meta, .msg-sistema .msg-meta {
    color: rgba(255, 255, 255, 0.85);
}

/* Estado vazio */
.empty-state {
    padding: 48px 24px;
}

.empty-state-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

/* Telas de visitante (login, cadastro, recuperação de senha) */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 32px;
}

.auth-brand {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    text-align: center;
}

.auth-card h1 {
    font-size: 20px;
    margin-bottom: 4px;
}

.auth-card .subtitle {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.auth-links {
    margin-top: 16px;
    text-align: center;
    font-size: 13px;
}

/* Formulários */
.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
}

.field input,
.field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

.field .field-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

.field-hint {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

.btn-block {
    width: 100%;
    text-align: center;
}

.alert-success { background: var(--success-bg); color: var(--success); }
.alert-error { background: var(--danger-bg); color: var(--danger); }

.dev-hint {
    margin-top: 16px;
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
}

/* Tabela de listagem */
.table-scroll {
    overflow-x: auto;
}

.table {
    width: 100%;
    min-width: 480px;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Responsivo */
@media (max-width: 768px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 12px 16px;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .content {
        padding: 16px;
    }

    .topbar {
        height: auto;
        min-height: 56px;
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .auth-card {
        padding: 24px;
    }

    .msg {
        max-width: 88%;
    }
}
