/* Reset y Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1877F2;
    --primary-dark: #166fe5;
    --primary-light: #E7F3FF;
    --danger: #EF4444;
    --warning: #F59E0B;
    --bg: #F9FAFB;
    --surface: #FFFFFF;
    --text: #111827;
    --text-secondary: #6B7280;
    --border: #E5E7EB;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    --radius: 8px;
    --radius-lg: 12px;
}

/* Modo Oscuro - detecta preferencia del sistema */
@media (prefers-color-scheme: dark) {
    :root {
        --primary: #1877F2;
        --primary-dark: #166fe5;
        --primary-light: rgba(24, 119, 242, 0.2);
        --danger: #EF4444;
        --warning: #F59E0B;
        --bg: #121213;
        --surface: #1D1E24;
        --text: #F9FAFB;
        --text-secondary: #9CA3AF;
        --border: #2D2E33;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
        --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    }

    /* Ajustes específicos para modo oscuro */
    .input-field {
        background: var(--surface);
        color: var(--text);
    }

    .variable-input {
        background: var(--surface);
        color: var(--text);
    }

    .broadcast-card {
        background: var(--surface);
    }

    .card {
        background: var(--surface);
    }

    .campaign-item {
        background: var(--surface);
    }

    .campaign-item:hover {
        background: var(--bg);
    }

    .whatsapp-preview-container {
        background: #0A0A0B;
    }

    .whatsapp-message {
        background: #1D1E24;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    }

    .message-content {
        color: #F9FAFB;
    }

    .template-preview-box .preview-inbox,
    .template-body,
    .variable-item,
    .variable-select,
    .variable-field-select,
    .variable-custom-input,
    .variable-input,
    .whatsapp-btn,
    .dropdown-options,
    .tag-dropdown,
    .variable-dropdown {
        background: var(--surface);
    }

    .whatsapp-btn {
        background: #1D1E24;
        border-color: #2D2E33;
        color: #1877F2;
    }

    .whatsapp-btn:hover {
        background: #2D2E33;
    }

    .btn-config-footer {
        color: #6B7280;
    }

    .btn-config-footer:hover {
        color: #9CA3AF;
    }

    .recipients-preview {
        background: #121213;
    }

    .preview-box {
        background: #121213;
    }

    .modal-content {
        background: var(--surface);
    }

    .toast {
        background: #2D2E33;
    }

    .toast.error {
        background: #7F1D1D;
        color: #FECACA;
    }

    .toast.success {
        background: #064E3B;
        color: #A7F3D0;
    }

    .toast.warning {
        background: #78350F;
        color: #FDE68A;
    }

    .toast.info {
        background: #1E3A8A;
        color: #BFDBFE;
    }

    .dropdown-options {
        background: var(--surface);
        border-color: var(--border);
    }

    .dropdown-option:hover {
        background: #2D2E33;
    }

    .variable-input-row {
        border-color: var(--border);
    }

    /* Buscador del dropdown en modo oscuro */
    .dropdown-search {
        background: #1D1E24;
        border-bottom-color: #2D2E33;
    }

    .dropdown-search input,
    .dropdown-search input[type="text"] {
        background: #121213 !important;
        color: #F9FAFB !important;
    }

    .dropdown-search input::placeholder {
        color: #6B7280;
    }

    .dropdown-search input:focus,
    .dropdown-search input[type="text"]:focus {
        background: #0A0A0B !important;
    }

    /* Selector bloqueado en modo oscuro */
    #templateSearch.template-blocked {
        opacity: 0.5;
    }

    /* Campaigns table dark mode */
    .campaigns-table-header {
        display: grid;
        grid-template-columns: minmax(120px, 1.5fr) minmax(200px, 3fr) 100px minmax(140px, 1.2fr) 80px 100px;
        background: #2d2d2d;
        color: #a1a1aa;
        border-bottom: 1px solid #3f3f46;
    }

    .campaign-row {
        border-bottom: 1px solid #3f3f46;
        background-color: var(--surface);
    }

    .campaign-row:hover {
        background-color: #27272a;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    .campaign-row .td {
        color: #d1d5db;
    }

    .campaign-row .td-name {
        color: #f3f4f6;
    }

    .campaign-row .td-message {
        color: #9ca3af;
    }

    .sender-info {
        color: #a1a1aa;
    }

    .status-pill.status-pending {
        background: rgba(251, 191, 36, 0.2);
        color: #fbbf24;
    }

    .status-pill.status-processing {
        background: rgba(59, 130, 246, 0.2);
        color: #60a5fa;
    }

    .status-pill.status-completed {
        background: rgba(34, 197, 94, 0.2);
        color: #4ade80;
    }

    .status-pill.status-failed {
        background: rgba(239, 68, 68, 0.2);
        color: #f87171;
    }

    .btn-more {
        color: #9ca3af;
    }

    .btn-more:hover {
        background: #3f3f46;
        color: #e5e7eb;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.badge {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Layout */
#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.view {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.card-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Forms */
.form {
    padding: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

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

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--surface);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.help-text {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.375rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-large {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

/* Preview Box */
.preview-box {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.25rem;
}

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

.preview-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.preview-count {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Variable Section */
.variable-section {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.variable-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.section-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.variables-list {
    display: grid;
    gap: 0.75rem;
}

.variable-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.variable-name {
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--primary-dark);
    background: var(--primary-light);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    min-width: 60px;
    text-align: center;
}

.variable-arrow {
    color: var(--text-secondary);
}

.variable-select {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
}

/* Campaigns List */
.campaigns-list {
    padding: 1rem;
}

.campaign-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.campaign-item:hover {
    background: var(--bg);
}

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

.campaign-info {
    flex: 1;
}

.campaign-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.campaign-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.campaign-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pending {
    background: #FEF3C7;
    color: #D97706;
}

.status-processing {
    background: #DBEAFE;
    color: #2563EB;
}

.status-completed {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.status-failed {
    background: #FEE2E2;
    color: var(--danger);
}

.progress-bar {
    width: 120px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1000;
}

.toast {
    background: var(--surface);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideDown 0.3s ease;
    max-width: 400px;
}

.toast.error {
    background: #FEE2E2;
    color: #991B1B;
}

.toast.success {
    background: #D1FAE5;
    color: #065F46;
}

.toast.warning {
    background: #FEF3C7;
    color: #92400E;
}

.toast.info {
    background: #DBEAFE;
    color: #1E40AF;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    #app {
        padding: 1rem;
    }

    .header {
        padding: 1rem;
    }

    .card-header,
    .form {
        padding: 1rem;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        top: 1rem;
        bottom: auto;
    }

    .toast {
        max-width: none;
    }
}

/* Developer Panel - Al pie de página */
.dev-panel-footer {
    margin: 2rem auto;
    max-width: 900px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.dev-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    border-radius: 12px 12px 0 0;
}

.dev-panel-header h3 {
    font-size: 0.9rem;
    margin: 0;
    color: var(--text);
}

.dev-panel-actions {
    display: flex;
    gap: 0.5rem;
}

.dev-panel-content {
    flex: 1;
    overflow: auto;
    padding: 0;
}

.dev-logs {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
}

.dev-log-entry {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
}

.dev-log-entry:last-child {
    border-bottom: none;
}

.dev-log-time {
    color: var(--text-muted);
    white-space: nowrap;
}

.dev-log-method {
    font-weight: 600;
    padding: 0 0.25rem;
    border-radius: 3px;
    font-size: 0.7rem;
}

.dev-log-method.get {
    background: #dbeafe;
    color: #1e40af;
}

.dev-log-method.post {
    background: #dcfce7;
    color: #166534;
}

.dev-log-url {
    color: var(--text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dev-log-status {
    font-weight: 600;
    padding: 0 0.25rem;
    border-radius: 3px;
    font-size: 0.7rem;
}

.dev-log-status.success {
    background: #dcfce7;
    color: #166534;
}

.dev-log-status.error {
    background: #fee2e2;
    color: #991b1b;
}

.dev-log-details {
    margin-top: 0.25rem;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-all;
}

.dev-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Botón de configuración */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-left: 0.5rem;
}

.btn-icon:hover {
    background: var(--bg);
    color: var(--primary);
    transform: rotate(30deg);
}

/* Modal de configuración */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}

.btn-close:hover {
    color: var(--text);
}

.modal .form {
    padding: 1.5rem;
}

.modal .form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

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

.btn-secondary:hover {
    background: var(--bg-elevated);
}

/* Searchable Select */
.searchable-select {
    position: relative;
}

.searchable-select input[type="text"] {
    width: 100%;
    padding-right: 2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    cursor: pointer;
}

.dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.dropdown-option {
    padding: 0.625rem 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.15s;
}

.dropdown-option:hover {
    background: var(--bg);
}

.dropdown-option.selected {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.dropdown-option .tag-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dropdown-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Buscador dentro del dropdown */
.dropdown-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.dropdown-search svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.dropdown-search input {
    flex: 1;
    border: none;
    background: #F3F4F6;
    font-size: 0.875rem;
    color: var(--text);
    outline: none;
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
}

.dropdown-search input::placeholder {
    color: var(--text-secondary);
}

.dropdown-search input:focus {
    background: #E5E7EB;
}

/* Quitar el icono de flecha del buscador del dropdown */
.dropdown-search input[type="text"] {
    background-image: none;
    padding-right: 0.5rem;
}

/* Estilo para input readonly de select */
.input-field[readonly] {
    cursor: pointer;
    background: var(--surface);
    user-select: none;
}

/* Selector bloqueado cuando no hay remitente seleccionado */
#templateSearch.template-blocked {
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

input:disabled {
    background: var(--bg);
    cursor: not-allowed;
    opacity: 0.6;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
    text-transform: uppercase;
}

.badge-approved {
    background: var(--success-light);
    color: var(--success);
}

.badge-pending {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-rejected {
    background: var(--error-light);
    color: var(--error);
}

.badge-tag {
    background: var(--primary-light);
    color: var(--primary);
    text-transform: none;
    min-width: 3rem;
    display: inline-block;
}

.text-muted {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Preview de plantilla */
.template-preview-box {
    background: var(--success-light);
    border: 1px solid var(--success);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 0.75rem;
}

.template-preview-box .preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--success);
}

.template-preview-box .preview-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--success);
}

.template-preview-box .preview-inbox {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.template-body {
    background: white;
    border-radius: 0.375rem;
    padding: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
}

.template-variables {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.template-var-badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Estilos mejorados para mapeo de variables */
.variable-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.variable-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.variable-name {
    font-weight: 600;
    color: var(--primary);
    font-family: monospace;
    font-size: 0.9rem;
}

.variable-arrow {
    color: var(--text-secondary);
}

.variable-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.variable-select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: white;
}

.variable-input-container {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    align-items: center;
}

.variable-input-container .variable-input {
    flex: 1;
    min-width: 150px;
}

.variable-field-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.variable-field-select:hover {
    border-color: var(--primary);
}

.variable-field-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.variable-custom-input {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: white;
    width: 100%;
}

.variable-custom-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Animación spin para sincronización */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

.input-with-button {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.input-with-button input {
    flex: 1;
}

.input-with-button button {
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Secciones del panel de desarrollador */
.dev-section {
    border-bottom: 1px solid var(--border);
}

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

.dev-section h4 {
    margin: 0;
    padding: 0.5rem 1rem;
    background: var(--bg);
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Contexto de embebido */
.dev-context {
    padding: 0.75rem 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
}

.dev-context-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: flex-start;
}

.dev-context-label {
    color: var(--text-muted);
    min-width: 120px;
    flex-shrink: 0;
}

.dev-context-value {
    color: var(--text);
    word-break: break-all;
}

.dev-context-value.code {
    background: var(--bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
}

.dev-context-value.boolean {
    color: var(--primary);
    font-weight: 600;
}

/* Logs pequeños para postMessage */
.dev-logs-small {
    max-height: 150px;
    overflow-y: auto;
}

.dev-postmessage-entry {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
}

.dev-postmessage-entry:last-child {
    border-bottom: none;
}

.dev-postmessage-time {
    color: var(--text-muted);
    font-size: 0.65rem;
}

.dev-postmessage-origin {
    color: var(--primary);
    font-weight: 600;
}

.dev-postmessage-data {
    margin-top: 0.25rem;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text);
}

/* ============================================
   NUEVO LAYOUT DE DIFUSIÓN - ESTILOS
   ============================================ */

/* Contenedor principal de dos columnas */
.broadcast-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

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

    .broadcast-preview-column {
        display: none;
    }
}

/* Columna del formulario */
.broadcast-form-column {
    min-width: 0;
}

/* Card principal de difusión */
.broadcast-card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header de la difusión */
.broadcast-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.broadcast-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.btn-back {
    background: none;
    border: none;
    padding: 0.375rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-back:hover {
    background: var(--bg);
    color: var(--text);
}

/* Formulario de difusión */
.broadcast-form {
    padding: 1.25rem;
}

.broadcast-form .form-group {
    margin-bottom: 1.25rem;
}

.broadcast-form .form-group:last-child {
    margin-bottom: 0;
}

/* Label con badge opcional */
.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.125rem;
}

.broadcast-form label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

/* Texto de ayuda más compacto */
.broadcast-form .help-text {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
    line-height: 1.3;
    margin-top: 0;
}

.badge-optional {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-weight: 500;
}

/* Campos de entrada */
.input-field {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9375rem;
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: #1877F2;
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
}

.input-field::placeholder {
    color: #9CA3AF;
}

/* Select input con chevron */
.select-input {
    padding-right: 2.5rem;
}

.searchable-select {
    position: relative;
}

.select-chevron {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* Botón de añadir destinatarios */
.btn-add-recipients {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: #1877F2;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-recipients:hover {
    border-color: #1877F2;
    background: rgba(24, 119, 242, 0.05);
}

.recipients-preview {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text);
}

/* Links de ayuda */
.form-links {
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.help-link {
    font-size: 0.8125rem;
    color: #1877F2;
    text-decoration: none;
    font-weight: 500;
}

.help-link:hover {
    text-decoration: underline;
}

/* Sección de programación */
.schedule-section {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 1rem;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.radio-option {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text);
}

.radio-option span:last-child {
    display: inline-block;
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.radio-custom::after {
    content: '';
    width: 8px;
    height: 8px;
    background: #1877F2;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s;
}

.radio-option input[type="radio"]:checked+.radio-custom {
    border-color: #1877F2;
}

.radio-option input[type="radio"]:checked+.radio-custom::after {
    opacity: 1;
    transform: scale(1);
}

/* Footer del broadcast */
.broadcast-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.cost-section {
    display: flex;
    flex-direction: column;
}

.cost-amount {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.cost-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.footer-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-cancel {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #1877F2;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: rgba(24, 119, 242, 0.1);
}

.btn-send {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    background: #1877F2;
    color: white;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-send:hover {
    background: #166fe5;
}

.btn-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   CAMPAIGNS TABLE
   ============================================ */

.campaigns-table {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.campaigns-table-header {
    display: grid;
    grid-template-columns: minmax(120px, 1.5fr) minmax(200px, 3fr) 100px minmax(140px, 1.2fr) 80px 100px;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e7eb;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.campaigns-table-header .th {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.campaign-row {
    display: grid;
    grid-template-columns: minmax(120px, 1.5fr) minmax(200px, 3fr) 100px minmax(140px, 1.2fr) 80px 100px;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.campaign-row:hover {
    background-color: #f9fafb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.campaign-row:active {
    background-color: #f3f4f6;
}

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

.campaign-row .td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    color: #374151;
}

.campaign-row .td-name {
    font-weight: 500;
    color: #111827;
}

.campaign-row .td-message {
    color: #6b7280;
    font-size: 13px;
}

.campaign-row .td-sender {
    display: flex;
    align-items: center;
}

.sender-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #6b7280;
    font-size: 13px;
}

.sender-info svg {
    flex-shrink: 0;
    color: #25D366;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-pill.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-pill.status-processing {
    background: #dbeafe;
    color: #1e40af;
}

.status-pill.status-completed {
    background: #d1fae5;
    color: #065f46;
}

.status-pill.status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.btn-more {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s;
}

.btn-more:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Modal Footer */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 12px 12px;
}

.dark-mode .modal-footer {
    border-color: #3f3f46;
    background: #27272a;
}

.modal-footer .btn {
    padding: 0.5rem 1.5rem;
    font-size: 14px;
    font-weight: 500;
}

/* Dark mode for WhatsApp Preview */
.dark-mode .preview-header {
    color: #f3f4f6;
}

.dark-mode .preview-footer {
    color: #9ca3af;
}

.dark-mode .preview-media {
    background: #3f3f46;
    color: #a1a1aa;
}

.dark-mode .whatsapp-btn {
    background: #3f3f46;
    color: #e5e7eb;
    border-color: #52525b;
}

.dark-mode .whatsapp-btn:hover {
    background: #52525b;
}

/* Campaign Detail Modal Styles - Minimalista */
.campaign-detail-content {
    padding: 0 1.5rem;
}

/* Mensaje box container */
.campaign-message-box {
    padding: 1.5rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.dark-mode .campaign-message-box {
    border-color: #3f3f46;
}

.campaign-message-box .campaign-message-preview {
    max-height: none;
    overflow: visible;
    margin-top: 0;
}

.campaign-detail-row {
    display: flex;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid #e5e7eb;
    gap: 1rem;
}

.dark-mode .campaign-detail-row {
    border-color: #3f3f46;
}

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

.campaign-detail-label {
    width: 140px;
    flex-shrink: 0;
    color: #6b7280;
    font-size: 14px;
    font-weight: 400;
}

.dark-mode .campaign-detail-label {
    color: #9ca3af;
}

.campaign-detail-value {
    flex: 1;
    color: #111827;
    font-size: 14px;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dark-mode .campaign-detail-value {
    color: #f3f4f6;
}

.campaign-detail-value .status-pill {
    display: inline-flex;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
}

.campaign-detail-value .sender-info {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #059669;
}

.dark-mode .campaign-detail-value .sender-info {
    color: #34d399;
}

/* Preview de WhatsApp en modal de detalles */
.campaign-detail-content .whatsapp-preview-container {
    background: #E5DDD5;
    border-radius: 12px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.campaign-detail-content .whatsapp-preview-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h100v100H0z' fill='%23E5DDD5'/%3E%3Cpath d='M0 0h50v50H0z' fill='%23DFD7CD'/%3E%3Cpath d='M50 50h50v50H50z' fill='%23DFD7CD'/%3E%3C/svg%3E");
    opacity: 0.5;
}

.campaign-detail-content .whatsapp-message-box {
    background: white;
    border-radius: 8px;
    padding: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
}

.campaign-detail-content .preview-body {
    font-size: 0.875rem;
    line-height: 1.5;
    color: #111827;
    margin-bottom: 0.5rem;
}

.campaign-detail-content .var-filled {
    color: #059669;
    font-weight: 500;
}

.campaign-detail-content .var-placeholder {
    color: #1877F2;
    font-weight: 500;
}

.campaign-detail-content .whatsapp-time {
    text-align: right;
    font-size: 0.6875rem;
    color: #6B7280;
    margin-top: 0.25rem;
}

.campaign-detail-content .preview-media-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    min-height: 120px;
    color: #9ca3af;
}

.campaign-detail-content .preview-media-placeholder svg {
    opacity: 0.6;
}

.campaign-detail-content .preview-media-placeholder span {
    font-size: 0.875rem;
    font-weight: 500;
}

.campaign-detail-content .preview-header {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.campaign-detail-content .preview-footer {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.5rem;
    text-align: center;
}

.campaign-detail-content .preview-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
    padding-top: 0.75rem;
}

.campaign-detail-content .preview-button {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.875rem;
    color: #1877F2;
    font-weight: 500;
}

/* Chips para destinatarios */
.campaign-recipient-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.campaign-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 500;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.dark-mode .campaign-chip {
    background: #3f3f46;
    color: #e5e7eb;
    border-color: #52525b;
}

.campaign-chip.error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* Stats row for campaign detail */
.campaign-stats-row {
    display: flex;
    gap: 1.5rem;
}

.campaign-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.campaign-stat-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.campaign-stat-label {
    font-size: 12px;
    color: #6b7280;
}

.dark-mode .campaign-stat-label {
    color: #9ca3af;
}

.dark-mode .campaign-chip.error {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.campaign-chip-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 500;
    background: transparent;
    color: #6b7280;
    border: 1px solid #d1d5db;
    cursor: pointer;
}

.dark-mode .campaign-chip-more {
    color: #9ca3af;
    border-color: #52525b;
}

.campaign-expand-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    margin-left: auto;
}

.dark-mode .campaign-expand-btn {
    color: #9ca3af;
}

/* Mensaje preview */
.campaign-message-preview {
    font-size: 14px;
    line-height: 1.5;
    color: #374151;
    white-space: pre-wrap;
    max-height: 120px;
    overflow: hidden;
    position: relative;
}

.dark-mode .campaign-message-preview {
    color: #e5e7eb;
}

.campaign-message-preview.expanded {
    max-height: none;
}

.campaign-message-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to bottom, transparent, white);
}

.dark-mode .campaign-message-fade {
    background: linear-gradient(to bottom, transparent, #27272a);
}

.campaign-message-preview {
    background: #f9fafb;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.5rem;
    border: 1px solid #e5e7eb;
    border: 1px solid #e5e7eb;
}

.dark-mode .campaign-message-preview {
    background: #27272a;
    border-color: #3f3f46;
}

.campaign-contacts-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-top: 0.5rem;
}

.dark-mode .campaign-contacts-list {
    border-color: #3f3f46;
}

.campaign-contact-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    gap: 0.75rem;
}

.dark-mode .campaign-contact-item {
    border-color: #3f3f46;
}

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

.campaign-contact-item:hover {
    background: #f9fafb;
}

.dark-mode .campaign-contact-item:hover {
    background: #27272a;
}

.campaign-contact-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 10px;
}

.campaign-contact-status.success {
    background: #d1fae5;
    color: #065f46;
}

.dark-mode .campaign-contact-status.success {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.campaign-contact-status.pending {
    background: #fef3c7;
    color: #92400e;
}

.dark-mode .campaign-contact-status.pending {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.campaign-contact-status.failed {
    background: #fee2e2;
    color: #991b1b;
}

.dark-mode .campaign-contact-status.failed {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* ============================================
   PREVIEW WHATSAPP
   ============================================ */

.broadcast-preview-column {
    position: sticky;
    top: 1rem;
    height: fit-content;
}

.whatsapp-preview-container {
    background: #E5DDD5;
    border-radius: 12px;
    padding: 2rem 1.5rem;
    min-height: 500px;
    position: relative;
    overflow: hidden;
}

/* Patrón de fondo tipo WhatsApp */
.whatsapp-preview-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h100v100H0z' fill='%23E5DDD5'/%3E%3Cpath d='M0 0h50v50H0z' fill='%23DFD7CD'/%3E%3Cpath d='M50 50h50v50H50z' fill='%23DFD7CD'/%3E%3C/svg%3E");
    opacity: 0.5;
}

.whatsapp-preview {
    position: relative;
    z-index: 1;
}

.whatsapp-message {
    background: white;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    margin-bottom: 0.5rem;
}

.message-content {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: #111827;
}

.message-content p {
    margin-bottom: 0.5rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.var-placeholder {
    color: #1877F2;
    font-weight: 500;
}

.check-item {
    color: #111827;
}

.warning-item {
    color: #92400E;
}

.message-time {
    text-align: right;
    font-size: 0.6875rem;
    color: #6B7280;
    margin-top: 0.25rem;
}

.whatsapp-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.whatsapp-btn {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    background: white;
    color: #1877F2;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
}

.whatsapp-btn:hover {
    background: #F9FAFB;
}

/* Card de campañas */
.campaigns-card {
    margin-top: 1.5rem;
}

/* Variables dinámicas - estilo compacto tipo imagen */
.variables-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 0.75rem;
}

.variable-input-row {
    min-width: 300px;
}

/* Estilos para campo de imagen */
.image-variable-row {
    grid-column: 1 / -1;
    max-width: 100%;
}

.image-input-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.image-url-input {
    font-family: monospace;
    font-size: 0.875rem;
}

.image-validation-msg {
    font-size: 0.75rem;
    padding: 0.25rem 0;
    font-weight: 500;
}

.image-preview-thumb {
    width: 100%;
    max-width: 200px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border);
    background: var(--surface);
}

.image-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Preview de imagen en WhatsApp */
.preview-media-image {
    margin-bottom: 0.75rem;
    border-radius: 8px;
    overflow: hidden;
    max-height: 200px;
}

.preview-media-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* Placeholder cuando no hay imagen */
.preview-media-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    min-height: 120px;
    color: #9ca3af;
}

.preview-media-placeholder svg {
    opacity: 0.6;
}

.preview-media-placeholder span {
    font-size: 0.875rem;
    font-weight: 500;
}

.variable-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9375rem;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.variable-input:focus {
    border-color: #1877F2;
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
}

.variable-input::placeholder {
    color: #9CA3AF;
    font-family: monospace;
}

/* Variable info con tag y origen */
.variable-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}

.variable-tag {
    display: inline-flex;
    font-family: monospace;
    font-size: 0.75rem;
    font-weight: 600;
    color: #4B5563;
    background: #F3F4F6;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid #E5E7EB;
}

.variable-source {
    font-size: 0.75rem;
    color: #6B7280;
    background: #F9FAFB;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

.variable-arrow {
    display: none;
}

/* Dark mode para variable info */
.dark-mode .variable-tag {
    color: #D1D5DB;
    background: #374151;
    border-color: #4B5563;
}

.dark-mode .variable-source {
    color: #9CA3AF;
    background: #1F2937;
}

/* Estilos para variables en el preview */
.var-filled {
    color: #111827;
    font-weight: 500;
    background: rgba(16, 185, 129, 0.1);
    padding: 0 2px;
    border-radius: 3px;
}

.placeholder-text {
    color: #9CA3AF;
    text-align: center;
    font-style: italic;
}

/* Variable searchable select dropdown */
.variable-searchable {
    position: relative;
    flex: 1;
}

.variable-searchable .variable-input {
    width: 100%;
    padding-right: 2.5rem;
    cursor: text;
}

.variable-searchable .select-chevron {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-secondary);
    pointer-events: auto;
}

.variable-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.variable-dropdown .dropdown-search {
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border);
}

.variable-dropdown .dropdown-options {
    position: static;
    border: none;
    box-shadow: none;
    max-height: 200px;
    overflow-y: auto;
}

.variable-dropdown .dropdown-group {
    padding: 0.5rem 0;
}

.variable-dropdown .dropdown-group-label {
    padding: 0.375rem 0.875rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.variable-dropdown .dropdown-option {
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.variable-dropdown .dropdown-option:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* Botón de configuración en pie de página */
.footer-config {
    display: flex;
    justify-content: flex-end;
    padding: 1.5rem;
    margin-top: 2rem;
}

.btn-config-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: #9CA3AF;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-config-footer:hover {
    color: #6B7280;
}

.btn-config-footer svg {
    width: 20px;
    height: 20px;
}

/* Campaign list new styles */
.campaign-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    background: var(--surface);
}

.campaign-info {
    flex: 1;
    min-width: 0;
}

.campaign-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.campaign-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.campaign-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.campaign-sender {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--primary);
    font-weight: 500;
}

.campaign-date,
.campaign-recipients {
    color: var(--text-secondary);
}

.campaign-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    min-width: 80px;
}

/* Dark mode fixes for white backgrounds */
.dark-mode .template-preview-box .preview-inbox {
    background: var(--surface);
}

.dark-mode .template-body {
    background: var(--surface);
}

.dark-mode .variable-item {
    background: var(--surface);
}

.dark-mode .variable-select {
    background: var(--surface);
    color: var(--text);
}

.dark-mode .variable-field-select {
    background: var(--surface);
    color: var(--text);
}

.dark-mode .variable-custom-input {
    background: var(--surface);
    color: var(--text);
}

.dark-mode .campaign-message-fade {
    background: linear-gradient(to bottom, transparent, var(--surface));
}

.dark-mode .whatsapp-btn {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.dark-mode .variable-dropdown {
    background: var(--surface);
}

.dark-mode .dropdown-options {
    background: var(--surface);
}

.dark-mode .tag-dropdown {
    background: var(--surface);
}

.dark-mode .btn-cancel {
    color: #60A5FA;
}

.dark-mode .btn-cancel:hover {
    background: rgba(96, 165, 250, 0.1);
}

.dark-mode .dev-log-status.error {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.dark-mode .dev-log-status.success {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

.dark-mode .campaign-contact-item:hover {
    background: #27272a;
}

.dark-mode .whatsapp-btn:hover {
    background: #27272a;
}

.dark-mode .variable-input {
    background: var(--surface);
    color: var(--text);
}

.dark-mode .form-group select,
.dark-mode .form-group input {
    background: var(--surface);
    color: var(--text);
}

.dark-mode select option {
    background: var(--surface);
    color: var(--text);
}

.dark-mode .dropdown-option {
    background: var(--surface);
    color: var(--text);
}

.dark-mode .dropdown-option:hover {
    background: var(--bg);
}