/**
 * ONA Club - Estilos del Panel de Administracion
 */

/* === Layout Admin === */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-darker);
    border-right: 1px solid var(--border-color);
    padding: var(--space-lg);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: var(--z-navbar);
    transition: transform var(--transition-base);
}

.admin-sidebar.collapsed {
    transform: translateX(-100%);
}

.admin-sidebar__logo {
    font-family: var(--font-heading);
    font-size: var(--font-size-xl);
    color: var(--color-primary);
    margin-bottom: var(--space-xs);
}

.admin-sidebar__subtitle {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    letter-spacing: var(--letter-spacing-wider);
    text-transform: uppercase;
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.admin-nav__section {
    margin-bottom: var(--space-lg);
}

.admin-nav__section-title {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wider);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-sm);
    padding-left: var(--space-sm);
}

.admin-nav__item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px var(--space-sm);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
    margin-bottom: 2px;
}

.admin-nav__item:hover {
    background: rgba(var(--color-primary-rgb), 0.05);
    color: var(--text-primary);
}

.admin-nav__item.active {
    background: rgba(var(--color-primary-rgb), 0.08);
    color: var(--color-primary);
}

.admin-nav__item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.admin-nav__badge {
    margin-left: auto;
    background: var(--color-error);
    color: white;
    font-size: 0.625rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: var(--font-weight-bold);
}

/* === Contenido Admin === */
.admin-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-xl);
    min-height: 100vh;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
}

.admin-header__title {
    font-family: var(--font-heading);
    font-size: var(--font-size-2xl);
    color: var(--text-heading);
}

.admin-header__subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* === Dashboard Stats === */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.admin-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
}

.admin-stat-card__icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.admin-stat-card__icon--gold {
    background: rgba(var(--color-primary-rgb), 0.10);
    color: var(--color-primary);
}

.admin-stat-card__icon--green {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.admin-stat-card__icon--blue {
    background: var(--color-info-bg);
    color: var(--color-info);
}

.admin-stat-card__icon--red {
    background: var(--color-error-bg);
    color: var(--color-error);
}

.admin-stat-card__value {
    font-family: var(--font-heading);
    font-size: var(--font-size-2xl);
    color: var(--text-heading);
    font-weight: var(--font-weight-bold);
}

.admin-stat-card__label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wider);
    margin-top: 2px;
}

.admin-stat-card__trend {
    font-size: var(--font-size-xs);
    margin-top: var(--space-xs);
    display: flex;
    align-items: center;
    gap: 4px;
}

.admin-stat-card__trend--up {
    color: var(--color-success);
}

.admin-stat-card__trend--down {
    color: var(--color-error);
}

/* === Tabla Admin === */
.admin-table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
}

.admin-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.admin-table-header__search {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    text-align: left;
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wider);
    font-weight: var(--font-weight-semibold);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.admin-table td {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

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

.admin-table tr:hover td {
    background: rgba(var(--color-primary-rgb), 0.02);
}

.admin-table-actions {
    display: flex;
    gap: var(--space-xs);
}

/* === Admin Form Panel === */
.admin-form-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
}

.admin-form-panel__title {
    font-family: var(--font-heading);
    font-size: var(--font-size-lg);
    color: var(--text-heading);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-lg);
}

/* === Scanner QR Admin === */
.scanner-container {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.scanner-viewport {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-darker);
    border-radius: var(--border-radius-xl);
    border: 2px solid var(--color-primary);
    overflow: hidden;
    position: relative;
    margin-bottom: var(--space-lg);
}

.scanner-viewport video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-viewport__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-viewport__frame {
    width: 200px;
    height: 200px;
    border: 2px solid var(--color-primary);
    border-radius: var(--border-radius);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

.scanner-result {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: var(--space-xl);
    text-align: left;
}

.scanner-result__header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.scanner-result__info {
    display: grid;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.scanner-result__row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--font-size-sm);
}

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

.scanner-result__value {
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
}

.scanner-result__actions {
    display: flex;
    gap: var(--space-sm);
}

/* === Chart placeholder === */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    min-height: 300px;
}

.chart-container__title {
    font-family: var(--font-heading);
    font-size: var(--font-size-lg);
    color: var(--text-heading);
    margin-bottom: var(--space-md);
}

/* === Admin toggle sidebar (mobile) === */
.admin-toggle-sidebar {
    display: none;
    position: fixed;
    top: var(--space-md);
    left: var(--space-md);
    z-index: calc(var(--z-navbar) + 1);
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* === Admin Section Title === */
.admin-section-title {
    font-family: var(--font-heading);
    font-size: var(--font-size-xl);
    color: var(--text-heading);
    margin-bottom: var(--space-lg);
}

/* === Gallery Grid === */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-md);
}

/* === Stats Grid (dashboard) === */
.stats-grid {
    display: grid;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    text-align: center;
}

.stat-card__value {
    font-family: var(--font-heading);
    font-size: var(--font-size-2xl);
    color: var(--text-heading);
    font-weight: var(--font-weight-bold);
}

.stat-card__label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wider);
    margin-top: var(--space-xs);
}

/* === List Item === */
.list-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-light);
}

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

.list-item__body {
    flex: 1;
    min-width: 0;
}

.list-item__title {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

/* === Toggle Switch === */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle__slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-input);
    transition: var(--transition-base);
    border-radius: 24px;
    border: 1px solid var(--border-color);
}

.toggle__slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: var(--transition-base);
    border-radius: 50%;
}

.toggle input:checked + .toggle__slider {
    background-color: rgba(var(--color-primary-rgb), 0.15);
    border-color: var(--color-primary);
}

.toggle input:checked + .toggle__slider:before {
    background-color: var(--color-primary);
    transform: translateX(20px);
}

/* === Settings Row === */
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--font-size-sm);
}

.settings-row:last-child {
    border-bottom: none;
}

/* === QR Display === */
.qr-display {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: var(--space-xl);
    text-align: center;
    margin-bottom: var(--space-lg);
}

.qr-display__label {
    font-family: var(--font-heading);
    font-size: var(--font-size-lg);
    color: var(--text-heading);
    margin-bottom: var(--space-md);
}

.qr-display__code {
    display: inline-block;
    padding: var(--space-md);
    background: var(--bg-darker);
    border-radius: var(--border-radius);
    margin-bottom: var(--space-md);
}

.qr-display__text {
    font-family: var(--font-mono);
    font-size: var(--font-size-lg);
    color: var(--color-primary);
    letter-spacing: var(--letter-spacing-wider);
    margin-bottom: var(--space-sm);
}

/* === Policy Popup === */
.policy-popup ul {
    margin: 0;
    padding-left: var(--space-lg);
}

.policy-popup li {
    margin-bottom: var(--space-xs);
}

/* === Modal Actions === */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-light);
}

/* === Admin Overlay for mobile sidebar === */
.admin-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: calc(var(--z-navbar) - 1);
}

.admin-sidebar.open ~ .admin-sidebar-overlay {
    display: block;
}

/* === WhatsApp Admin Panel === */
.wa-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: var(--space-lg);
    background: var(--bg-darker);
    border-radius: var(--border-radius-lg);
    padding: 3px;
    overflow-x: auto;
}

.wa-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 10px var(--space-md);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.wa-tab:hover { color: var(--text-primary); background: rgba(var(--color-primary-rgb), 0.04); }
.wa-tab--active { background: var(--bg-card); color: var(--color-primary); box-shadow: var(--shadow-sm); font-weight: var(--font-weight-semibold); }

/* Inbox Layout */
.wa-inbox {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 1px;
    background: var(--border-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    min-height: 500px;
}

.wa-inbox__list {
    background: var(--bg-card);
    overflow-y: auto;
    max-height: 600px;
}

.wa-inbox__thread {
    background: var(--bg-base, var(--bg-body, #f5f5f5));
    display: flex;
    flex-direction: column;
}

/* Conversation List Item */
.wa-conv-item {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
}

.wa-conv-item:hover { background: rgba(var(--color-primary-rgb), 0.03); }
.wa-conv-item--active { background: rgba(var(--color-primary-rgb), 0.06); border-left: 3px solid var(--color-primary); }

.wa-conv-item__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-darker);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-weight: var(--font-weight-semibold);
    flex-shrink: 0;
    overflow: hidden;
}

.wa-conv-item__body { flex: 1; min-width: 0; }
.wa-conv-item__top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.wa-conv-item__name { font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.wa-conv-item__time { font-size: 0.65rem; color: var(--text-muted); white-space: nowrap; }
.wa-conv-item__bottom { display: flex; justify-content: space-between; align-items: center; }
.wa-conv-item__preview { font-size: var(--font-size-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.wa-conv-item__badges { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.wa-badge-unread {
    background: var(--color-primary);
    color: var(--bg-darker);
    font-size: 0.6rem;
    font-weight: var(--font-weight-bold);
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.wa-window-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-muted); opacity: 0.4;
}
.wa-window-dot--active { background: #25d366; opacity: 1; }

/* Thread */
.wa-thread { display: flex; flex-direction: column; height: 100%; min-height: 500px; }
.wa-thread-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 300px; }

.wa-thread__header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}
.wa-thread__back { display: none; }
.wa-thread__user { flex: 1; }
.wa-thread__user strong { display: block; font-size: var(--font-size-sm); color: var(--text-heading); }

.wa-thread__messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.wa-thread__input {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    align-items: flex-end;
}

.wa-thread__textarea {
    flex: 1;
    max-height: 100px;
    resize: none;
}

/* Chat Bubbles */
.wa-bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: var(--font-size-sm);
    line-height: 1.4;
    position: relative;
}

.wa-bubble--out {
    align-self: flex-end;
    background: rgba(var(--color-primary-rgb), 0.10);
    border-bottom-right-radius: 4px;
    color: var(--text-primary);
}

.wa-bubble--in {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}

.wa-bubble__text { word-break: break-word; }
.wa-bubble__meta { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 4px; }
.wa-bubble__tpl { font-size: 0.6rem; color: var(--text-muted); background: var(--bg-darker); padding: 1px 5px; border-radius: 3px; }
.wa-bubble__time { font-size: 0.6rem; color: var(--text-muted); }

/* Status indicators */
.wa-status { font-size: 0.7rem; }
.wa-status--sent { color: var(--text-muted); }
.wa-status--delivered { color: var(--text-muted); }
.wa-status--read { color: #53bdeb; }
.wa-status--failed { color: var(--color-error); }
.wa-status--pending { font-size: 0.6rem; }

/* Broadcast preview */
.wa-preview-box {
    background: var(--bg-elevated, var(--bg-darker));
    padding: var(--space-md);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    white-space: pre-wrap;
    border-left: 3px solid var(--color-primary);
}

/* Responsive */
@media (max-width: 767px) {
    .wa-inbox { grid-template-columns: 1fr; min-height: auto; }
    .wa-inbox__list { max-height: 300px; }
    .wa-inbox__thread { min-height: 400px; }
    .wa-thread__back { display: flex; }
    .wa-tab { padding: 8px var(--space-sm); font-size: var(--font-size-xs); }
    .wa-conv-item__name { max-width: 120px; }
    .wa-conv-item__preview { max-width: 140px; }
}

/* === Admin responsive tables (card layout on mobile) === */
@media (max-width: 767px) {
    .admin-table thead {
        display: none;
    }
    
    .admin-table, .admin-table tbody, .admin-table tr, .admin-table td {
        display: block;
    }
    
    .admin-table tr {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        padding: var(--space-md);
        margin-bottom: var(--space-sm);
    }
    
    .admin-table td {
        padding: var(--space-xs) 0;
        border-bottom: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .admin-table td::before {
        content: attr(data-label);
        font-size: var(--font-size-xs);
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: var(--letter-spacing-wider);
        font-weight: var(--font-weight-semibold);
        margin-right: var(--space-md);
    }

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

    /* Scanner layout: stack columns on mobile */
    .scanner-layout {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 575px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   WhatsApp Template Editor — Estilo Meta 2026
   ═══════════════════════════════════════════════════════════ */

/* Filter tabs */
.wa-filter-btn {
    background: none; border: none; cursor: pointer; padding: 10px 14px;
    font-size: var(--font-size-sm); color: var(--text-muted);
    border-bottom: 2px solid transparent; transition: all 0.2s;
    display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.wa-filter-btn:hover { color: var(--text-primary); }
.wa-filter-btn--active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: var(--font-weight-medium); }
.wa-filter-count { background: var(--bg-secondary); border-radius: 10px; padding: 1px 7px; font-size: 0.7rem; }
.wa-filter-btn--active .wa-filter-count { background: rgba(var(--color-primary-rgb), 0.12); color: var(--color-primary); }

/* Template list card */
.wa-tpl-card {
    display: flex; align-items: center; padding: 14px var(--space-lg);
    border-bottom: 1px solid var(--border-color); cursor: pointer;
    transition: background 0.15s;
}
.wa-tpl-card:hover { background: rgba(var(--color-primary-rgb), 0.03); }
.wa-tpl-card:last-child { border-bottom: none; }
.wa-tpl-card__left { flex: 1; min-width: 0; }
.wa-tpl-card__right { flex-shrink: 0; color: var(--text-muted); margin-left: var(--space-md); }
.wa-tpl-card__name { font-weight: var(--font-weight-semibold); color: var(--text-heading); margin-bottom: 2px; display: flex; align-items: center; }
.wa-tpl-card__meta-name { margin-bottom: 4px; }
.wa-tpl-card__meta-name code { font-size: 0.7rem; background: var(--bg-secondary); padding: 1px 5px; border-radius: 3px; }
.wa-tpl-card__preview { color: var(--text-muted); font-size: var(--font-size-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 500px; margin-bottom: 6px; }
.wa-tpl-card__tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Badge small */
.badge--sm { font-size: 0.65rem; padding: 1px 6px; }

/* Editor layout */
.wa-editor { display: grid; grid-template-columns: 1fr 320px; gap: var(--space-xl); max-height: 75vh; overflow-y: auto; }
.wa-editor__form { overflow-y: auto; padding-right: var(--space-md); }
.wa-editor__preview { position: sticky; top: 0; }
.wa-editor__preview-label { font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: var(--space-sm); font-weight: var(--font-weight-semibold); }

/* Editor sections */
.wa-editor-section { margin-bottom: var(--space-lg); padding-bottom: var(--space-lg); border-bottom: 1px solid var(--border-color); }
.wa-editor-section:last-of-type { border-bottom: none; }
.wa-editor-section__title { font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); color: var(--text-heading); margin-bottom: var(--space-sm); }

/* Phone preview */
.wa-phone-preview {
    background: #e5ddd5; border-radius: 16px; padding: 24px 12px;
    min-height: 340px; display: flex; flex-direction: column; justify-content: flex-end;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ccc4b8' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    box-shadow: inset 0 0 20px rgba(0,0,0,0.05);
}
.wa-phone-preview__screen { width: 100%; }
.wa-preview-bubble {
    background: #fff; border-radius: 0 8px 8px 8px; padding: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.12); overflow: hidden;
    max-width: 280px;
}
.wa-preview-header--text { padding: 10px 12px 0; font-size: 14px; }
.wa-preview-header--media {
    background: #f0f0f0; padding: 20px 12px; text-align: center;
    color: var(--text-muted); font-size: 13px; display: flex;
    align-items: center; justify-content: center; gap: 6px; min-height: 80px;
}
.wa-preview-body { padding: 10px 12px; font-size: 13.5px; line-height: 1.45; color: #111b21; word-break: break-word; }
.wa-preview-footer { padding: 0 12px 8px; font-size: 12px; color: #8696a0; }

/* Preview buttons */
.wa-preview-buttons { margin-top: 4px; display: flex; flex-direction: column; gap: 1px; max-width: 280px; }
.wa-preview-btn {
    background: #fff; text-align: center; padding: 8px; font-size: 13px;
    color: #00a884; font-weight: 500; border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08); cursor: default;
}

/* Button editor items */
.wa-btn-item { padding: 8px 0; border-bottom: 1px solid var(--border-color); }
.wa-btn-item:last-child { border-bottom: none; }

.mt-xs { margin-top: 4px; }

/* Modal wider for editor */
.modal:has(.wa-editor) { max-width: 900px; width: 95vw; }

@media (max-width: 768px) {
    .wa-editor { grid-template-columns: 1fr; max-height: 85vh; }
    .wa-editor__preview { position: relative; order: -1; }
    .wa-phone-preview { min-height: 200px; }
    .wa-tpl-card__preview { max-width: 250px; }
}

/* ═══════════════════════════════════════════════════════════
   Variable Type Editor — Tipos de variables para Meta
   ═══════════════════════════════════════════════════════════ */
.var-type-grid {
    display: grid; grid-template-columns: 1fr 120px 1fr auto; gap: var(--space-xs);
    align-items: center; margin-bottom: var(--space-xs);
}
.var-type-grid .form-input--sm { padding: 4px 8px; font-size: var(--font-size-xs); }
.var-type-label { font-size: var(--font-size-xs); color: var(--text-muted); font-weight: var(--font-weight-medium); }
.var-type-badge {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 0.65rem; padding: 2px 6px; border-radius: 4px;
    background: var(--bg-secondary); color: var(--text-muted);
}
.var-type-badge--text { color: #2563eb; background: rgba(37, 99, 235, 0.08); }
.var-type-badge--number { color: #7c3aed; background: rgba(124, 58, 237, 0.08); }
.var-type-badge--date { color: #0d9488; background: rgba(13, 148, 136, 0.08); }
.var-type-badge--time { color: #d97706; background: rgba(217, 119, 6, 0.08); }
.var-type-badge--url { color: #dc2626; background: rgba(220, 38, 38, 0.08); }
.var-type-badge--currency { color: #059669; background: rgba(5, 150, 105, 0.08); }

/* ═══════════════════════════════════════════════════════════
   Automation Flows — Flujos automáticos
   ═══════════════════════════════════════════════════════════ */
.flow-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: var(--space-md);
}

.flow-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.flow-card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(var(--color-primary-rgb), 0.3);
}
.flow-card--disabled {
    opacity: 0.55;
}
.flow-card--disabled:hover {
    opacity: 0.7;
}

.flow-card__header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}
.flow-card__title-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: var(--space-xs);
}
.flow-card__name {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-heading);
    margin: 0;
}
.flow-card__trigger {
    display: flex; align-items: center; gap: 4px;
    font-size: var(--font-size-xs);
    color: var(--color-primary);
    font-weight: var(--font-weight-medium);
}
.flow-card__desc {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin: var(--space-xs) 0 0;
    line-height: 1.4;
}

/* Status badges */
.flow-card__status {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.flow-status--active {
    background: rgba(var(--color-success-rgb, 16, 185, 129), 0.12);
    color: var(--color-success);
}
.flow-status--inactive {
    background: var(--bg-secondary);
    color: var(--text-muted);
}
.flow-status--warning {
    background: rgba(var(--color-warning-rgb, 245, 158, 11), 0.12);
    color: var(--color-warning);
}

/* Channel rows */
.flow-card__channels {
    padding: var(--space-sm) var(--space-lg);
}
.flow-channel {
    display: flex; align-items: center; gap: var(--space-sm);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid rgba(var(--border-color-rgb, 200, 200, 200), 0.3);
}
.flow-channel:last-child { border-bottom: none; }

.flow-channel__icon {
    flex-shrink: 0; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-muted);
    transition: all 0.2s;
}
.flow-channel--active .flow-channel__icon {
    background: rgba(var(--color-primary-rgb), 0.08);
    color: var(--color-primary);
}
.flow-channel--inactive { opacity: 0.5; }

.flow-channel__info { flex: 1; min-width: 0; }
.flow-channel__label {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--text-heading);
    display: block;
}
.flow-channel__detail {
    font-size: 0.7rem; color: var(--text-muted);
    display: flex; align-items: center; gap: 4px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.flow-channel__detail code {
    font-size: 0.65rem; background: var(--bg-secondary);
    padding: 1px 4px; border-radius: 3px;
}
.flow-channel__toggle { flex-shrink: 0; }

/* Toggle switch */
.flow-toggle {
    position: relative; display: inline-block;
    width: 36px; height: 20px;
}
.flow-toggle input { opacity: 0; width: 0; height: 0; }
.flow-toggle__slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-tertiary, #ccc);
    border-radius: 20px;
    transition: 0.3s;
}
.flow-toggle__slider:before {
    content: "";
    position: absolute; height: 16px; width: 16px;
    left: 2px; bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.flow-toggle input:checked + .flow-toggle__slider {
    background-color: var(--color-primary);
}
.flow-toggle input:checked + .flow-toggle__slider:before {
    transform: translateX(16px);
}

/* Stats row */
.flow-card__stats {
    display: flex; gap: var(--space-md);
    padding: var(--space-xs) var(--space-lg);
    background: var(--bg-secondary);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Actions */
.flow-card__actions {
    display: flex; gap: var(--space-xs);
    padding: var(--space-sm) var(--space-lg);
    border-top: 1px solid var(--border-color);
}

/* Edit sections */
.flow-edit-section {
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

/* Badge extra small */
.badge--xs {
    font-size: 0.6rem;
    padding: 1px 4px;
    border-radius: 3px;
}

@media (max-width: 768px) {
    .flow-cards { grid-template-columns: 1fr; }
    .flow-card__channels { padding: var(--space-sm); }
    .flow-card__actions { flex-wrap: wrap; }
}

