/* ============================================================
   ChatBot SaaS — Dashboard CSS (Material Design Customizado)
   ============================================================ */

/* --- Variáveis CSS (tokens de design) --- */
:root {
    --md-primary:           #1976D2;
    --md-primary-dark:      #115293;
    --md-primary-light:     #42A5F5;
    --md-primary-surface:   #E3F2FD;
    --md-secondary:         #0288D1;
    --md-success:           #2E7D32;
    --md-success-surface:   #E8F5E9;
    --md-warning:           #F57C00;
    --md-warning-surface:   #FFF3E0;
    --md-error:             #C62828;
    --md-error-surface:     #FFEBEE;
    --md-surface:           #FFFFFF;
    --md-background:        #F5F7FA;
    --md-on-surface:        #1C1B1F;
    --md-on-surface-variant:#49454F;
    --md-outline:           #CAC4D0;
    --md-outline-light:     #EDEDF0;

    /* Sidebar */
    --sidebar-width:        260px;
    --sidebar-collapsed:    72px;
    --sidebar-bg:           #0F172A;
    --sidebar-text:         #94A3B8;
    --sidebar-text-active:  #F1F5F9;
    --sidebar-hover:        rgba(255,255,255,0.06);
    --sidebar-active-bg:    rgba(25, 118, 210, 0.18);
    --sidebar-active-border:#1976D2;

    /* Topbar */
    --topbar-height:        64px;
    --topbar-bg:            #FFFFFF;

    /* Sombras */
    --shadow-sm:            0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.12);
    --shadow-md:            0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg:            0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);

    /* Tipografia */
    --font-family:          'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius:               8px;
    --radius-lg:            12px;
    --radius-xl:            16px;

    --transition:           all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-family);
    background: var(--md-background);
    color: var(--md-on-surface);
    display: flex;
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

img { max-width: 100%; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: var(--transition);
    z-index: 200;
    border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

/* Logo */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.sidebar-logo-icon {
    width: 38px; height: 38px;
    background: var(--md-primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-icon .material-icons-round { color: #fff; font-size: 22px; }

.sidebar-logo-text {
    font-size: 15px;
    font-weight: 700;
    color: #F1F5F9;
    letter-spacing: -0.3px;
    white-space: nowrap;
    flex: 1;
}

.sidebar-toggle-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    transition: var(--transition);
    flex-shrink: 0;
}
.sidebar-toggle-btn:hover { color: var(--sidebar-text-active); background: var(--sidebar-hover); }
.sidebar-toggle-btn .material-icons-round { font-size: 20px; }

/* Perfil rápido */
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: relative;
}

.sidebar-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(25,118,210,0.6);
}

.sidebar-profile-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.sidebar-profile-name {
    font-size: 13px;
    font-weight: 600;
    color: #F1F5F9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-role {
    font-size: 11px;
    color: var(--sidebar-text);
    text-transform: capitalize;
}

.sidebar-online-dot {
    width: 8px; height: 8px;
    background: #22C55E;
    border-radius: 50%;
    border: 2px solid var(--sidebar-bg);
    position: absolute;
    bottom: 16px; left: 42px;
}

/* Navegação */
.sidebar-nav {
    flex: 1;
    padding: 8px 0 16px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav-section {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.sidebar-nav-section:last-child { border-bottom: none; }

.sidebar-nav-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: rgba(148, 163, 184, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 20px 4px;
    white-space: nowrap;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    margin: 2px 8px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 400;
    transition: var(--transition);
    position: relative;
    cursor: pointer;
    white-space: nowrap;
}

.sidebar-nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.sidebar-nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--md-primary-light);
    font-weight: 500;
    border-left: 3px solid var(--md-primary);
    margin-left: 5px;
    padding-left: 17px;
}

.sidebar-nav-item .material-icons-round {
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-nav-text { flex: 1; }

.sidebar-badge {
    background: var(--md-error);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.sidebar-nav-item--logout {
    color: rgba(239, 68, 68, 0.7);
}
.sidebar-nav-item--logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
}

/* Overlay mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
    backdrop-filter: blur(2px);
}

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

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--md-outline-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-menu-btn {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    color: var(--md-on-surface-variant);
    transition: var(--transition);
}
.topbar-menu-btn:hover { background: var(--md-outline-light); }
.topbar-menu-btn .material-icons-round { font-size: 24px; }

.topbar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--md-on-surface);
    letter-spacing: -0.3px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--md-success-surface);
    border-radius: 20px;
}

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
}
.status-dot--online { background: #22C55E; box-shadow: 0 0 0 2px rgba(34,197,94,0.2); }

.status-text { font-size: 12px; font-weight: 500; color: var(--md-success); }

.topbar-icon-btn {
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    color: var(--md-on-surface-variant);
    transition: var(--transition);
}
.topbar-icon-btn:hover { background: var(--md-outline-light); }
.topbar-icon-btn .material-icons-round { font-size: 22px; }

.topbar-badge {
    position: absolute;
    top: 4px; right: 4px;
    background: var(--md-error);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    width: 16px; height: 16px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
}

/* User menu */
.topbar-user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}
.topbar-user-menu:hover { background: var(--md-outline-light); }

.topbar-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.topbar-user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--md-on-surface);
}

.topbar-chevron { font-size: 18px; color: var(--md-on-surface-variant); }

/* Dropdown */
.topbar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--md-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--md-outline-light);
    min-width: 180px;
    overflow: hidden;
    display: none;
    z-index: 300;
}
.topbar-user-menu:hover .topbar-dropdown,
.topbar-user-menu.open .topbar-dropdown { display: block; }

.topbar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--md-on-surface);
    transition: var(--transition);
}
.topbar-dropdown-item:hover { background: var(--md-outline-light); }
.topbar-dropdown-item .material-icons-round { font-size: 18px; color: var(--md-on-surface-variant); }

.topbar-dropdown-divider { height: 1px; background: var(--md-outline-light); margin: 4px 0; }

.topbar-dropdown-item--danger { color: var(--md-error); }
.topbar-dropdown-item--danger .material-icons-round { color: var(--md-error); }

/* ============================================================
   ALERTAS (Flash Messages)
   ============================================================ */
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin: 16px 24px 0;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
}

.alert--success {
    background: var(--md-success-surface);
    color: var(--md-success);
    border-left: 4px solid #4CAF50;
}
.alert--error {
    background: var(--md-error-surface);
    color: var(--md-error);
    border-left: 4px solid #F44336;
}
.alert--warning {
    background: var(--md-warning-surface);
    color: var(--md-warning);
    border-left: 4px solid #FF9800;
}

.alert .material-icons-round { font-size: 20px; flex-shrink: 0; }
.alert-close { margin-left: auto; background: transparent; border: none; cursor: pointer; color: inherit; opacity: 0.7; }
.alert-close:hover { opacity: 1; }

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
    flex: 1;
    padding: 24px;
    overflow-x: hidden;
}

/* ============================================================
   CARDS (Material Design Elevation)
   ============================================================ */
.card {
    background: var(--md-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--md-outline-light);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--md-outline-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--md-on-surface);
}

.card-subtitle {
    font-size: 13px;
    color: var(--md-on-surface-variant);
    margin-top: 2px;
}

.card-body { padding: 24px; }

.card-footer {
    padding: 12px 24px;
    background: var(--md-background);
    border-top: 1px solid var(--md-outline-light);
}

/* ============================================================
   METRIC CARDS (Dashboard)
   ============================================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--md-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--md-outline-light);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
}
.metric-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.metric-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.metric-icon .material-icons-round { font-size: 24px; }

.metric-icon--blue    { background: var(--md-primary-surface); color: var(--md-primary); }
.metric-icon--green   { background: var(--md-success-surface); color: var(--md-success); }
.metric-icon--orange  { background: var(--md-warning-surface); color: var(--md-warning); }
.metric-icon--red     { background: var(--md-error-surface); color: var(--md-error); }

.metric-info { flex: 1; }
.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--md-on-surface);
    line-height: 1;
    letter-spacing: -1px;
}
.metric-label {
    font-size: 13px;
    color: var(--md-on-surface-variant);
    margin-top: 4px;
}
.metric-trend {
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: 6px;
}
.metric-trend--up   { color: var(--md-success); }
.metric-trend--down { color: var(--md-error); }

/* ============================================================
   TABELAS
   ============================================================ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--md-outline-light);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--md-surface);
}

thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--md-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--md-background);
    border-bottom: 1px solid var(--md-outline-light);
}

tbody td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--md-on-surface);
    border-bottom: 1px solid var(--md-outline-light);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--md-background); }

/* ============================================================
   BOTÕES
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    font-family: var(--font-family);
}

.btn .material-icons-round { font-size: 18px; }

.btn--primary {
    background: var(--md-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn--primary:hover { background: var(--md-primary-dark); box-shadow: var(--shadow-md); }

.btn--secondary {
    background: var(--md-surface);
    color: var(--md-primary);
    border: 1px solid var(--md-primary);
}
.btn--secondary:hover { background: var(--md-primary-surface); }

.btn--ghost {
    background: transparent;
    color: var(--md-on-surface-variant);
    border: 1px solid var(--md-outline);
}
.btn--ghost:hover { background: var(--md-background); color: var(--md-on-surface); }

.btn--danger {
    background: var(--md-error);
    color: #fff;
}
.btn--danger:hover { filter: brightness(0.9); }

.btn--sm { padding: 6px 14px; font-size: 13px; }
.btn--lg { padding: 14px 28px; font-size: 16px; }

/* ============================================================
   BADGES / CHIPS
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.badge--success { background: var(--md-success-surface); color: var(--md-success); }
.badge--warning { background: var(--md-warning-surface); color: var(--md-warning); }
.badge--error   { background: var(--md-error-surface);   color: var(--md-error); }
.badge--info    { background: var(--md-primary-surface); color: var(--md-primary); }
.badge--neutral { background: var(--md-outline-light);   color: var(--md-on-surface-variant); }

/* ============================================================
   FORMULÁRIOS
   ============================================================ */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--md-on-surface-variant);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--md-outline);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font-family);
    color: var(--md-on-surface);
    background: var(--md-surface);
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.form-control.is-invalid {
    border-color: var(--md-error);
}

.form-error {
    font-size: 12px;
    color: var(--md-error);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.form-error .material-icons-round { font-size: 14px; }

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2349454F' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 100px; }

/* ============================================================
   AVATAR COLORS (UI Avatars fallback)
   ============================================================ */
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
}
.avatar--sm { width: 28px; height: 28px; }
.avatar--lg { width: 48px; height: 48px; }

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

.page-header-info h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--md-on-surface);
    letter-spacing: -0.5px;
}

.page-header-info p {
    font-size: 14px;
    color: var(--md-on-surface-variant);
    margin-top: 4px;
}

.page-header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--md-on-surface-variant);
}
.empty-state .material-icons-round {
    font-size: 64px;
    color: var(--md-outline);
    margin-bottom: 16px;
    display: block;
}
.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--md-on-surface);
    margin-bottom: 8px;
}
.empty-state p {
    font-size: 14px;
    max-width: 360px;
    margin: 0 auto 20px;
    line-height: 1.6;
}

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-page {
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-container {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    background: var(--md-surface);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
}

.auth-logo-icon {
    width: 48px; height: 48px;
    background: var(--md-primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-logo-icon .material-icons-round { font-size: 28px; color: #fff; }

.auth-logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--md-on-surface);
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--md-on-surface);
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--md-on-surface-variant);
    text-align: center;
    margin-bottom: 28px;
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--md-on-surface-variant);
}

.auth-link a {
    color: var(--md-primary);
    font-weight: 500;
    text-decoration: none;
}
.auth-link a:hover { text-decoration: underline; }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--md-on-surface-variant);
    font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--md-outline-light);
}

/* ============================================================
   GRID UTILITIES
   ============================================================ */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--md-on-surface-variant); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }

.w-full { width: 100%; }

/* ============================================================
   SIDEBAR COLLAPSED STATE
   ============================================================ */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-profile-info,
.sidebar.collapsed .sidebar-nav-text,
.sidebar.collapsed .sidebar-nav-label,
.sidebar.collapsed .sidebar-badge { display: none; }
.sidebar.collapsed .sidebar-toggle-btn .material-icons-round { transform: rotate(180deg); }
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 20px 16px; }
.sidebar.collapsed .sidebar-profile { justify-content: center; padding: 14px 16px; }
.sidebar.collapsed .sidebar-nav-item { justify-content: center; padding: 10px; margin: 2px 8px; }
.sidebar.collapsed .sidebar-nav-item.active { margin-left: 8px; padding-left: 10px; border-left: none; border-radius: var(--radius); }
.main-content.collapsed-sidebar { margin-left: var(--sidebar-collapsed); }

/* ============================================================
   RESPONSIVIDADE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar-overlay.active { display: block; }
    .main-content { margin-left: 0; }
    .topbar-menu-btn { display: flex; }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .topbar-user-name { display: none; }
    .page-header { flex-direction: column; }
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .metrics-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .auth-card { padding: 28px 20px; }
}

/* ============================================================
   SCROLLBAR GLOBAL
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--md-outline); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--md-on-surface-variant); }

/* ============================================================
   VARIÁVEIS EXTRAS (compat. com views)
   ============================================================ */
:root {
    --color-primary:         var(--md-primary);
    --color-border:          var(--md-outline);
    --color-text-secondary:  var(--md-on-surface-variant);
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-header-info {}
.page-header-title { margin: 0; font-size: 22px; font-weight: 600; color: var(--md-on-surface); }
.page-header-subtitle { margin: 4px 0 0; font-size: 14px; color: var(--md-on-surface-variant); }
.page-header-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.empty-state-icon {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--md-primary-surface);
    display: flex; align-items: center; justify-content: center;
}
.empty-state-icon .material-icons-round { font-size: 36px; color: var(--md-primary); }
.empty-state-title { margin: 0; font-size: 20px; font-weight: 600; }
.empty-state-desc  { margin: 0; color: var(--md-on-surface-variant); max-width: 400px; }

/* ============================================================
   CARD GRID (chatbots)
   ============================================================ */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.card--chatbot {}
.card-chatbot-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--md-primary-surface);
}
.card-chatbot-icon .material-icons-round { font-size: 26px; color: var(--md-primary); }
.card-chatbot-icon--sdr         { background: #e8f5e9; }
.card-chatbot-icon--sdr .material-icons-round { color: #2E7D32; }
.card-chatbot-icon--suporte     { background: #e3f2fd; }
.card-chatbot-icon--suporte .material-icons-round { color: #1565C0; }
.card-chatbot-icon--vendas      { background: #fff3e0; }
.card-chatbot-icon--vendas .material-icons-round { color: #E65100; }
.card-chatbot-icon--agendamento { background: #f3e5f5; }
.card-chatbot-icon--agendamento .material-icons-round { color: #6A1B9A; }

.card-header {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--md-outline-light);
    flex-wrap: wrap;
}
.card-chatbot-info { flex: 1; min-width: 0; }
.card-chatbot-name { margin: 0 0 4px; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-chatbot-status { flex-shrink: 0; }
.card-body    { padding: 16px 20px; }
.card-desc    { margin: 0; font-size: 13px; color: var(--md-on-surface-variant); }
.card-footer  { padding: 12px 20px; border-top: 1px solid var(--md-outline-light); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.card-meta    { font-size: 12px; color: var(--md-on-surface-variant); display: flex; align-items: center; gap: 4px; }
.card-title   { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* Status chips */
.status-chip            { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.status-chip--ativo     { background: var(--md-success-surface); color: var(--md-success); }
.status-chip--inativo   { background: #f5f5f5; color: #757575; }

/* Badges */
.badge                  { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge--primary         { background: var(--md-primary-surface); color: var(--md-primary); }
.badge--success         { background: var(--md-success-surface); color: var(--md-success); }
.badge--warning         { background: var(--md-warning-surface); color: var(--md-warning); }
.badge--outline         { border: 1px solid var(--md-outline); color: var(--md-on-surface-variant); }
.badge--sdr             { background: #e8f5e9; color: #2E7D32; }
.badge--suporte         { background: #e3f2fd; color: #1565C0; }
.badge--vendas          { background: #fff3e0; color: #E65100; }
.badge--agendamento     { background: #f3e5f5; color: #6A1B9A; }

/* ============================================================
   CARD GENÉRICO
   ============================================================ */
.card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--md-outline-light);
    overflow: hidden;
}
.card--info { border-left: 3px solid var(--md-primary); }
.card--sticky { position: sticky; top: 80px; }

/* ============================================================
   GRID HELPERS
   ============================================================ */
.grid          { display: grid; }
.grid--2col    { grid-template-columns: 1fr 1fr; }
.d-inline      { display: inline; }
.w-full        { width: 100%; }

/* ============================================================
   BOTÕES EXTRAS
   ============================================================ */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500; cursor: pointer; border: none; text-decoration: none; transition: var(--transition); white-space: nowrap; }
.btn--primary  { background: var(--md-primary); color: #fff; }
.btn--primary:hover { background: var(--md-primary-dark); }
.btn--outline  { background: transparent; border: 1px solid var(--md-outline); color: var(--md-on-surface); }
.btn--outline:hover { background: var(--md-background); }
.btn--ghost    { background: transparent; color: var(--md-on-surface-variant); }
.btn--ghost:hover { background: var(--md-background); }
.btn--danger   { color: var(--md-error); }
.btn--danger:hover { background: var(--md-error-surface); }
.btn--sm       { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ============================================================
   FORMULÁRIOS EXTRAS
   ============================================================ */
.form-group    { margin-bottom: 16px; }
.form-label    { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--md-on-surface); }
.form-control  { width: 100%; padding: 9px 12px; border: 1px solid var(--md-outline); border-radius: var(--radius); font-size: 14px; font-family: inherit; outline: none; transition: border-color .2s; background: #fff; box-sizing: border-box; }
.form-control:focus { border-color: var(--md-primary); box-shadow: 0 0 0 2px rgba(25,118,210,.12); }
.form-control.is-invalid { border-color: var(--md-error); }
.form-control--code { font-family: monospace; font-size: 13px; }
.form-error    { color: var(--md-error); font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.form-hint     { font-size: 12px; color: var(--md-on-surface-variant); margin-top: 4px; }
.form-row      { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-range    { width: 100%; accent-color: var(--md-primary); }

/* Toggle switch */
.toggle-label  { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle-input  { display: none; }
.toggle-switch { width: 42px; height: 22px; background: var(--md-outline); border-radius: 11px; position: relative; transition: background .2s; flex-shrink: 0; }
.toggle-switch::after { content: ''; position: absolute; width: 18px; height: 18px; background: #fff; border-radius: 50%; top: 2px; left: 2px; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.toggle-input:checked ~ .toggle-switch { background: var(--md-primary); }
.toggle-input:checked ~ .toggle-switch::after { transform: translateX(20px); }
.toggle-text   { font-size: 14px; }

/* ============================================================
   ABAS (TABS)
   ============================================================ */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--md-outline-light); margin-bottom: 0; overflow-x: auto; }
.tab  { display: flex; align-items: center; gap: 6px; padding: 10px 18px; font-size: 14px; font-weight: 500; color: var(--md-on-surface-variant); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .2s; white-space: nowrap; }
.tab:hover { color: var(--md-primary); }
.tab.active { color: var(--md-primary); border-bottom-color: var(--md-primary); }

/* ============================================================
   TABELAS
   ============================================================ */
.table-card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--md-outline-light); overflow: hidden; }
.table      { width: 100%; border-collapse: collapse; }
.table th   { background: var(--md-background); padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--md-on-surface-variant); }
.table td   { padding: 12px 16px; border-top: 1px solid var(--md-outline-light); font-size: 14px; vertical-align: middle; }
.table tr:hover td { background: var(--md-background); }
.table-actions { display: flex; gap: 4px; }

/* ============================================================
   LISTA SIMPLES
   ============================================================ */
.list-group      { list-style: none; padding: 0; margin: 0; }
.list-group-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--md-outline-light); font-size: 14px; }
.list-group-item:first-child { border-top: none; }

/* ============================================================
   ALERTAS
   ============================================================ */
.alert           { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert--success  { background: var(--md-success-surface); color: var(--md-success); }
.alert--error    { background: var(--md-error-surface); color: var(--md-error); }
.alert--warning  { background: var(--md-warning-surface); color: var(--md-warning); }
.alert-close     { background: none; border: none; cursor: pointer; margin-left: auto; color: inherit; display: flex; align-items: center; }

/* ============================================================
   COLOR PICKER
   ============================================================ */
.color-picker-group { display: flex; align-items: center; gap: 8px; }
.color-picker       { width: 44px; height: 36px; border: 1px solid var(--md-outline); border-radius: var(--radius); cursor: pointer; padding: 2px; background: none; }
.color-picker-text  { flex: 1; }

/* ============================================================
   POSITION PICKER
   ============================================================ */
.position-picker  { display: flex; gap: 10px; flex-wrap: wrap; }
.position-option  { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--md-outline); border-radius: var(--radius); cursor: pointer; font-size: 13px; transition: all .2s; }
.position-option input { display: none; }
.position-option.active { border-color: var(--md-primary); background: var(--md-primary-surface); color: var(--md-primary); }

/* ============================================================
   EDITOR DE FLUXO
   ============================================================ */
.editor-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 0 20px; gap: 12px; flex-wrap: wrap;
}
.editor-header-left  { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.editor-header-right { display: flex; gap: 10px; }

.editor-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
}

.editor-steps          { background: #fff; border-radius: var(--radius-lg); border: 1px solid var(--md-outline-light); box-shadow: var(--shadow-sm); padding: 20px; }
.editor-steps-header   { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.editor-steps-header h3 { margin: 0; font-size: 15px; font-weight: 600; }

.step-card { background: #fff; border: 1px solid var(--md-outline-light); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; transition: box-shadow .2s; }
.step-card:hover { box-shadow: var(--shadow-md); }
.step-card-header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.step-card-drag   { color: var(--md-outline); cursor: grab; flex-shrink: 0; }
.step-card-num    { width: 24px; height: 24px; border-radius: 50%; background: var(--md-primary); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-card-info   { flex: 1; min-width: 0; }
.step-card-info strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-type-badge  { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--md-on-surface-variant); }
.step-type-badge .material-icons-round { font-size: 13px; }
.step-card-tags   { display: flex; gap: 4px; flex-shrink: 0; }
.step-card-actions { display: flex; gap: 2px; flex-shrink: 0; }
.step-card-options { padding: 0 14px 12px; display: flex; gap: 6px; flex-wrap: wrap; }

.steps-empty { text-align: center; padding: 40px 16px; color: var(--md-on-surface-variant); }
.steps-empty .material-icons-round { font-size: 40px; display: block; margin-bottom: 8px; }

.option-chip { background: var(--md-background); border-radius: 12px; padding: 3px 10px; font-size: 11px; color: var(--md-on-surface-variant); border: 1px solid var(--md-outline-light); }

/* Preview do chat no editor */
.editor-preview        { background: #fff; border-radius: var(--radius-lg); border: 1px solid var(--md-outline-light); box-shadow: var(--shadow-sm); overflow: hidden; position: sticky; top: 80px; }
.editor-preview-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--md-outline-light); }
.editor-preview-header h3 { margin: 0; font-size: 15px; font-weight: 600; }

.chat-preview     { display: flex; flex-direction: column; height: 480px; }
.chat-messages    { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: #fafafa; }
.chat-bubble      { display: flex; gap: 8px; align-items: flex-end; max-width: 85%; }
.chat-bubble--bot { align-self: flex-start; }
.chat-bubble--user { align-self: flex-end; flex-direction: row-reverse; }
.chat-bubble-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--md-primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-bubble-avatar .material-icons-round { font-size: 18px; color: #fff; }
.chat-bubble-content { background: #e3f2fd; border-radius: 12px 12px 12px 0; padding: 10px 14px; font-size: 13px; line-height: 1.5; }
.chat-bubble--user .chat-bubble-content { background: var(--md-primary); color: #fff; border-radius: 12px 12px 0 12px; }
.chat-input-area  { padding: 10px 12px; border-top: 1px solid var(--md-outline-light); display: flex; gap: 8px; align-items: center; background: #fff; }
.chat-input       { flex: 1; border: 1px solid var(--md-outline); border-radius: 24px; padding: 8px 16px; font-size: 13px; outline: none; font-family: inherit; }
.chat-input:focus { border-color: var(--md-primary); }
.chat-send-btn    { width: 38px; height: 38px; border-radius: 50%; background: var(--md-primary); color: #fff; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-option-btn  { border: 1px solid var(--md-primary); color: var(--md-primary); background: #fff; border-radius: 20px; padding: 6px 14px; font-size: 12px; cursor: pointer; transition: all .15s; }
.chat-option-btn:hover { background: var(--md-primary); color: #fff; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay  { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.visible { display: flex; }
.modal          { background: #fff; border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header   { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--md-outline-light); }
.modal-title    { margin: 0; font-size: 17px; font-weight: 600; }
.modal-close    { background: none; border: none; cursor: pointer; color: var(--md-on-surface-variant); display: flex; align-items: center; }
.modal-body     { padding: 20px 24px; }
.modal-footer   { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--md-outline-light); }

/* ============================================================
   TIPO GRID (modal de etapas)
   ============================================================ */
.tipo-grid    { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.tipo-option  { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px; border: 1px solid var(--md-outline); border-radius: var(--radius); cursor: pointer; font-size: 12px; text-align: center; transition: all .2s; }
.tipo-option input { display: none; }
.tipo-option .material-icons-round { font-size: 22px; color: var(--md-on-surface-variant); }
.tipo-option:hover  { border-color: var(--md-primary); color: var(--md-primary); }
.tipo-option:hover .material-icons-round { color: var(--md-primary); }
.tipo-option.active { border-color: var(--md-primary); background: var(--md-primary-surface); color: var(--md-primary); }
.tipo-option.active .material-icons-round { color: var(--md-primary); }

/* ============================================================
   TOAST
   ============================================================ */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px); background: #323232; color: #fff; padding: 10px 20px; border-radius: 24px; font-size: 14px; z-index: 9999; transition: transform .3s; box-shadow: var(--shadow-lg); white-space: nowrap; }
.toast.visible { transform: translateX(-50%) translateY(0); }

/* ============================================================
   RESPONSIVIDADE DO EDITOR
   ============================================================ */
@media (max-width: 900px) {
    .editor-layout { grid-template-columns: 1fr; }
    .editor-preview { position: static; }
    .grid--2col { grid-template-columns: 1fr; }
}
