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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  color: #333;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 40px;
}

header {
  text-align: center;
  margin-bottom: 40px;
  padding-bottom: 30px;
  border-bottom: 2px solid #f0f0f0;
}

header h1 {
  color: #667eea;
  font-size: 2.5em;
  margin-bottom: 10px;
}

.subtitle {
  color: #666;
  font-size: 1.1em;
}

.config-section,
.campaigns-section,
.actions-section {
  margin-bottom: 40px;
}

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

h2 {
  color: #667eea;
  font-size: 1.8em;
  margin-bottom: 20px;
}

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

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #555;
}

input[type='text'],
textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1em;
  transition: border-color 0.3s;
  font-family: inherit;
}

input[type='text']:focus,
textarea:focus {
  outline: none;
  border-color: #667eea;
}

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

small {
  display: block;
  margin-top: 5px;
  color: #888;
  font-size: 0.9em;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  font-family: inherit;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-success {
  background: #10b981;
  color: white;
}

.btn-success:hover {
  background: #059669;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background: #6b7280;
  color: white;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-large {
  padding: 16px 32px;
  font-size: 1.1em;
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.campaign-card {
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 20px;
  position: relative;
  transition: all 0.3s;
}

.campaign-card:hover {
  border-color: #667eea;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

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

.campaign-header h3 {
  color: #667eea;
  font-size: 1.3em;
}

.remove-campaign {
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 50%;
  width: 35px;
  height: 35px;
  cursor: pointer;
  font-size: 1.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.remove-campaign:hover {
  background: #dc2626;
  transform: scale(1.1);
}

.campaign-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.campaign-form.full-width {
  grid-column: 1 / -1;
}

.form-row {
  display: flex;
  gap: 15px;
}

.form-row .form-group {
  flex: 1;
}

.components-section {
  grid-column: 1 / -1;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid #e5e7eb;
}

.components-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.component-item {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
}

.component-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.actions-section {
  text-align: center;
  display: flex;
  gap: 15px;
  justify-content: center;
}

.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  color: white;
}

.loading.hidden {
  display: none;
}

.spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.result-section {
  margin-top: 40px;
  padding: 25px;
  background: #f9fafb;
  border-radius: 12px;
  border: 2px solid #e5e7eb;
}

.result-section.hidden {
  display: none;
}

.result-section h3 {
  color: #667eea;
  margin-bottom: 20px;
}

.result-success {
  color: #10b981;
  font-weight: 600;
  margin-bottom: 15px;
}

.result-error {
  color: #ef4444;
  font-weight: 600;
  margin-bottom: 15px;
}

.campaign-list {
  margin-top: 20px;
}

.campaign-item {
  background: white;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 10px;
  border-left: 4px solid #667eea;
}

.error-list {
  margin-top: 20px;
  padding: 15px;
  background: #fee2e2;
  border-radius: 8px;
  border-left: 4px solid #ef4444;
}

.error-item {
  margin-bottom: 10px;
  padding: 10px;
  background: white;
  border-radius: 5px;
}

.hidden {
  display: none !important;
}

/* Estilos para sección de ver campañas */
.view-campaigns-section {
  margin-bottom: 40px;
  padding-bottom: 30px;
  border-bottom: 2px solid #f0f0f0;
}

.campaigns-list {
  margin-top: 20px;
}

.empty-message {
  text-align: center;
  color: #888;
  padding: 40px;
  font-style: italic;
}

.loading-campaigns {
  text-align: center;
  padding: 40px;
  color: #667eea;
  font-weight: 600;
}

.error-message {
  background: #fee2e2;
  color: #dc2626;
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid #dc2626;
}

/* Tarjeta de visualización de campaña */
.campaign-view-card {
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 20px;
  transition: all 0.3s;
}

.campaign-view-card:hover {
  border-color: #667eea;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.campaign-view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e5e7eb;
}

.campaign-title-section {
  flex: 1;
}

.campaign-title-section h3 {
  color: #667eea;
  margin-bottom: 10px;
  font-size: 1.5em;
}

.campaign-status {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.9em;
  font-weight: 600;
}

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

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

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

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

.status-cancelled {
  background: #f3f4f6;
  color: #374151;
}

.campaign-id {
  color: #888;
  font-size: 0.85em;
  font-family: monospace;
}

/* Grid de información */
.campaign-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.info-item {
  padding: 12px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.info-item strong {
  color: #667eea;
  display: block;
  margin-bottom: 5px;
  font-size: 0.9em;
}

/* Barra de progreso */
.progress-bar-container {
  width: 100%;
  height: 25px;
  background: #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  transition: width 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.8em;
  font-weight: 600;
}

/* Información de tiempo */
.time-info {
  margin-bottom: 20px;
  padding: 15px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.time-item {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f3f4f6;
}

.time-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.time-item strong {
  color: #667eea;
  display: block;
  margin-bottom: 5px;
}

.time-value {
  color: #333;
  font-weight: 500;
}

.time-match {
  color: #10b981;
}

.time-diff {
  color: #f59e0b;
}

.time-match-note {
  color: #10b981;
  display: block;
  margin-top: 5px;
}

.time-diff-note {
  color: #f59e0b;
  display: block;
  margin-top: 5px;
}

/* Error box */
.error-box {
  background: #fee2e2;
  border-left: 4px solid #dc2626;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  color: #991b1b;
}

/* Lista de destinatarios */
.recipients-list {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid #e5e7eb;
}

.recipients-list h4 {
  color: #667eea;
  margin-bottom: 15px;
}

.recipient-item {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  transition: all 0.3s;
}

.recipient-item:hover {
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.recipient-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.recipient-icon {
  font-size: 1.2em;
}

.recipient-number {
  flex: 1;
  font-weight: 600;
  color: #333;
}

.recipient-status {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 600;
  text-transform: uppercase;
}

.recipient-sent .recipient-status {
  background: #d1fae5;
  color: #065f46;
}

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

.recipient-blocked .recipient-status {
  background: #f3f4f6;
  color: #374151;
}

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

.recipient-details {
  margin-left: 32px;
}

.recipient-details small {
  display: block;
  color: #666;
  font-size: 0.85em;
}

.error-msg {
  color: #dc2626 !important;
  font-weight: 600;
}

/* Estilos para modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 1200px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 25px;
  border-bottom: 2px solid #e5e7eb;
}

.modal-header h2 {
  margin: 0;
  color: #667eea;
  font-size: 1.8em;
}

.modal-close {
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.5em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.modal-close:hover {
  background: #dc2626;
  transform: scale(1.1);
}

.modal-body {
  padding: 25px;
  overflow-y: auto;
  flex: 1;
}

.modal-actions {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 1em;
}

.filter-select {
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 1em;
  background: white;
  cursor: pointer;
}

/* Estadísticas de destinatarios */
.recipients-stats {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  padding: 15px;
  background: #f9fafb;
  border-radius: 8px;
}

.stat-item {
  padding: 10px 15px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  font-size: 0.95em;
}

.stat-item strong {
  color: #667eea;
  display: block;
  margin-bottom: 5px;
}

.stat-sent {
  border-left: 4px solid #10b981;
}

.stat-failed {
  border-left: 4px solid #ef4444;
}

.stat-pending {
  border-left: 4px solid #f59e0b;
}

.stat-blocked {
  border-left: 4px solid #6b7280;
}

/* Tabla de destinatarios */
.recipients-table-container {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.recipients-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.recipients-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.recipients-table th {
  background: #667eea;
  color: white;
  padding: 15px;
  text-align: left;
  font-weight: 600;
  font-size: 0.9em;
}

.recipients-table td {
  padding: 12px 15px;
  border-bottom: 1px solid #f3f4f6;
}

.recipients-table tbody tr:hover {
  background: #f9fafb;
}

.recipients-table tbody tr.recipient-sent {
  background: #f0fdf4;
}

.recipients-table tbody tr.recipient-failed {
  background: #fef2f2;
}

.recipients-table tbody tr.recipient-pending {
  background: #fffbeb;
}

.recipients-table tbody tr.recipient-blocked {
  background: #f9fafb;
}

.status-badge {
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 600;
  display: inline-block;
}

.status-badge.recipient-sent {
  background: #d1fae5;
  color: #065f46;
}

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

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

.status-badge.recipient-blocked {
  background: #f3f4f6;
  color: #374151;
}

.phone-number-cell {
  font-family: monospace;
  font-weight: 600;
  color: #333;
}

.error-text {
  color: #dc2626;
  font-size: 0.9em;
}

.no-results {
  text-align: center;
  padding: 40px;
  color: #888;
  font-style: italic;
}

.recipients-summary {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid #e5e7eb;
}

@media (max-width: 768px) {
  .container {
    padding: 20px;
  }

  .campaign-form {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
  }

  .actions-section {
    flex-direction: column;
  }

  .section-header {
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
  }

  .campaign-view-header {
    flex-direction: column;
    gap: 15px;
  }

  .campaign-info-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    max-height: 95vh;
    margin: 10px;
  }

  .modal-actions {
    flex-direction: column;
  }

  .search-input,
  .filter-select {
    width: 100%;
  }

  .recipients-stats {
    flex-direction: column;
  }

  .recipients-table-container {
    max-height: 400px;
  }

  .recipients-table {
    font-size: 0.85em;
  }

  .recipients-table th,
  .recipients-table td {
    padding: 8px;
  }
}
