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

:root {
  --primary-color: #25D366;
  --primary-dark: #1DA851;
  --secondary-color: #34495e;
  --success-color: #27ae60;
  --danger-color: #e74c3c;
  --warning-color: #f39c12;
  --bg-light: #ecf0f1;
  --bg-white: #ffffff;
  --text-dark: #2c3e50;
  --text-gray: #7f8c8d;
  --border-color: #bdc3c7;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: var(--text-dark);
  min-height: 100vh;
  padding: 20px;
}

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

/* Header */
.header {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: var(--shadow-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.header h1 {
  font-size: 28px;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}

.status {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  background: var(--bg-light);
  color: var(--text-gray);
}

.status.online {
  background: #d4edda;
  color: var(--success-color);
}

.status.offline {
  background: #f8d7da;
  color: var(--danger-color);
}

/* Main */
.main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
}

/* Form Section */
.form-section {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 30px;
  box-shadow: var(--shadow-lg);
}

.form-section h2,
.pages-section h2 {
  font-size: 20px;
  margin-bottom: 20px;
  color: var(--text-dark);
}

.form {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr auto;
  gap: 15px;
  align-items: end;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.form-group input,
.form-group select {
  padding: 12px 15px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s;
  font-family: inherit;
}

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

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
  font-size: 12px;
  padding: 8px 12px;
}

.btn-secondary:hover {
  background: #2c3e50;
  opacity: 0.9;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
  font-size: 12px;
  padding: 8px 12px;
}

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

.btn-check {
  background: #3498db;
  color: white;
  font-size: 12px;
  padding: 8px 12px;
}

.btn-check:hover {
  background: #2980b9;
}

.btn-check:disabled {
  background: #95a5a6;
  cursor: not-allowed;
  opacity: 0.7;
}

/* Pages Section */
.pages-section {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 30px;
  box-shadow: var(--shadow-lg);
}

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

.import-export-buttons {
  display: flex;
  gap: 10px;
}

.btn-export,
.btn-import {
  font-size: 13px;
  padding: 10px 16px;
}

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

.btn-export:hover {
  background: #229954;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn-import {
  background: #3498db;
  color: white;
}

.btn-import:hover {
  background: #2980b9;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.table-container {
  overflow-x: auto;
}

.pages-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.pages-table thead {
  background: var(--bg-light);
  border-bottom: 2px solid var(--border-color);
}

.pages-table th {
  padding: 15px;
  text-align: left;
  font-weight: 600;
  color: var(--text-dark);
}

.pages-table td {
  padding: 15px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-gray);
}

.pages-table tbody tr:hover {
  background: var(--bg-light);
}

.pages-table .empty-state {
  text-align: center;
  color: var(--text-gray);
  font-style: italic;
}

.pages-table .empty-state:hover {
  background: transparent;
}

.name-cell {
  font-size: 14px;
  color: var(--text-dark);
  max-width: 150px;
  word-wrap: break-word;
}

.url-cell {
  font-family: 'Courier New', monospace;
  word-break: break-all;
  max-width: 200px;
  font-size: 11px;
}

.link-cell {
  max-width: 180px;
}

.whatsapp-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.3s;
}

.whatsapp-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.link-icon {
  font-size: 14px;
}

.no-link {
  color: var(--text-gray);
  font-size: 12px;
  font-style: italic;
}

.frequency-badge {
  display: inline-block;
  padding: 4px 8px;
  background: var(--bg-light);
  color: var(--secondary-color);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

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

.status-badge.active {
  background: #d4edda;
  color: var(--success-color);
}

.status-badge.inactive {
  background: #f8d7da;
  color: var(--danger-color);
}

.actions-cell {
  display: flex;
  gap: 8px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s;
}

.modal.open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-white);
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s;
}

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

.modal-header h2 {
  font-size: 20px;
  color: var(--text-dark);
}

.close {
  font-size: 28px;
  font-weight: bold;
  color: var(--text-gray);
  cursor: pointer;
  transition: color 0.3s;
}

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

.modal-body {
  padding: 20px;
}

.history-content {
  max-height: 500px;
  overflow-y: auto;
  padding: 5px;
}

.history-entry {
  background: var(--bg-light);
  padding: 15px;
  margin-bottom: 15px;
  border-radius: 8px;
  border-left: 4px solid var(--primary-color);
  transition: all 0.3s;
}

.history-entry:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: translateX(2px);
}

.history-entry.changed {
  border-left-color: var(--warning-color);
  background: #fffbea;
}

.history-entry.current-entry {
  border-left-color: var(--success-color);
  border-left-width: 6px;
  background: #e8f5e9;
}

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

.history-timestamp {
  font-size: 12px;
  color: var(--text-gray);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.current-badge {
  display: inline-block;
  padding: 3px 8px;
  background: var(--success-color);
  color: white;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.manual-badge {
  display: inline-block;
  padding: 3px 8px;
  background: #3498db;
  color: white;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  margin-left: 5px;
}

.local-storage-notice {
  background: #e3f2fd;
  color: #1976d2;
  padding: 10px 15px;
  border-radius: 6px;
  margin-bottom: 15px;
  font-size: 13px;
  font-weight: 600;
  border-left: 4px solid #2196f3;
}

.history-changed {
  display: inline-block;
  padding: 4px 8px;
  background: var(--warning-color);
  color: white;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.history-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-link {
  padding: 10px 12px;
  background: white;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  word-break: break-all;
  border: 1px solid var(--border-color);
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-dark);
}

.history-link:hover {
  border-color: var(--primary-color);
  background: #f0fdf4;
  box-shadow: 0 2px 6px rgba(37, 211, 102, 0.2);
}

.no-link-found {
  background: #fff3f3;
  border-color: var(--danger-color);
  color: var(--danger-color);
  font-style: italic;
}

.no-history {
  text-align: center;
  color: var(--text-gray);
  padding: 30px;
  font-style: italic;
}

/* Import Modal */
.import-instructions {
  background: var(--bg-light);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.import-instructions h3 {
  font-size: 16px;
  margin-bottom: 10px;
  color: var(--text-dark);
}

.import-instructions p {
  font-size: 13px;
  color: var(--text-gray);
  margin: 10px 0;
}

.code-example {
  background: var(--bg-white);
  padding: 10px;
  border-radius: 6px;
  margin: 10px 0;
  border-left: 3px solid var(--primary-color);
}

.code-example code {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--secondary-color);
  display: block;
  margin: 5px 0;
}

.import-input-area {
  margin-bottom: 20px;
}

.import-input-area label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.import-input-area textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  resize: vertical;
  transition: border-color 0.3s;
}

.import-input-area textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.import-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-bottom: 20px;
}

.import-result {
  margin-top: 20px;
}

.import-summary {
  padding: 15px;
  border-radius: 8px;
  background: var(--bg-light);
}

.import-success {
  padding: 10px;
  background: #d4edda;
  color: var(--success-color);
  border-radius: 6px;
  margin-bottom: 10px;
  font-weight: 600;
}

.import-errors {
  padding: 10px;
  background: #f8d7da;
  color: var(--danger-color);
  border-radius: 6px;
  margin-bottom: 10px;
  font-weight: 600;
}

.error-list {
  list-style: none;
  margin-top: 10px;
}

.error-list li {
  padding: 10px;
  background: white;
  border-left: 3px solid var(--danger-color);
  margin-bottom: 8px;
  border-radius: 4px;
  font-size: 12px;
}

.error-list code {
  display: block;
  margin-top: 5px;
  padding: 5px;
  background: var(--bg-light);
  border-radius: 3px;
  color: var(--text-gray);
}

/* Edit Modal */
.edit-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.edit-form .form-group {
  display: flex;
  flex-direction: column;
}

.edit-form .form-group label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.edit-form .form-group input,
.edit-form .form-group select {
  padding: 12px 15px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s;
  font-family: inherit;
}

.edit-form .form-group input:focus,
.edit-form .form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.edit-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateY(-30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Responsive */
@media (max-width: 1024px) {
  .form {
    grid-template-columns: 1fr 1fr;
  }

  .form .btn {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .header {
    flex-direction: column;
    text-align: center;
  }

  .header h1 {
    font-size: 24px;
  }

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

  .form .btn {
    grid-column: span 1;
  }

  .btn {
    width: 100%;
  }

  .pages-table {
    font-size: 11px;
  }

  .pages-table th,
  .pages-table td {
    padding: 10px 6px;
  }

  .name-cell {
    max-width: 100px;
  }

  .url-cell {
    max-width: 120px;
  }

  .link-cell {
    max-width: 100px;
  }

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

  .modal-content {
    width: 95%;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  .header {
    padding: 20px;
  }

  .header h1 {
    font-size: 20px;
  }

  .form-section,
  .pages-section {
    padding: 20px;
  }

  .pages-table {
    font-size: 11px;
  }

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

  .url-cell {
    max-width: 150px;
  }

  .btn-secondary,
  .btn-danger {
    font-size: 11px;
    padding: 6px 10px;
  }
}

/* Loading spinner */
.spinner {
  border: 3px solid var(--bg-light);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
  display: inline-block;
}

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

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-gray);
}
