/* =========================================================================
   FLUXONZAP - PREMIUM DESIGN SYSTEM, COLLAPSIBLE SIDEBAR & STYLES
   ========================================================================= */

:root {
    /* Paleta de Cores Curada */
    --color-bg-dark: #000108;       /* Fundo do Topo/Header/Sidebar Premium */
    --color-bg-light: #F8FAFC;      /* Fundo Claro do Restante do Sistema */
    --color-bg-card: #FFFFFF;       /* Cards e Tabelas */
    
    /* Gradientes e Acentuações */
    --color-violet: #7C3AED;        /* Roxo Elétrico */
    --color-violet-light: #A78BFA;  /* Roxo Claro */
    --color-violet-hover: #6D28D9;
    --color-violet-glow: rgba(124, 58, 237, 0.12);
    
    --color-green: #10B981;         /* Verde WhatsApp Moderno */
    --color-green-light: #34D399;   /* Verde Claro */
    --color-green-hover: #059669;
    --color-green-glow: rgba(16, 185, 129, 0.12);

    --color-gradient-primary: linear-gradient(135deg, #7C3AED 0%, #10B981 100%);
    --color-gradient-violet: linear-gradient(135deg, #7C3AED 0%, #A78BFA 100%);
    --color-gradient-green: linear-gradient(135deg, #059669 0%, #34D399 100%);
    
    /* Cores de Feedback */
    --color-danger: #EF4444;
    --color-danger-light: #FEF2F2;
    --color-warning: #F59E0B;
    --color-warning-light: #FEF3C7;
    
    /* Tipografia & Bordas */
    --font-sans: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;
    
    --border-color: #E2E8F0;
    --border-soft: #F1F5F9;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Sombras Premium */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.25);
    
    /* Animações e Transições */
    --transition-fast: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-normal: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-sidebar: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* =========================================================================
   RESET E CONFIGURAÇÕES GERAIS
   ========================================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg-light);
    color: #1E293B;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* =========================================================================
   ANIMAÇÕES MODERNAS
   ========================================================================= */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes pulse-glow {
    0% { transform: scale(0.95); opacity: 0.5; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
    70% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); opacity: 0.5; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.animate-fade-in {
    animation: fadeIn var(--transition-normal) forwards;
}

.animate-slide-up {
    animation: slideUp var(--transition-normal) forwards;
}

/* =========================================================================
   SISTEMA DE LOADING CENTRALIZADO
   ========================================================================= */
.app-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    transition: opacity var(--transition-fast) ease-out;
}

.app-spinner.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner-core {
    width: 48px;
    height: 48px;
    border: 3.5px solid var(--border-color);
    border-top: 3.5px solid var(--color-violet);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-text {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: #475569;
}

/* =========================================================================
   SISTEMA DE TOASTS FLUTUANTES
   ========================================================================= */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    width: calc(100vw - 48px);
}

.toast {
    background: #FFFFFF;
    border-left: 5px solid var(--color-violet);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideUp var(--transition-fast) forwards;
    position: relative;
    overflow: hidden;
}

.toast.success { border-left-color: var(--color-green); }
.toast.error { border-left-color: var(--color-danger); }
.toast.info { border-left-color: var(--color-violet); }

.toast-message {
    font-size: 0.88rem;
    font-weight: 500;
    color: #334155;
    flex-grow: 1;
}

/* =========================================================================
   COMPATIBILIDADE SPA: PAINÉIS DE TELA
   ========================================================================= */
.view-panel {
    display: none;
}

.view-panel.active {
    display: block;
}

.hidden {
    display: none !important;
}

/* =========================================================================
   ESTRUTURA DE LOGIN E AUTENTICAÇÃO (TELA CHEIA)
   ========================================================================= */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-color: #F8FAFC;
    position: relative;
    overflow: hidden;
}

/* Esferas decorativas de fundo */
.auth-wrapper::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(124, 58, 237, 0.10) 0%, transparent 70%);
    top: -180px;
    left: -180px;
    pointer-events: none;
    z-index: 0;
}

.auth-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.09) 0%, transparent 70%);
    bottom: -120px;
    right: -120px;
    pointer-events: none;
    z-index: 0;
}

.auth-card {
    background: var(--color-bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 440px;
    padding: 44px 40px 40px;
    box-shadow: 0 24px 48px -12px rgba(0,0,0,0.10), 0 0 0 1px rgba(0,0,0,0.04);
    text-align: center;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* Barra de identidade no topo do card */
.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #7C3AED 0%, #10B981 100%);
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 0;
}

/* Logo wrapper no card de auth com mais respiro */
.auth-card .brand-logo {
    font-size: 2.4rem;
    margin-bottom: 28px;
    display: flex;
}

.logo-flux {
    color: #FFFFFF;
}

/* No auth-card o logo é roxo/verde pois o fundo é claro */
.auth-card .logo-flux {
    color: var(--color-violet);
}
.logo-on {
    color: var(--color-green);
    margin: 0 2px;
}
.logo-zap {
    background: var(--color-gradient-violet);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header h2 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    color: #0F172A;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}

.auth-header p {
    font-size: 0.9rem;
    color: #64748B;
    margin-bottom: 32px;
    line-height: 1.6;
}

/* Divisória decorativa entre logo e formulário */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 28px 0;
}

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

.auth-divider span {
    font-size: 0.72rem;
    font-weight: 600;
    color: #CBD5E1;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

/* =========================================================================
   COMPONENTES DE FORMULÁRIO MODERNOS
   ========================================================================= */
.auth-form {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.input-group label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-wrapper i,
.input-wrapper svg {
    position: absolute;
    left: 16px;
    color: #94A3B8;
    width: 18px;
    height: 18px;
    pointer-events: none;
    transition: color var(--transition-fast);
}

.input-wrapper input,
.input-wrapper select,
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 13px 16px 13px 44px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--color-bg-light);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    color: #1E293B;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.input-wrapper input::placeholder,
.input-group textarea::placeholder {
    color: #CBD5E1;
    font-weight: 400;
}

.input-group select {
    padding-left: 16px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 14px;
}

.input-group textarea {
    padding: 14px 16px;
    resize: none;
    line-height: 1.6;
}

.input-wrapper input:focus,
.input-wrapper select:focus,
.input-group select:focus,
.input-group textarea:focus {
    border-color: var(--color-violet);
    background-color: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.10);
}

.input-wrapper:focus-within i,
.input-wrapper:focus-within svg {
    color: var(--color-violet);
}


.btn-toggle-password {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.btn-toggle-password i,
.btn-toggle-password svg {
    position: static !important;
    left: auto !important;
    color: #94A3B8;
    pointer-events: auto !important;
    width: 18px !important;
    height: 18px !important;
}

.btn-toggle-password:hover i,
.btn-toggle-password:hover svg {
    color: var(--color-violet) !important;
}

.input-wrapper input[type="password"] {
    padding-right: 46px;
}

.forgot-link, .auth-redirect {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-violet);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.forgot-link:hover, .auth-redirect:hover {
    color: var(--color-violet-hover);
}

/* =========================================================================
   BOTÕES COM MICRO-INTERAÇÕES
   ========================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 13px 22px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    letter-spacing: 0.15px;
    user-select: none;
}

.btn:active {
    transform: scale(0.97) !important;
}

.btn-primary {
    background: var(--color-gradient-primary);
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.35);
}

.btn-secondary {
    background-color: #FFFFFF;
    border: 1.5px solid var(--border-color);
    color: #475569;
}

.btn-secondary:hover {
    background-color: var(--color-bg-light);
    border-color: #CBD5E1;
    color: #0F172A;
}

.btn-accent {
    background: var(--color-gradient-green);
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.2);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.text-muted {
    font-size: 0.78rem;
    color: #94A3B8;
}

/* =========================================================================
   PORTAL SHELL - CABEÇALHO DO SAAS (HEADER PRETO #000108)
   ========================================================================= */
.app-header {
    background-color: var(--color-bg-dark);
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 70px;
    z-index: 1000;
    border-bottom: 2px solid rgba(255, 255, 255, 0.05);
    box-shadow: var(--shadow-md);
}

.header-container {
    max-width: 100%;
    height: 100%;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* A brand-logo do header herda o estilo genérico, mas sem margin-bottom */
.app-header .brand-logo {
    font-size: 2rem;
    margin-bottom: 0;
}

.page-title-header {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    border-left: 1.5px solid rgba(255, 255, 255, 0.12);
    padding-left: 16px;
    display: block;
    letter-spacing: 0.1px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--color-gradient-primary);
    color: #FFFFFF;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #FFFFFF;
}

.user-info-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.user-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #FFFFFF;
}

.user-role {
    font-size: 0.72rem;
    font-weight: 500;
    color: #94A3B8;
}

.btn-logout-header {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #F1F5F9;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-logout-header:hover {
    background: #EF4444;
    color: #FFFFFF;
    transform: scale(1.05);
}

/* =========================================================================
   BODY CONTAINER (DESKTOP LAYOUT COM SIDEBAR COLAPSÁVEL)
   ========================================================================= */
.app-body-container {
    display: flex;
    width: 100vw;
    height: calc(100vh - 70px);
    margin-top: 70px;
    position: relative;
}

/* SIDEBAR MODERNA, CLEAN E COLAPSÁVEL */
.app-sidebar {
    background-color: var(--color-bg-dark);
    width: 72px; /* Recolhida mostra apenas ícones */
    height: 100%;
    flex-shrink: 0;
    border-right: 1.5px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 0;
    z-index: 990;
    position: relative;
    overflow: hidden;
    transition: width var(--transition-sidebar);
}

/* Ao passar o mouse, expande e mostra os textos com animação suave */
.app-sidebar:hover {
    width: 240px;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    padding: 0 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: center; /* centralizado quando recolhida */
    padding: 11px 12px;
    border-radius: var(--radius-md);
    color: #94A3B8;
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.93rem;
    width: 100%;
    transition: all var(--transition-fast);
    position: relative;
    gap: 0;
}

/* Quando sidebar expande: alinhar à esquerda */
.app-sidebar:hover .sidebar-link {
    justify-content: flex-start;
    gap: 14px;
    padding: 11px 14px;
}

.sidebar-link i {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: color var(--transition-fast);
}

/* Texto colapsável */
.sidebar-link-text {
    opacity: 0;
    white-space: nowrap;
    overflow: hidden;
    width: 0;
    transition: opacity 0.18s ease-in-out, width 0.18s ease-in-out;
    pointer-events: none;
}

.app-sidebar:hover .sidebar-link-text {
    opacity: 1;
    width: auto;
    pointer-events: auto;
}

.sidebar-link:hover {
    color: #FFFFFF;
    background-color: rgba(255, 255, 255, 0.09);
}

/* Item ativo: gradiente + indicador lateral via inset shadow */
.sidebar-link.active {
    background: var(--color-gradient-primary);
    color: #FFFFFF !important;
    box-shadow: inset 3px 0 0 var(--color-green), 0 4px 14px rgba(124, 58, 237, 0.28);
}

.sidebar-link.active i {
    color: #FFFFFF !important;
}

/* Rodapé da Sidebar */
.sidebar-footer {
    padding: 0 10px;
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 12px;
    margin-top: 8px;
}

/* Info do usuário no rodapé (só visivel quando expandida) */
.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.04);
    overflow: hidden;
    min-width: 0;
}

.sidebar-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--color-gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.75rem;
    color: #FFFFFF;
    flex-shrink: 0;
}

.sidebar-user-details {
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    width: 0;
    transition: opacity 0.18s ease, width 0.18s ease;
    pointer-events: none;
}

.app-sidebar:hover .sidebar-user-details {
    opacity: 1;
    width: 140px;
    pointer-events: auto;
}

.sidebar-user-name {
    font-family: var(--font-heading);
    font-size: 0.78rem;
    font-weight: 700;
    color: #E2E8F0;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 0.68rem;
    color: #64748B;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================================================================
   CONTEÚDO PRINCIPAL (FUNDO CLARO E CARDS PREMIUM)
   ========================================================================= */
.app-main-content {
    flex-grow: 1;
    height: 100%;
    overflow-y: auto;
    background-color: var(--color-bg-light); /* Fundo claro */
    padding: 40px 48px;
    position: relative;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.page-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-title {
    font-family: var(--font-heading);
    font-size: 1.9rem;
    font-weight: 800;
    color: #0F172A;
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 0.95rem;
    color: #64748B;
    margin-top: 2px;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #475569;
    background: #FFFFFF;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot.green { background-color: var(--color-green); }
.dot.pulse {
    animation: pulse-glow 2s infinite;
}

/* CARDS BRANCOS COM SOMBRAS LEVES E BORDAS ARREDONDADAS (PREMIUM) */
.card {
    background: var(--color-bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition-fast) ease, border-color var(--transition-fast) ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(124, 58, 237, 0.12);
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.card-header h3 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: #0F172A;
    letter-spacing: -0.1px;
}

.card-body {
    padding: 20px 24px;
}

.empty-text {
    font-size: 0.88rem;
    color: #64748B;
    text-align: center;
    padding: 20px 0;
}

/* =========================================================================
   ESTRUTURA DO DASHBOARD (CARDS & METRICAS)
   ========================================================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--color-bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

/* Accent no hover — linha superior gradiente */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-violet) 0%, var(--color-green) 100%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: rgba(124, 58, 237, 0.2);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-wrapper i {
    width: 24px;
    height: 24px;
}

.stat-icon-wrapper.green-light { background: #ECFDF5; color: var(--color-green); }
.stat-icon-wrapper.violet-light { background: #F5F3FF; color: var(--color-violet); }
.stat-icon-wrapper.blue-light { background: #EFF6FF; color: #3B82F6; }
.stat-icon-wrapper.orange-light { background: #FFF7ED; color: #F97316; }

.stat-data {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    color: #0F172A;
    margin-top: 2px;
}

/* DASHBOARD COLUMNS */
.dashboard-columns {
    display: flex;
    gap: 24px;
}

.flex-2 { flex: 2; }
.flex-1 { flex: 1; }

/* LISTA DE INSTÂNCIAS NO DASHBOARD (COMPACTA) */
.instance-list-compact {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.instance-row-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: var(--color-bg-light);
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-soft);
}

.instance-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.instance-name-compact {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: #1E293B;
}

.status-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 99px;
    text-transform: uppercase;
}

.status-badge.connected { background-color: #D1FAE5; color: #065F46; }
.status-badge.connecting { background-color: #FEF3C7; color: #92400E; }
.status-badge.disconnected { background-color: #FEE2E2; color: #991B1B; }

.upcoming-schedules-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.schedule-item-compact {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    background-color: var(--color-bg-light);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--color-violet);
    text-align: left;
}

.schedule-item-dest {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1E293B;
}

.schedule-item-content {
    font-size: 0.8rem;
    color: #64748B;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 4px 0;
}

.schedule-item-time {
    font-size: 0.7rem;
    font-weight: 600;
    color: #94A3B8;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* =========================================================================
   TELA DE INSTÂNCIAS (GRID COMPLETO)
   ========================================================================= */
.instances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.instance-card {
    background: #FFFFFF;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
}

.instance-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-violet);
}

.instance-card-header {
    background-color: var(--color-bg-light);
    padding: 20px;
    border-bottom: 1.5px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.instance-card-header i {
    width: 22px;
    height: 22px;
    color: var(--color-violet);
}

.instance-card-body {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 20px;
    text-align: left;
}

.instance-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #64748B;
}

.meta-row strong {
    color: #1E293B;
}

.instance-card-actions {
    display: flex;
    gap: 10px;
}

.empty-state-container {
    grid-column: 1 / -1;
    background: #FFFFFF;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 60px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.empty-icon-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-violet-glow);
    color: var(--color-violet);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.empty-icon-wrapper i {
    width: 28px;
    height: 28px;
}

.empty-state-container h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: #0F172A;
}

.empty-state-container p {
    font-size: 0.88rem;
    color: #64748B;
    max-width: 420px;
    margin: 0 auto 8px auto;
}

/* =========================================================================
   TELA DE GRUPOS (FILTROS E TABELA PREMIUM)
   ========================================================================= */
.filter-card {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.filter-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.app-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.app-table th {
    background-color: #FAFAFA;
    padding: 13px 20px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.78rem;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-bottom: 1.5px solid var(--border-color);
    white-space: nowrap;
}

.app-table td {
    padding: 14px 20px;
    font-size: 0.875rem;
    color: #334155;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}

.app-table tbody tr {
    transition: background-color 0.15s ease;
}

.app-table tbody tr:last-child td {
    border-bottom: none;
}

.app-table tbody tr:hover {
    background-color: #F8F8FE;
}

.empty-table-cell {
    text-align: center;
    color: #64748B;
    padding: 48px 24px !important;
}

.card-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border-soft);
    background-color: var(--color-bg-light);
}

.total-text {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
}

/* =========================================================================
   TELA DE DISPAROS / MENSAGENS (LAYOUT EM SPLIT)
   ========================================================================= */
.message-split-layout {
    display: flex;
    gap: 24px;
}

.composer-column {
    flex: 1.3;
}

.history-column {
    flex: 1.7;
}

.composer-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-help {
    font-size: 0.72rem;
    color: #94A3B8;
    margin-top: 2px;
}

.scheduler-box {
    background-color: var(--color-bg-light);
    border: 1.5px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.checkbox-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.checkbox-toggle input {
    display: none;
}

.checkbox-toggle .slider {
    width: 44px;
    height: 24px;
    background-color: #CBD5E1;
    border-radius: 99px;
    position: relative;
    transition: background-color var(--transition-fast);
}

.checkbox-toggle .slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #FFFFFF;
    left: 3px;
    top: 3px;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.checkbox-toggle input:checked + .slider {
    background-color: var(--color-violet);
}

.checkbox-toggle input:checked + .slider::before {
    transform: translateX(20px);
}

.checkbox-toggle strong {
    font-size: 0.85rem;
    color: #1E293B;
}

.schedule-fields {
    border-top: 1px dashed var(--border-color);
    padding-top: 16px;
}

/* LISTA DE HISTÓRICO DE MENSAGENS */
.history-filter-row {
    padding: 16px;
    border-bottom: 1px solid var(--border-soft);
}

.history-list-container {
    display: flex;
    flex-direction: column;
    max-height: 520px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item-dest {
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 700;
    color: #0F172A;
}

.history-item-body {
    font-size: 0.85rem;
    color: #475569;
    white-space: pre-wrap;
    background-color: var(--color-bg-light);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft);
}

.history-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    color: #94A3B8;
    font-weight: 600;
}

.history-item-error {
    color: var(--color-danger);
    background-color: var(--color-danger-light);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.78rem;
    margin-top: 4px;
}

/* =========================================================================
   TELA DE TEMPLATES (GRID DE CARDS)
   ========================================================================= */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.template-card {
    background: #FFFFFF;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    text-align: left;
    transition: all var(--transition-fast);
}

.template-card:hover {
    border-color: var(--color-violet);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.template-card h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    color: #0F172A;
}

.template-content-preview {
    font-size: 0.85rem;
    color: #64748B;
    white-space: pre-wrap;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
    background-color: var(--color-bg-light);
    padding: 10px;
    border-radius: var(--radius-sm);
}

.template-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.template-card-actions {
    display: flex;
    gap: 6px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background-color: var(--color-bg-light);
    border: 1px solid var(--border-color);
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background-color: var(--color-violet-glow);
    color: var(--color-violet);
    border-color: var(--color-violet);
}

.btn-icon.delete:hover {
    background-color: var(--color-danger-light);
    color: var(--color-danger);
    border-color: var(--color-danger);
}

.btn-icon i {
    width: 14px;
    height: 14px;
}

/* =========================================================================
   TELA DE CONFIGURAÇÕES
   ========================================================================= */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    text-align: left;
}

.status-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: left;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: var(--color-bg-light);
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-soft);
}

.status-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.account-actions {
    margin-top: 10px;
}

/* =========================================================================
   SISTEMA DE MODAIS (POP-UPS DIALOG)
   ========================================================================= */
.app-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 1, 8, 0.4);
    backdrop-filter: blur(4px);
    z-index: 10000;
    transition: opacity var(--transition-fast) ease-out;
}

.app-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #FFFFFF;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    z-index: 10001;
    overflow: hidden;
}

.modal-header {
    padding: 20px 24px 18px;
    border-bottom: 1.5px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #FFFFFF;
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: #0F172A;
    letter-spacing: -0.2px;
}

.btn-close-modal {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--color-bg-light);
    border: 1px solid var(--border-color);
    color: #64748B;
    font-size: 1.1rem;
    font-weight: 400;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-close-modal:hover {
    background: #FEE2E2;
    border-color: #FCA5A5;
    color: #EF4444;
}

.modal-body {
    padding: 24px;
}

.modal-desc {
    font-size: 0.85rem;
    color: #64748B;
    margin-bottom: 16px;
    text-align: left;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* COMPONENTES DE QR CODE SCAN */
.qrcode-scan-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
}

.qrcode-wrapper {
    background-color: #FFFFFF;
    border: 2px solid var(--border-color);
    padding: 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    width: 220px;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#qrcode-image-holder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#qrcode-image-holder img {
    max-width: 100%;
    max-height: 100%;
}

.qrcode-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-soft);
    border-top: 3px solid var(--color-violet);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.qrcode-scan-container h4 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    color: #1E293B;
    margin-top: 8px;
}

.scan-instructions {
    text-align: left;
    font-size: 0.8rem;
    color: #475569;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.scan-loading-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748B;
    background-color: var(--color-bg-light);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft);
    margin-top: 10px;
}

/* =========================================================================
   BARRA DE NAVEGAÇÃO MOBILE (BOTTOM NAV BAR)
   ========================================================================= */
.app-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    background-color: #FFFFFF;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.03);
    z-index: 999;
}

.mobile-more-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 1, 8, 0.3);
    backdrop-filter: blur(4px);
    z-index: 1000;
}

.mobile-more-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100vw;
    background-color: #FFFFFF;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 24px;
    box-shadow: 0 -10px 24px rgba(0,0,0,0.1);
    animation: slideUp var(--transition-fast) forwards;
}

.mobile-more-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.mobile-more-header h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: #0F172A;
}

.btn-close-more-overlay {
    background: none;
    border: none;
    font-size: 1.6rem;
    color: #94A3B8;
    cursor: pointer;
}

.mobile-more-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mobile-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background-color: var(--color-bg-light);
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    color: #334155;
    text-decoration: none;
}

.mobile-link i {
    width: 18px;
    height: 18px;
    color: var(--color-violet);
}

.mobile-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px;
    background-color: var(--color-danger-light);
    color: var(--color-danger);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    width: 100%;
    cursor: pointer;
}

/* =========================================================================
   MEDIA QUERIES (RESPONSIVIDADE INTELIGENTE)
   ========================================================================= */

@media (max-width: 1024px) {
    .message-split-layout {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    body {
        background-color: #FFFFFF;
    }

    .app-sidebar {
        display: none !important; /* Escondido no mobile em prol da bottom nav */
    }

    .app-header {
        height: 60px;
    }

    .header-left {
        gap: 16px;
    }

    .page-title-header {
        font-size: 1rem;
        padding-left: 10px;
    }

    .brand-logo {
        font-size: 1.5rem;
    }
    
    .app-body-container {
        margin-top: 60px;
        height: calc(100vh - 60px);
    }

    .app-main-content {
        padding: 24px 16px 100px 16px;
    }

    .page-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .page-title-row button {
        width: 100%;
    }

    .app-bottom-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
        height: 68px;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .app-bottom-nav .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: #94A3B8;
        text-decoration: none;
        flex: 1;
        height: 100%;
    }

    .app-bottom-nav .nav-item i {
        width: 20px;
        height: 20px;
    }

    .app-bottom-nav .nav-item span {
        font-size: 0.65rem;
        font-weight: 700;
    }

    .app-bottom-nav .nav-item.active {
        color: var(--color-violet);
    }

    .dashboard-columns {
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
        gap: 10px;
        border-radius: var(--radius-md);
    }
    
    .stat-icon-wrapper {
        width: 40px;
        height: 40px;
    }
    
    .stat-icon-wrapper i {
        width: 18px;
        height: 18px;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-row button {
        width: 100%;
    }

    .app-modal {
        width: 90%;
        max-width: 90%;
    }
}

/* Estilos para o avatar e fallback na lista de grupos */
.group-avatar-wrapper {
    width: 38px;
    height: 38px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.group-avatar-img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
    display: block;
}

.group-avatar-fallback {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: #FFFFFF;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    border: 2px solid #FFFFFF;
    box-shadow: var(--shadow-sm);
}

/* =========================================================================
   ESTILOS PREMIUM DE MULTI-SELEÇÃO E PREVIEW ESTILO WHATSAPP
   ========================================================================= */

/* Scrollbar para checkboxes de instâncias e grupos no composer */
.checkbox-scroll-container {
    max-height: 140px;
    overflow-y: auto;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    background-color: var(--color-bg-light);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all var(--transition-fast);
}

.checkbox-scroll-container:focus-within {
    border-color: var(--color-violet);
    background-color: #FFFFFF;
    box-shadow: 0 0 0 4px var(--color-violet-glow);
}

.checkbox-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    padding: 4px 0;
    user-select: none;
}

.checkbox-item-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-violet);
    cursor: pointer;
}

/* Simulação de celular WhatsApp no Preview */
.whatsapp-preview-card {
    background: #E5DDD5;
    background-image: url("https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png");
    background-repeat: repeat;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: 520px;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.whatsapp-preview-header {
    background-color: #075E54;
    color: #FFFFFF;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-sans);
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.whatsapp-preview-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #ECEFF1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #075E54;
    font-size: 0.8rem;
    font-weight: 700;
}

.whatsapp-preview-info {
    display: flex;
    flex-direction: column;
}

.whatsapp-preview-name {
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.whatsapp-preview-status {
    font-size: 0.65rem;
    opacity: 0.8;
}

.whatsapp-preview-body {
    flex-grow: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}

/* Balões de conversa do WhatsApp */
.whatsapp-balloon {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 7.5px;
    font-size: 0.82rem;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
    word-break: break-word;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.whatsapp-balloon.sent {
    background-color: #DCF8C6;
    align-self: flex-end;
    border-top-right-radius: 0;
}

.whatsapp-balloon-text {
    white-space: pre-wrap;
    color: #303030;
    line-height: 1.4;
}

.whatsapp-balloon-media img,
.whatsapp-balloon-media video {
    max-width: 100%;
    border-radius: 6px;
    display: block;
    margin-bottom: 4px;
}

.whatsapp-balloon-media.document-block {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #374151;
    border-left: 3px solid #EF4444;
}

/* Player de áudio simulado do WhatsApp */
.whatsapp-audio-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    min-width: 180px;
}

.whatsapp-audio-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #34D399;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.whatsapp-audio-bar {
    flex-grow: 1;
    height: 3.5px;
    background-color: #B0BEC5;
    border-radius: 2px;
    position: relative;
}

.whatsapp-audio-progress {
    width: 40%;
    height: 100%;
    background-color: #075E54;
    border-radius: 2px;
}

.whatsapp-audio-time {
    font-size: 0.68rem;
    color: #727272;
}

.whatsapp-balloon-time {
    font-size: 0.62rem;
    color: #828282;
    align-self: flex-end;
    margin-top: 1px;
}

/* Botão de remoção de bloco */
.btn-remove-block {
    position: absolute;
    top: -6px;
    left: -6px;
    background-color: #EF4444;
    color: #FFFFFF;
    border: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.whatsapp-balloon:hover .btn-remove-block {
    display: flex;
}

/* Três colunas no desktop */
@media (min-width: 1024px) {
    .message-split-layout {
        display: grid;
        grid-template-columns: 1.25fr 1fr 1.25fr;
        gap: 20px;
        align-items: start;
    }
    
    .composer-column, .preview-column, .history-column {
        flex: none;
        width: 100%;
    }
}

/* Modal Split Premium para Templates */
.app-modal.app-modal-lg {
    max-width: 820px;
    width: 95%;
    transition: max-width var(--transition-fast) ease;
}

/* Cards de Escolha de Agendamento */
.choice-card {
    border: 2px solid var(--border-color);
    background-color: var(--color-bg-light);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: all var(--transition-fast) cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 14px;
}

.choice-card:hover {
    border-color: var(--color-violet) !important;
    background-color: #FFFFFF !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.08);
}

.choice-card.active {
    border-color: var(--color-violet) !important;
    background-color: #FFFFFF !important;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.12);
}

.choice-card.active .choice-icon-wrapper {
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.25);
}

/* Responsividade do Modal Split */
@media (max-width: 768px) {
    .app-modal.app-modal-lg .modal-body {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
        padding: 16px !important;
    }
    .template-preview-column {
        display: none !important;
    }
}

/* BANNER DE EMPTY STATE / ONBOARDING PREMIUM */
.empty-state-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px dashed rgba(124, 58, 237, 0.3);
    border-radius: var(--radius-lg);
    text-align: center;
    margin: 20px 0;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast) ease-in-out;
}

.empty-state-banner:hover {
    border-color: var(--color-violet);
    background: rgba(255, 255, 255, 0.65);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.empty-state-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-violet-light), var(--color-violet));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.22);
}

.empty-state-icon i, .empty-state-icon svg {
    width: 32px;
    height: 32px;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0F172A;
    margin: 0 0 10px 0;
    font-family: var(--font-heading);
}

.empty-state-text {
    font-size: 1.05rem;
    font-weight: 500;
    color: #475569;
    margin: 0 0 24px 0;
    max-width: 420px;
    line-height: 1.5;
}

.empty-state-banner .btn {
    padding: 12px 28px;
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.2);
}


/* =========================================================================
   PWA: BANNER DE INSTALAÇÃO E BOTÃO DO HEADER
   ========================================================================= */

.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    z-index: 9999;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.08);
    animation: slideUp var(--transition-fast) forwards;
    flex-wrap: wrap;
}

.pwa-install-banner.hidden { display: none !important; }

.pwa-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.pwa-banner-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.pwa-banner-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pwa-banner-text strong {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    color: #0F172A;
}

.pwa-banner-text span {
    font-size: 0.78rem;
    color: #64748B;
    font-weight: 500;
}

.pwa-banner-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn.btn-sm {
    padding: 8px 16px;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
}

/* Botão de instalar no header desktop */
.btn-install-pwa {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: linear-gradient(135deg, var(--color-violet-light), var(--color-violet));
    color: #FFFFFF;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast) ease;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

.btn-install-pwa:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4);
}

.btn-install-pwa i { width: 15px; height: 15px; }
.btn-install-pwa.hidden { display: none !important; }

/* =========================================================================
   RESPONSIVIDADE MOBILE COMPLETA — TABELAS → CARDS
   ========================================================================= */

@media (max-width: 768px) {

    /* PWA banner: acima do bottom nav */
    .pwa-install-banner {
        bottom: 68px;
        padding: 12px 16px;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    /* No mobile o banner já cuida da instalação */
    .btn-install-pwa { display: none !important; }

    /* Padding: conteúdo não fica atrás do bottom nav */
    .app-main-content {
        padding: 20px 16px calc(100px + env(safe-area-inset-bottom)) 16px !important;
    }

    /* Containers de cards mobile */
    .mobile-card-list {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    /* ── INSTÂNCIAS ── */
    .instance-mobile-card {
        background: #FFFFFF;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 16px;
        display: flex;
        flex-direction: column;
        gap: 12px;
        box-shadow: var(--shadow-sm);
    }

    .instance-card-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    .instance-card-name {
        font-family: var(--font-heading);
        font-size: 0.95rem;
        font-weight: 700;
        color: #0F172A;
    }

    .instance-card-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }

    .instance-card-actions button {
        padding: 7px 12px;
        font-size: 0.76rem;
        border-radius: var(--radius-sm);
        flex: 1;
    }

    /* ── GRUPOS ── */
    .group-mobile-card {
        background: #FFFFFF;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 14px 16px;
        display: flex;
        align-items: center;
        gap: 12px;
        box-shadow: var(--shadow-sm);
        min-width: 0;
    }

    .group-card-info {
        display: flex;
        flex-direction: column;
        gap: 2px;
        flex: 1;
        min-width: 0;
    }

    .group-card-name {
        font-family: var(--font-heading);
        font-size: 0.88rem;
        font-weight: 700;
        color: #0F172A;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .group-card-meta {
        font-size: 0.75rem;
        color: #64748B;
        font-weight: 500;
    }

    /* ── MENSAGENS ── */
    .message-mobile-card {
        background: #FFFFFF;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 14px 16px;
        display: flex;
        flex-direction: column;
        gap: 8px;
        box-shadow: var(--shadow-sm);
    }

    .message-mobile-card-header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 8px;
    }

    .message-mobile-title {
        font-family: var(--font-heading);
        font-size: 0.9rem;
        font-weight: 700;
        color: #0F172A;
        flex: 1;
    }

    .message-mobile-meta {
        font-size: 0.75rem;
        color: #64748B;
        font-weight: 500;
    }

    .message-mobile-actions {
        display: flex;
        gap: 8px;
        margin-top: 4px;
    }

    .message-mobile-actions button {
        flex: 1;
        padding: 8px;
        font-size: 0.78rem;
        border-radius: var(--radius-sm);
        text-align: center;
    }

    /* ── DASHBOARD ── */
    .dashboard-columns { flex-direction: column !important; }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .stat-card { padding: 14px !important; }

    .dashboard-table { display: none !important; }

    .dashboard-mobile-list {
        display: flex !important;
        flex-direction: column;
        gap: 8px;
    }

    .dashboard-list-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 14px;
        background: #FFFFFF;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
    }

    .dashboard-list-icon {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--color-violet-glow);
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--color-violet);
        flex-shrink: 0;
    }

    .dashboard-list-icon i { width: 16px; height: 16px; }
    .dashboard-list-info { flex: 1; min-width: 0; }

    .dashboard-list-title {
        font-family: var(--font-heading);
        font-size: 0.85rem;
        font-weight: 700;
        color: #0F172A;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .dashboard-list-sub {
        font-size: 0.73rem;
        color: #64748B;
        margin-top: 1px;
    }

    .dashboard-list-badge { flex-shrink: 0; }

    /* ── MODAIS ── */
    .app-modal {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 88vh;
        overflow-y: auto;
    }

    .modal-header {
        position: sticky;
        top: 0;
        background: #FFFFFF;
        z-index: 1;
    }

    .modal-body { padding: 16px 20px 24px !important; }

    /* ── FILTROS ── */
    .filter-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .filter-row input,
    .filter-row select { width: 100% !important; }

    .filter-row button {
        width: 100% !important;
        justify-content: center;
    }

    /* ── FORMULÁRIOS ── */
    .form-row {
        flex-direction: column !important;
        gap: 16px !important;
    }

    /* ── WHATSAPP PREVIEW ── */
    .whatsapp-preview-card { display: none !important; }

    /* ── EMPTY STATE ── */
    .empty-state-banner { padding: 40px 20px !important; }
    .empty-state-title { font-size: 1.2rem !important; }
    .empty-state-text { font-size: 0.9rem !important; }

    /* ── TIPOGRAFIA ── */
    .page-title { font-size: 1.4rem !important; }
    .page-subtitle { font-size: 0.85rem !important; }

    /* ── iOS Safe Area ── */
    .app-bottom-nav { padding-bottom: env(safe-area-inset-bottom); }
}

/* iPhone SE e telas muito pequenas */
@media (max-width: 390px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    .stat-card {
        padding: 12px !important;
        gap: 8px !important;
    }

    .stat-value { font-size: 1.1rem !important; }
    .stat-label { font-size: 0.7rem !important; }

    .pwa-install-banner {
        flex-direction: column;
        align-items: flex-start;
    }

    .pwa-banner-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
