/* ===== VARIABLES ===== */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --success: #10b981;
  --success-hover: #059669;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --secondary: #6b7280;
  --secondary-hover: #4b5563;
  --google-blue: #4285f4;
  --google-hover: #3367d6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
}

/* ===== LIGHT MODE ===== */
.light-mode {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --input-bg: #ffffff;
  --overlay-bg: rgba(15, 23, 42, 0.6);
  --card-bg: #ffffff;
  --table-header-bg: #f1f5f9;
  --table-row-hover: #f8fafc;
  --table-border: #e2e8f0;
}

/* ===== DARK MODE ===== */
.dark-mode {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #334155;
  --input-bg: #1e293b;
  --overlay-bg: rgba(0, 0, 0, 0.8);
  --card-bg: #1e293b;
  --table-header-bg: #334155;
  --table-row-hover: #334155;
  --table-border: #475569;
}

/* ===== RESET ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: var(--transition);
  line-height: 1.6;
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.badge {
  background: var(--primary);
  color: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

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

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--success-hover); transform: translateY(-1px); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: var(--secondary-hover); }

.btn-google { background: var(--google-blue); color: #fff; }
.btn-google:hover:not(:disabled) { background: var(--google-hover); transform: translateY(-1px); }

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-icon:hover { background: var(--primary); color: #fff; }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

.btn-close-admin {
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
}
.btn-close-admin:hover { background: var(--danger); color: #fff; }

/* ===== ACCESS GATE ===== */
.gate-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  backdrop-filter: blur(8px);
}

.gate-card {
  background: var(--card-bg);
  padding: 2.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: 400px;
  width: 100%;
  animation: fadeInUp 0.4s ease;
}

.gate-logo {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 1.8rem;
  color: #fff;
}

.gate-card h2 {
  margin-bottom: 0.5rem;
  font-size: 1.4rem;
}

.gate-card p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.gate-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.gate-input-group input {
  padding: 0.8rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--input-bg);
  color: var(--text-primary);
  text-align: center;
  transition: var(--transition);
}

.gate-input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ===== HEADER ===== */
.app-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-left h1 {
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-left h1 i {
  color: var(--primary);
}

.header-logo {
  height: 32px;
  width: auto;
  vertical-align: middle;
  border-radius: 4px;
}

.logo-preview-container {
  text-align: center;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
}

.logo-preview {
  max-height: 48px;
  max-width: 100%;
  border-radius: 4px;
}

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

#user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--primary);
}

#user-name {
  font-size: 0.85rem;
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== SOCIAL BAR ===== */
.social-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.social-bar a {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  transition: var(--transition);
  text-decoration: none;
}

.social-bar a:hover { transform: scale(1.15); }

.social-bar a[data-network="whatsapp"] { background: #25d366; }
.social-bar a[data-network="telegram"] { background: #0088cc; }
.social-bar a[data-network="tiktok"] { background: #010101; }
.social-bar a[data-network="instagram"] { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.social-bar a[data-network="facebook"] { background: #1877f2; }
.social-bar a[data-network="twitter"] { background: #000; }
.social-bar a[data-network="youtube"] { background: #ff0000; }
.social-bar a[data-network="linkedin"] { background: #0077b5; }
.social-bar a[data-network="web"] { background: var(--primary); }
.social-bar a[data-network="email"] { background: var(--secondary); }

/* ===== CONTROLS ===== */
.controls-section {
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.control-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
}

.control-group label i {
  color: var(--primary);
  margin-right: 0.3rem;
}

.control-group input {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--input-bg);
  color: var(--text-primary);
  transition: var(--transition);
}

.control-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

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

/* ===== PROGRESS ===== */
.progress-section {
  padding: 0 1.5rem 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.progress-bar-container {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

#progress-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== RESULTS TABLE ===== */
.results-section {
  padding: 0 1.5rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.results-header h2 {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}

#results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 700px;
}

#results-table thead {
  background: var(--table-header-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

#results-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

#results-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--table-border);
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#results-table tbody tr:hover {
  background: var(--table-row-hover);
}

#results-table td a {
  color: var(--primary);
  text-decoration: none;
}

#results-table td a:hover {
  text-decoration: underline;
}

/* ===== FILTERS BAR ===== */
.filters-bar {
  padding: 0.75rem 2rem;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.filter-item {
  flex: 1;
  min-width: 140px;
}

.filter-item label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.filter-item label i {
  margin-right: 0.25rem;
  color: var(--primary);
}

.filter-item input,
.filter-item select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 0.85rem;
  transition: var(--transition);
}

.filter-item input:focus,
.filter-item select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ===== PAGINATION ===== */
.pagination-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.btn-pagination {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  padding: 0 0.5rem;
}

.btn-pagination:hover:not(:disabled) {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-pagination.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  font-weight: 700;
}

.btn-pagination:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-dots {
  color: var(--text-secondary);
  padding: 0 0.25rem;
  font-size: 0.85rem;
}

/* ===== FOOTER ===== */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

/* ===== ADMIN OVERLAY ===== */
.admin-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 10000;
  padding: 2rem 1rem;
  overflow-y: auto;
  backdrop-filter: blur(8px);
}

.admin-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  animation: fadeInUp 0.3s ease;
}

.admin-dashboard {
  max-width: 600px;
}

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

.admin-card-header h2 {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-card-body {
  padding: 1.5rem;
}

.admin-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.admin-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.admin-section h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
}

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

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
}

.form-group input {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--input-bg);
  color: var(--text-primary);
  transition: var(--transition);
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.input-with-action {
  display: flex;
  gap: 0.5rem;
}

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

/* ===== SOCIAL SELECTOR ===== */
.social-buttons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.social-selector-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.75rem 0.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.75rem;
}

.social-selector-btn i { font-size: 1.2rem; }
.social-selector-btn:hover { border-color: var(--primary); background: var(--bg-secondary); }
.social-selector-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }

.social-links-config {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.social-link-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
}

.social-link-item i {
  font-size: 1.2rem;
  width: 30px;
  text-align: center;
  color: var(--primary);
}

.social-link-item input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  background: var(--input-bg);
  color: var(--text-primary);
}

.social-link-item .btn-remove {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: var(--transition);
}

.social-link-item .btn-remove:hover { background: var(--danger-hover); }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: fadeInUp 0.3s ease;
  max-width: 320px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .app-header {
    padding: 0.75rem 1rem;
  }

  .header-left h1 {
    font-size: 1rem;
  }

  #user-name { display: none; }

  .controls-section {
    padding: 1rem;
  }

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

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

  .controls-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .results-section {
    padding: 0 0.75rem 1.5rem;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  #results-table {
    font-size: 0.75rem;
  }

  #results-table th,
  #results-table td {
    padding: 0.5rem 0.6rem;
  }

  .admin-overlay {
    padding: 1rem 0.5rem;
  }

  .admin-card-body {
    padding: 1rem;
  }

  .social-buttons-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }

  .gate-card {
    padding: 1.5rem;
  }

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

  .toast {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .header-left h1 {
    font-size: 0.9rem;
  }

  .header-left h1 i {
    display: none;
  }

  .social-buttons-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .btn {
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
  }

  .filters-bar {
    padding: 0.5rem 1rem;
  }

  .filter-item {
    min-width: 100%;
  }
}
