/**
 * ESTILOS VISUALES — NEXUSWPP DASHBOARD
 * Inspirado en la interfaz de Cloudflare (dash.cloudflare.com)
 * Paleta: Grafito Oscuro (#0c0d14), Acentos Cloudflare Orange (#f38020), Verde Esmeralda (#10b981)
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    color-scheme: dark;
    --bg-page: #0c0d12;
    --bg-sidebar: #11131a;
    --bg-card: #161922;
    --bg-card-hover: #1c202c;
    --bg-input: #1a1e29;
    --border-color: #262a38;
    --border-light: #32384a;
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --cf-orange: #f38020;
    --cf-orange-hover: #fa8f3d;
    --cf-orange-subtle: rgba(243, 128, 32, 0.12);
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --info: #3b82f6;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.015em;
    height: 100vh;
    overflow: hidden;
}

h1, h2, h3, h4, .page-title, .card-title, .modal-title, .brand-logo {
    letter-spacing: -0.025em;
}

/* =====================================================================
   HEADER & TOPBAR (ESTILO CLOUDFLARE)
   ===================================================================== */
.topbar {
    height: 56px;
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 50;
    position: relative;
}

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

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.brand-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--cf-orange), #ff4500);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    box-shadow: 0 0 12px rgba(243, 128, 32, 0.4);
}

.tenant-selector-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    gap: 8px;
}

.tenant-selector-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.tenant-select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    color-scheme: dark;
}

select,
.tenant-select,
.form-control {
    color-scheme: dark;
}

select option,
.tenant-select option,
.form-control option {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    padding: 10px 14px;
    font-size: 0.85rem;
}

select option:checked,
.tenant-select option:checked,
.form-control option:checked {
    background-color: #242b3b !important;
    color: var(--cf-orange) !important;
    font-weight: 600;
}

.topbar-center {
    flex: 1;
    max-width: 480px;
    margin: 0 24px;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 7px 12px 7px 34px;
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--cf-orange);
    background: var(--bg-input);
}

.search-box svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 15px;
    height: 15px;
}

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

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 9999px;
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.admin-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--cf-orange);
    background: var(--cf-orange-subtle);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(243, 128, 32, 0.3);
}

/* Minimalist Status Indicator */
.status-micro {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.76rem;
    font-weight: 500;
    white-space: nowrap;
}
.status-micro.offline { color: #64748b; }
.status-micro.online { color: #10b981; }
.status-micro.warning { color: #f59e0b; }

.micro-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.micro-dot.offline { background: #475569; }
.micro-dot.online { background: #10b981; box-shadow: 0 0 6px #10b981; }
.micro-dot.warning { background: #f59e0b; }

/* Indicador ultracompacto para tabla maestra (reemplaza texto Conectado/Desconectado para ahorrar espacio) */
.table-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    vertical-align: middle;
    cursor: help;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.table-status-dot.online {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
    animation: pulse-dot-online 2.2s infinite ease-in-out;
}
.table-status-dot.offline {
    background: #64748b;
    box-shadow: 0 0 2px rgba(100, 116, 139, 0.3);
}
.table-status-dot.warning {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
    animation: pulse-dot-warning 1.6s infinite ease-in-out;
}
@keyframes pulse-dot-online {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.22); opacity: 0.85; box-shadow: 0 0 12px rgba(16, 185, 129, 0.9); }
}
@keyframes pulse-dot-warning {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.18); opacity: 0.75; }
}

/* Botón de acción compacto para la tabla */
.btn-table-action {
    background: rgba(243, 128, 32, 0.08);
    border: 1px solid rgba(243, 128, 32, 0.3);
    color: var(--cf-orange);
    padding: 4px 10px;
    font-size: 0.74rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-table-action:hover {
    background: var(--cf-orange);
    color: #ffffff;
    border-color: var(--cf-orange);
    box-shadow: 0 0 10px rgba(243, 128, 32, 0.35);
}

/* Badges de Módulo y Acción en Tabla */
.action-flow-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.74rem;
    font-weight: 600;
    white-space: nowrap;
}
.action-flow-badge.citas {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.action-flow-badge.catalogo {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.action-flow-badge.delivery {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.action-flow-badge.transferir {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.action-flow-badge.submenu {
    background: rgba(168, 85, 247, 0.12);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
}
.action-flow-badge.texto {
    background: rgba(148, 163, 184, 0.12);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Modal Amplio para el Diseñador de Flujos */
.modal-window.modal-wide {
    max-width: 820px;
}

/* Tarjeta contenedora de Etapas / Pipeline */
.pipeline-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0;
}
.pipeline-step-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    transition: all 0.2s ease;
    position: relative;
}
.pipeline-step-card:hover {
    border-color: rgba(243, 128, 32, 0.3);
    background: rgba(255, 255, 255, 0.03);
}
.pipeline-step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.pipeline-step-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-primary);
}
.pipeline-step-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 10px;
}

.table-plan-select {
    min-width: 140px;
    width: 140px;
    padding: 4px 8px;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* Indicador de Negocio Activo en el Topbar (Sin dropdown invasivo) */
.active-business-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    font-size: 0.84rem;
}
.business-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cf-orange);
    box-shadow: 0 0 8px rgba(243, 128, 32, 0.6);
}
.business-label {
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 500;
}
.business-name {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.86rem;
}

/* Indicador Minimalista Online/Offline para la Tabla */
.badge-dot-minimal {
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.badge-dot-minimal.offline { color: #64748b; }
.badge-dot-minimal.online { color: #10b981; }
.badge-dot-minimal.warning { color: #f59e0b; }

/* =====================================================================
   ESTILOS DE AGENDA DIARIA POR FRANJAS HORARIAS (ESTILO CLÍNICA)
   ===================================================================== */
.agenda-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-bottom: 20px;
}

.agenda-date-picker-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.agenda-logo-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agenda-business-logo-img {
    max-height: 40px;
    max-width: 140px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: white;
    padding: 3px 8px;
}

.slot-available {
    background: transparent;
}
.slot-available:hover {
    background: rgba(255, 255, 255, 0.02);
}

.slot-occupied {
    background: rgba(243, 128, 32, 0.03);
}

.slot-time-badge {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-primary);
}

.slot-free-text {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.btn-slot-agendar {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
    padding: 3px 9px;
    font-size: 0.74rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.btn-slot-agendar:hover {
    background: var(--success);
    color: white;
}

.btn-slot-ingreso {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: var(--warning);
    padding: 3px 9px;
    font-size: 0.74rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.btn-slot-ingreso:hover {
    background: var(--warning);
    color: #111;
}

.btn-slot-fin {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: var(--success);
    padding: 3px 9px;
    font-size: 0.74rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}
.btn-slot-fin:hover {
    background: var(--success);
    color: white;
}

.badge-disponible {
    background: rgba(16, 185, 129, 0.08);
    color: #10b981;
    font-size: 0.70rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-cupo-libre {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
}

.badge-cupo-parcial {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
}

.badge-cupo-lleno {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
}

.badge-cupo-receso {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(245, 158, 11, 0.08);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* =====================================================================
   MAIN APP LAYOUT (SIDEBAR + CONTENT)
   ===================================================================== */
.app-container {
    display: flex;
    height: calc(100vh - 56px);
}

/* SIDEBAR IZQUIERDA */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.nav-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 10px 6px;
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--cf-orange-subtle);
    color: var(--cf-orange);
    font-weight: 600;
    border-left: 3px solid var(--cf-orange);
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* CONTENIDO PRINCIPAL */
.main-stage {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-page);
    padding: 24px 32px;
}

.view-panel {
    display: none;
    animation: fadeIn 0.15s ease-out;
}

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

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

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* =====================================================================
   CARDS & GRID SYSTEM
   ===================================================================== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

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

@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

.telemetry-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.telemetry-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--cf-orange), transparent);
}

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

.telemetry-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

.telemetry-badge {
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(243, 128, 32, 0.15);
    color: var(--cf-orange);
    font-weight: 600;
}

.telemetry-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
}

.telemetry-subtext {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.card:hover {
    border-color: var(--border-light);
}

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

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* BOTONES Y FORMULARIOS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--cf-orange-hover);
    box-shadow: 0 0 12px rgba(243, 128, 32, 0.4);
}

.btn-secondary {
    background: var(--bg-card-hover);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #252a3a;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-control {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--cf-orange);
    background: #1e2330;
}

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

/* =====================================================================
   TABLAS ESTILO CLOUDFLARE
   ===================================================================== */
.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

/* =====================================================================
   SIMULADOR WHATSAPP MÓVIL SANDBOX
   ===================================================================== */
.simulator-layout {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.phone-mockup {
    width: 380px;
    height: 640px;
    background: #000;
    border-radius: 40px;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 0 10px #242938;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    flex-shrink: 0;
}

.phone-notch {
    height: 24px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notch-pill {
    width: 90px;
    height: 12px;
    background: #181818;
    border-radius: 8px;
}

.phone-header {
    background: #1f2c34;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #2a3942;
}

.phone-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cf-orange), #ff4500);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
}

.phone-contact-info {
    flex: 1;
}

.phone-contact-name {
    color: #e9edef;
    font-size: 0.9rem;
    font-weight: 600;
}

.phone-contact-status {
    color: #8696a0;
    font-size: 0.72rem;
}

.phone-body {
    flex: 1;
    background-color: #0b141a;
    background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 16px 16px;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-bubble {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.84rem;
    line-height: 1.4;
    position: relative;
    word-break: break-word;
    white-space: pre-wrap;
}

.bubble-in {
    background: #202c33;
    color: #e9edef;
    align-self: flex-start;
    border-top-left-radius: 2px;
}

.bubble-out {
    background: #005c4b;
    color: #e9edef;
    align-self: flex-end;
    border-top-right-radius: 2px;
}

.bubble-time {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    text-align: right;
    margin-top: 4px;
}

.phone-footer {
    background: #1f2c34;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.phone-input {
    flex: 1;
    background: #2a3942;
    border: none;
    border-radius: 20px;
    padding: 8px 14px;
    color: #e9edef;
    font-size: 0.85rem;
    outline: none;
}

.phone-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #00a884;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.phone-send-btn:hover {
    background: #06cf9c;
}

.sim-inspector {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.log-terminal {
    background: #090a0f;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: #10b981;
    height: 220px;
    overflow-y: auto;
    white-space: pre-wrap;
}

/* =====================================================================
   QR CARD Y VINCULACIÓN
   ===================================================================== */
.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    text-align: center;
}

.qr-frame {
    background: white;
    padding: 12px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-bottom: 16px;
    width: 260px;
    height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-frame img {
    max-width: 100%;
    height: auto;
    display: block;
}

.pairing-box {
    background: var(--bg-input);
    border: 1px dashed var(--cf-orange);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--cf-orange);
    letter-spacing: 0.15em;
    margin-top: 10px;
}

/* =====================================================================
   MODAL DIALOGS & VARIABLE CHIPS (CLOUDFLARE STYLE)
   ===================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 5, 8, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-window {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 1px 1px rgba(255, 255, 255, 0.05);
    width: 100%;
    max-width: 660px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    background: rgba(0, 0, 0, 0.15);
}

/* CHIPS DE VARIABLES DINÁMICAS */
.chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    margin-bottom: 12px;
}

.variable-chip {
    background: rgba(243, 128, 32, 0.1);
    color: var(--cf-orange);
    border: 1px solid rgba(243, 128, 32, 0.3);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.variable-chip:hover {
    background: var(--cf-orange);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(243, 128, 32, 0.3);
}

/* PREVIEW ESTILO WHATSAPP EN TIEMPO REAL */
.live-preview-box {
    background: #0b141a;
    border: 1px solid #202c33;
    border-radius: var(--radius-md);
    padding: 14px;
    position: relative;
    margin-top: 4px;
}

.live-preview-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8696a0;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-preview-bubble {
    background: #202c33;
    color: #e9edef;
    padding: 10px 14px;
    border-radius: 8px;
    border-top-left-radius: 0;
    font-size: 0.85rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.emoji-badge {
    font-size: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.menu-greeting-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    margin-top: 16px;
}

@media (max-width: 900px) {
    .menu-greeting-grid {
        grid-template-columns: 1fr;
    }
}

.preview-time-stamp {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    font-size: 0.68rem;
    color: #8696a0;
    margin-top: 8px;
    user-select: none;
}

/* ESTILOS CARD COLAPSABLE */
.collapsible-card {
    transition: all 0.25s ease;
}

.collapsible-card-header {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
    border-radius: var(--radius-sm);
    padding: 2px 4px;
}

.collapsible-card-header:hover {
    background: rgba(255, 255, 255, 0.015);
}

.collapsible-content {
    transition: all 0.3s ease;
}

.collapsible-content.collapsed {
    display: none;
}

/* VARIABLES DINÁMICAS EN PIPELINE */
.pipeline-var-card {
    transition: all 0.2s ease;
}
.pipeline-var-card:hover {
    background: rgba(255, 255, 255, 0.045) !important;
    border-color: rgba(243, 128, 32, 0.35) !important;
}

