/* =============================================================================
   Vocal · Bot Studio — bots.vocal.ch
   Design tokens alignés avec my.vocal.ch + spécifiques studio (sidebar 2-modes,
   simulator chat, code editor, timeline, KPI cards, marketplace cards…).
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. Variables & Theme
   ----------------------------------------------------------------------------- */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-soft: #eef2ff;
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    --bg-page: #f4f5fb;
    --bg-white: #ffffff;
    --bg-soft: #f8fafc;
    --bg-dark: #0f172a;

    --text-main: #1e1b4b;
    --text-muted: #64748b;
    --text-soft: #94a3b8;
    --text-on-dark: #e2e8f0;

    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --success: #16a34a;
    --warning: #ea580c;
    --danger: #dc2626;
    --info: #0ea5e9;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
    --shadow-hover: 0 10px 30px -8px rgba(99, 102, 241, 0.25);
    --shadow-glow: 0 4px 14px rgba(99, 102, 241, 0.45);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-2xl: 1.5rem;

    --sidebar-width: 280px;
    --header-height: 68px;
}

/* -----------------------------------------------------------------------------
   2. Base
   ----------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    margin: 0;
    font-family: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    background: var(--bg-page);
    line-height: 1.5;
    letter-spacing: -0.01em;
}

button, input, select, textarea { font-family: inherit; }

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.app-loading {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--bg-page);
}
.loading-spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

/* -----------------------------------------------------------------------------
   3. Layout
   ----------------------------------------------------------------------------- */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; left: 0; top: 0; z-index: 100;
    width: var(--sidebar-width); height: 100vh;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden;
    transition: transform 0.25s ease;
}

.main-content {
    flex: 1; margin-left: var(--sidebar-width); min-height: 100vh;
    display: flex; flex-direction: column;
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
}

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 99;
}
@media (max-width: 1024px) {
    .sidebar.open ~ .sidebar-overlay,
    body.sidebar-open .sidebar-overlay { display: block; }
}

/* -----------------------------------------------------------------------------
   4. Sidebar header & nav
   ----------------------------------------------------------------------------- */
.sidebar-header {
    flex-shrink: 0; height: var(--header-height);
    padding: 0 1.25rem;
    display: flex; align-items: center; gap: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.sidebar-header .logo { height: 26px; width: auto; display: block; }
.sidebar-header .studio-pill {
    margin-left: auto;
    font-size: 0.625rem; font-weight: 800; letter-spacing: 0.08em;
    background: linear-gradient(135deg, #ede9fe, #ddd6fe);
    color: var(--primary-dark);
    padding: 0.2rem 0.5rem; border-radius: 999px;
    text-transform: uppercase;
}

.sidebar-context {
    flex-shrink: 0;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #fdfdff 0%, #f5f3ff 100%);
}
.sidebar-context-back {
    display: inline-flex; align-items: center; gap: 0.35rem;
    font-size: 0.75rem; color: var(--text-muted); font-weight: 600;
    background: none; border: none; cursor: pointer; padding: 0;
    margin-bottom: 0.45rem;
}
.sidebar-context-back:hover { color: var(--primary-dark); }
.sidebar-context-name {
    font-weight: 800; font-size: 0.95rem; color: var(--text-main);
    display: flex; align-items: center; gap: 0.4rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-context-status {
    margin-top: 0.2rem;
    font-size: 0.7rem; color: var(--text-muted);
    display: flex; align-items: center; gap: 0.4rem;
}
.dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: var(--text-soft);
}
.dot.live { background: var(--success); box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); animation: pulse 2s infinite; }
.dot.draft { background: var(--warning); }
.dot.paused { background: var(--text-soft); }

.sidebar-nav {
    flex: 1; overflow-y: auto; padding: 0.85rem 0.75rem;
}

.nav-section { margin-bottom: 1.1rem; }
.nav-section:last-child { margin-bottom: 0; }
.nav-section-title {
    font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--text-muted);
    padding: 0 0.75rem 0.5rem;
}

.nav-item {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.6rem 0.85rem;
    margin-bottom: 0.2rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem; font-weight: 600;
    color: var(--text-main);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    cursor: pointer; border: none; background: transparent;
    width: 100%; text-align: left;
}
.nav-item:hover { background: var(--primary-soft); color: var(--primary-dark); }
.nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; box-shadow: var(--shadow-glow);
}
.nav-item .nav-icon { width: 1.05rem; height: 1.05rem; flex-shrink: 0; opacity: 0.85; }
.nav-item.active .nav-icon { opacity: 1; }

.nav-badge-soon {
    margin-left: auto;
    font-size: 0.55rem; font-weight: 800; letter-spacing: 0.06em;
    padding: 0.15rem 0.4rem; border-radius: 999px;
    background: rgba(99, 102, 241, 0.12); color: var(--primary-dark);
    text-transform: uppercase;
}
.nav-item.active .nav-badge-soon { background: rgba(255, 255, 255, 0.18); color: #fff; }

.sidebar-footer {
    flex-shrink: 0; padding: 0.9rem; border-top: 1px solid var(--border);
}
.user-info { display: flex; align-items: center; gap: 0.6rem; }
.user-avatar {
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 0.85rem; font-weight: 700;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}
.user-details { min-width: 0; flex: 1; }
.user-details .user-name {
    font-size: 0.8125rem; font-weight: 600;
    color: var(--text-main); overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.user-details .user-role { font-size: 0.7rem; color: var(--text-muted); }

/* -----------------------------------------------------------------------------
   5. Page header & content
   ----------------------------------------------------------------------------- */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 1rem;
    min-height: var(--header-height);
    padding: 1rem 2rem;
    background: var(--bg-white); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.page-header-left { display: flex; align-items: center; gap: 0.75rem; }
.menu-toggle {
    display: none;
    background: none; border: none; padding: 0.5rem; border-radius: var(--radius-md);
    cursor: pointer; color: var(--text-main);
}
@media (max-width: 1024px) { .menu-toggle { display: inline-flex; } }
.menu-toggle:hover { background: var(--bg-soft); }

.page-title {
    margin: 0; font-size: 1.5rem; font-weight: 800;
    letter-spacing: -0.025em; color: var(--text-main); line-height: 1.15;
}
.page-subtitle {
    margin: 0.25rem 0 0; font-size: 0.875rem;
    color: var(--text-muted); font-weight: 500;
}
.page-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.page-content { flex: 1; padding: 1.5rem 2rem; max-width: 1280px; width: 100%; margin: 0 auto; }

@media (max-width: 640px) {
    .page-header { padding: 0.85rem 1rem; }
    .page-content { padding: 1.25rem 1rem; }
    .page-title { font-size: 1.25rem; }
}

.breadcrumb {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.4rem;
}
.breadcrumb a { color: var(--text-muted); font-weight: 500; }
.breadcrumb a:hover { color: var(--primary-dark); }
.breadcrumb .sep { opacity: 0.5; }

/* -----------------------------------------------------------------------------
   6. Buttons
   ----------------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.6rem 1.15rem;
    font-size: 0.875rem; font-weight: 700; line-height: 1.25;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
    text-decoration: none; white-space: nowrap; letter-spacing: -0.005em;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { box-shadow: var(--shadow-glow); }

.btn-secondary {
    background: var(--bg-white); color: var(--text-main);
    border-color: var(--border); box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--primary-light); color: var(--primary-dark); }

.btn-ghost { background: transparent; color: var(--text-main); }
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary-dark); }

.btn-danger { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fee2e2; border-color: #f87171; }

.btn-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.btn-success:hover:not(:disabled) { background: #bbf7d0; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8125rem; }
.btn-icon { padding: 0.5rem; min-width: 2.25rem; min-height: 2.25rem; border-radius: 50%; }

/* -----------------------------------------------------------------------------
   7. Cards
   ----------------------------------------------------------------------------- */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-2xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); background: #fafbff;
}
.card-title { margin: 0; font-size: 1rem; font-weight: 700; color: var(--text-main); letter-spacing: -0.01em; }
.card-subtitle { margin: 0.15rem 0 0; font-size: 0.8125rem; color: var(--text-muted); font-weight: 500; }
.card-body { padding: 1.5rem; }
.card-flat {
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow-sm);
}
.card-grid { display: grid; gap: 1rem; }
.card-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1024px) {
    .card-grid.cols-3, .card-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .card-grid.cols-2, .card-grid.cols-3, .card-grid.cols-4 { grid-template-columns: 1fr; }
}

/* -----------------------------------------------------------------------------
   8. Stats / KPIs
   ----------------------------------------------------------------------------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.875rem; margin-bottom: 1.5rem;
}
.kpi {
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius-xl); padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 0.4rem;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.kpi-label {
    font-size: 0.7rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.06em;
}
.kpi-value {
    font-size: 1.65rem; font-weight: 800; color: var(--text-main);
    letter-spacing: -0.025em; line-height: 1;
}
.kpi-trend { font-size: 0.75rem; color: var(--text-muted); }
.kpi-trend.up { color: var(--success); font-weight: 700; }
.kpi-trend.down { color: var(--danger); font-weight: 700; }

/* -----------------------------------------------------------------------------
   9. Forms
   ----------------------------------------------------------------------------- */
.form-row {
    display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem;
}
.form-row label, .form-label {
    font-size: 0.8rem; font-weight: 700; color: var(--text-main);
}
.form-row .help, .form-help {
    font-size: 0.7rem; color: var(--text-muted); font-weight: 500;
}
.form-input,
.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="number"],
.form-row input[type="url"],
.form-row input[type="password"],
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    font-size: 0.875rem;
    background: var(--bg-white);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}
.form-row textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.form-input:focus,
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.form-input:disabled,
.form-row input:disabled,
.form-row select:disabled,
.form-row textarea:disabled {
    background: var(--bg-soft); color: var(--text-muted); cursor: not-allowed;
}

.form-row.row-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 640px) { .form-row.row-grid { grid-template-columns: 1fr; } }

.toggle-row {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.65rem 0.85rem;
    background: var(--bg-soft); border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.875rem; font-weight: 600; color: var(--text-main);
    cursor: pointer; user-select: none;
}
.toggle-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

.code-textarea {
    font-family: 'JetBrains Mono', ui-monospace, monospace !important;
    font-size: 0.8125rem !important;
    line-height: 1.55 !important;
    background: #0f172a !important;
    color: #e2e8f0 !important;
    border-color: #1e293b !important;
}

/* -----------------------------------------------------------------------------
   10. Badges
   ----------------------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.02em;
    border-radius: 999px; line-height: 1.2;
}
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #ffedd5; color: #9a3412; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-dark { background: #1e293b; color: #e2e8f0; }

/* -----------------------------------------------------------------------------
   11. Tables
   ----------------------------------------------------------------------------- */
.table-container {
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius-xl); overflow: hidden;
    box-shadow: var(--shadow-sm);
}
table.data-table {
    width: 100%; border-collapse: collapse;
}
.data-table th {
    text-align: left; font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 0.85rem 1rem;
    font-size: 0.875rem; color: var(--text-main);
    border-bottom: 1px solid var(--border);
}
.data-table tbody tr:hover { background: #fafbff; }
.data-table tbody tr:last-child td { border-bottom: 0; }

/* -----------------------------------------------------------------------------
   12. Bot grid (BotsListView)
   ----------------------------------------------------------------------------- */
.bot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1rem;
}
.bot-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-2xl);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 0.85rem;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.bot-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: rgba(99, 102, 241, 0.35);
}
.bot-card-header {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
}
.bot-avatar {
    width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
    color: #fff;
}
.bot-card-title {
    font-size: 1rem; font-weight: 700; color: var(--text-main);
    margin: 0 0 0.15rem; letter-spacing: -0.015em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bot-card-desc {
    font-size: 0.8rem; color: var(--text-muted); font-weight: 500;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; min-height: 2.4em;
}
.bot-card-meta {
    display: flex; gap: 0.6rem; flex-wrap: wrap; font-size: 0.7rem; color: var(--text-muted);
    border-top: 1px dashed var(--border); padding-top: 0.7rem;
}
.bot-card-meta span { display: inline-flex; align-items: center; gap: 0.3rem; }

.bot-create-card {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    border: 2px dashed var(--primary-light);
    border-radius: var(--radius-2xl);
    padding: 2rem 1.25rem;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.6rem;
    cursor: pointer; transition: background 0.18s ease, transform 0.18s ease;
    min-height: 200px;
}
.bot-create-card:hover {
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
    transform: translateY(-3px);
}
.bot-create-icon {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--bg-white); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-md);
}
.bot-create-text { font-weight: 700; color: var(--primary-dark); }

/* -----------------------------------------------------------------------------
   13. Empty state
   ----------------------------------------------------------------------------- */
.empty-state {
    text-align: center; padding: 3rem 1.5rem;
    background: var(--bg-white); border: 1px dashed var(--border);
    border-radius: var(--radius-2xl);
}
.empty-state-icon {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 1rem;
}
.empty-state-title { font-size: 1.125rem; font-weight: 700; margin: 0 0 0.4rem; color: var(--text-main); }
.empty-state-desc { font-size: 0.875rem; color: var(--text-muted); max-width: 480px; margin: 0 auto 1rem; }

/* -----------------------------------------------------------------------------
   14. Simulator (chat live)
   ----------------------------------------------------------------------------- */
.simulator {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.25rem;
    min-height: calc(100vh - 200px);
}
@media (max-width: 1100px) { .simulator { grid-template-columns: 1fr; } }

.chat-shell {
    display: flex; flex-direction: column;
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius-2xl); overflow: hidden;
    box-shadow: var(--shadow-sm);
    min-height: 540px;
}
.chat-header {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
}
.chat-header-info { display: flex; align-items: center; gap: 0.7rem; }
.chat-header-title { font-weight: 700; font-size: 0.9rem; color: var(--text-main); }
.chat-header-sub { font-size: 0.7rem; color: var(--text-muted); }

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.25rem;
    display: flex; flex-direction: column; gap: 0.75rem;
    background: linear-gradient(180deg, #fdfdff 0%, #f8fafc 100%);
}

.bubble {
    max-width: 80%;
    padding: 0.7rem 0.95rem;
    border-radius: 18px;
    font-size: 0.875rem; line-height: 1.5;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    animation: fadeIn 0.2s ease-out;
    white-space: pre-wrap; word-break: break-word;
}
.bubble.user {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; align-self: flex-end;
    border-bottom-right-radius: 6px;
}
.bubble.bot {
    background: var(--bg-white); color: var(--text-main);
    align-self: flex-start;
    border: 1px solid var(--border);
    border-bottom-left-radius: 6px;
}
.bubble.system {
    background: #fef9c3; color: #713f12;
    align-self: center; font-size: 0.75rem; font-style: italic;
}
.bubble-meta {
    font-size: 0.65rem; opacity: 0.7; margin-top: 0.35rem;
}

.chat-typing {
    display: inline-flex; gap: 4px; align-items: center;
    padding: 0.55rem 0.85rem;
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: 18px;
}
.chat-typing span {
    width: 6px; height: 6px; border-radius: 50%; background: var(--text-soft);
    animation: pulse 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

.chat-composer {
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-white);
    display: flex; align-items: flex-end; gap: 0.6rem;
}
.chat-composer textarea {
    flex: 1; resize: none; max-height: 140px;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border); border-radius: var(--radius-md);
    font-size: 0.875rem; line-height: 1.4;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.chat-composer textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.chat-composer .btn-icon {
    width: 38px; height: 38px; min-width: 38px;
}

.simulator-side {
    display: flex; flex-direction: column; gap: 1rem;
}

/* -----------------------------------------------------------------------------
   15. Versions / timeline
   ----------------------------------------------------------------------------- */
.version-row {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s ease;
}
.version-row:hover { background: var(--bg-soft); }
.version-dot {
    width: 28px; height: 28px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 0.7rem; font-weight: 700;
    background: var(--primary-soft); color: var(--primary-dark);
}
.version-row.current .version-dot {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: var(--shadow-glow);
}
.version-info { flex: 1; min-width: 0; }
.version-title { font-weight: 700; font-size: 0.875rem; color: var(--text-main); }
.version-meta { font-size: 0.72rem; color: var(--text-muted); }
.version-actions { display: flex; gap: 0.4rem; }

/* -----------------------------------------------------------------------------
   16. A/B testing
   ----------------------------------------------------------------------------- */
.abtest-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
@media (max-width: 900px) { .abtest-grid { grid-template-columns: 1fr; } }
.variant-card {
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius-xl); padding: 1.1rem;
}
.variant-card.winner {
    border-color: var(--success);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}
.variant-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.85rem;
}
.variant-name { font-weight: 800; font-size: 0.95rem; color: var(--text-main); }
.variant-bar {
    height: 8px; background: var(--bg-soft); border-radius: 999px;
    overflow: hidden; margin-top: 0.4rem;
}
.variant-bar-fill {
    height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}
.variant-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem;
    margin-top: 0.85rem; padding-top: 0.85rem; border-top: 1px dashed var(--border);
}
.variant-stat-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; }
.variant-stat-value { font-size: 1.05rem; font-weight: 800; color: var(--text-main); }

/* -----------------------------------------------------------------------------
   17. Templates
   ----------------------------------------------------------------------------- */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}
.template-card {
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius-2xl);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 0.6rem;
    cursor: pointer; transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.template-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.template-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}
.template-icon.resto    { background: linear-gradient(135deg, #fed7aa, #fdba74); color: #9a3412; }
.template-icon.medical  { background: linear-gradient(135deg, #bfdbfe, #93c5fd); color: #1e40af; }
.template-icon.legal    { background: linear-gradient(135deg, #e9d5ff, #d8b4fe); color: #6b21a8; }
.template-icon.garage   { background: linear-gradient(135deg, #fde68a, #fcd34d); color: #92400e; }
.template-icon.ecom     { background: linear-gradient(135deg, #bbf7d0, #86efac); color: #166534; }
.template-icon.beauty   { background: linear-gradient(135deg, #fbcfe8, #f9a8d4); color: #9d174d; }
.template-icon.other    { background: var(--primary-soft); color: var(--primary-dark); }

.template-title { font-weight: 800; font-size: 1rem; color: var(--text-main); }
.template-desc { font-size: 0.8rem; color: var(--text-muted); flex: 1; }
.template-features {
    display: flex; flex-wrap: wrap; gap: 0.3rem;
    padding-top: 0.6rem; border-top: 1px dashed var(--border);
}
.template-features .badge { font-size: 0.6rem; }

/* -----------------------------------------------------------------------------
   18. Marketplace
   ----------------------------------------------------------------------------- */
.voice-card {
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius-2xl); padding: 1.1rem;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 0.7rem;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.voice-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }

.voice-card-top { display: flex; align-items: center; gap: 0.7rem; }
.voice-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 1.1rem; flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}
.voice-card .name { font-weight: 800; font-size: 0.95rem; color: var(--text-main); }
.voice-card .creator { font-size: 0.72rem; color: var(--text-muted); }

.voice-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.voice-waveform {
    height: 32px;
    background: linear-gradient(90deg, var(--primary-soft) 0%, #f5f3ff 50%, var(--primary-soft) 100%);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center; gap: 2px;
    padding: 0 0.4rem;
}
.voice-waveform .bar {
    width: 3px; background: var(--primary); border-radius: 999px; opacity: 0.7;
}

.voice-card-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding-top: 0.7rem; border-top: 1px dashed var(--border);
}
.voice-price { font-weight: 800; color: var(--text-main); font-size: 0.95rem; }
.voice-price small { font-size: 0.65rem; font-weight: 600; color: var(--text-muted); }

/* -----------------------------------------------------------------------------
   19. Soon banner / preview
   ----------------------------------------------------------------------------- */
.soon-banner {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 1px solid #facc15;
    border-radius: var(--radius-lg);
    padding: 0.85rem 1rem;
    display: flex; align-items: flex-start; gap: 0.75rem;
    color: #713f12;
    margin-bottom: 1rem;
    font-size: 0.825rem;
}
.soon-banner svg { flex-shrink: 0; margin-top: 0.1rem; }
.soon-banner b { color: #713f12; }
.soon-banner code {
    background: rgba(255,255,255,0.6); padding: 0.05rem 0.3rem;
    border-radius: 4px; font-size: 0.78em;
}

/* -----------------------------------------------------------------------------
   20. Login (split layout)
   ----------------------------------------------------------------------------- */
.login-split {
    display: grid; grid-template-columns: 1fr 1fr;
    min-height: 100vh; background: var(--bg-page);
}
@media (max-width: 1024px) { .login-split { grid-template-columns: 1fr; } }

.login-form-side {
    display: flex; align-items: center; justify-content: center;
    padding: 2rem;
}
.login-form-inner { width: 100%; max-width: 380px; }
.login-brand { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 2rem; }
.login-brand img { height: 28px; }
.login-brand .pill {
    font-size: 0.65rem; font-weight: 800; letter-spacing: 0.06em;
    background: linear-gradient(135deg, #ede9fe, #ddd6fe);
    color: var(--primary-dark);
    padding: 0.2rem 0.5rem; border-radius: 999px;
    text-transform: uppercase;
}
.login-title { font-size: 1.75rem; font-weight: 800; color: var(--text-main); margin: 0 0 0.4rem; letter-spacing: -0.025em; }
.login-subtitle { font-size: 0.95rem; color: var(--text-muted); margin: 0 0 1.5rem; }
.login-error {
    background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
    padding: 0.6rem 0.85rem; border-radius: var(--radius-md);
    font-size: 0.8rem; margin-bottom: 1rem;
}

.login-aside {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 60%, #8b5cf6 100%);
    color: #fff; padding: 3rem;
    display: flex; flex-direction: column; justify-content: center;
    position: relative; overflow: hidden;
}
.login-aside::before {
    content: ''; position: absolute; inset: -50% -10% auto auto;
    width: 480px; height: 480px;
    background: radial-gradient(circle, rgba(255,255,255,0.18), transparent 70%);
    border-radius: 50%;
}
.login-aside-inner { position: relative; max-width: 480px; }
.login-aside h2 { font-size: 2rem; font-weight: 800; letter-spacing: -0.025em; margin: 0 0 1rem; }
.login-aside p { font-size: 1rem; opacity: 0.9; margin: 0 0 2rem; }
.login-aside .feature-mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.login-aside .feature-mini {
    background: rgba(255,255,255,0.12); border-radius: 12px; padding: 1rem;
    backdrop-filter: blur(6px);
}
.login-aside .feature-mini .ico { font-size: 1.3rem; margin-bottom: 0.4rem; }
.login-aside .feature-mini .t { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.2rem; }
.login-aside .feature-mini .d { font-size: 0.72rem; opacity: 0.8; }

/* -----------------------------------------------------------------------------
   21. Misc utilities
   ----------------------------------------------------------------------------- */
.hstack { display: flex; align-items: center; gap: 0.5rem; }
.hstack.gap-sm { gap: 0.35rem; }
.hstack.gap-lg { gap: 1rem; }
.vstack { display: flex; flex-direction: column; gap: 0.5rem; }
.vstack.gap-sm { gap: 0.3rem; }
.vstack.gap-lg { gap: 1rem; }
.spacer { flex: 1; }
.text-muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-xs { font-size: 0.7rem; }
.text-sm { font-size: 0.8125rem; }
.text-bold { font-weight: 700; }
.text-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.divider-dashed { border: 0; border-top: 1px dashed var(--border); margin: 1rem 0; }

.tag {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.18rem 0.45rem; font-size: 0.68rem; font-weight: 600;
    background: var(--bg-soft); color: var(--text-muted);
    border: 1px solid var(--border); border-radius: 6px;
}

/* Smooth scrollbar */
.sidebar-nav::-webkit-scrollbar,
.chat-body::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb,
.chat-body::-webkit-scrollbar-thumb {
    background: var(--border); border-radius: 999px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover,
.chat-body::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
