/* ==========================================
   Event Collector - Admin Styles
   Professional, clean, modern design
   ========================================== */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  /* Colors */
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --primary-light: #DBEAFE;
  --success: #10B981;
  --success-light: #D1FAE5;
  --danger: #EF4444;
  --danger-hover: #DC2626;
  --danger-light: #FEE2E2;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --info: #6366F1;
  --info-light: #EEF2FF;
  
  /* Neutrals */
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Borders */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
}

/* ==========================================
   Layout
   ========================================== */
.admin-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-lg);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--gray-200);
}

.admin-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.025em;
}

.admin-subtitle {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.admin-user-name {
  font-size: 0.875rem;
  color: var(--gray-600);
}

/* ==========================================
   Cards
   ========================================== */
.card {
  background: white;
  border-radius: var(--radius-xl);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-800);
}

.card-body {
  padding: var(--space-lg);
}

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

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  transition: all 0.2s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

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

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.purple { background: var(--info-light); color: var(--info); }

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-top: 0.125rem;
}

/* ==========================================
   Buttons
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-200);
}

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

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

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--gray-100);
  color: var(--gray-800);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-icon {
  padding: 0.5rem;
}

/* ==========================================
   Forms
   ========================================== */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: var(--space-sm);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-family: var(--font-family);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: white;
  color: var(--gray-800);
  transition: all 0.2s ease;
}

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

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--gray-400);
}

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

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}

.form-help {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-top: 0.375rem;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--gray-300);
  accent-color: var(--primary);
  cursor: pointer;
}

/* Grid */
.grid {
  display: grid;
  gap: var(--space-lg);
}

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

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

@media (max-width: 768px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* ==========================================
   Tables
   ========================================== */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
}

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

.table th {
  padding: 0.875rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.table td {
  padding: 1rem;
  font-size: 0.9375rem;
  color: var(--gray-800);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

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

.table tr:hover td {
  background: var(--gray-50);
}

/* Table cells */
.event-name {
  font-weight: 600;
  color: var(--gray-900);
}

.event-desc {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

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

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

.badge-inactive {
  background: var(--gray-100);
  color: var(--gray-500);
}

.slug {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.8125rem;
  color: var(--gray-600);
  background: var(--gray-100);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

/* ==========================================
   Actions
   ========================================== */
.actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.action-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.action-edit {
  background: var(--gray-100);
  color: var(--gray-700);
}

.action-edit:hover {
  background: var(--gray-200);
}

.action-view {
  background: var(--primary-light);
  color: var(--primary);
}

.action-view:hover {
  background: #BFDBFE;
}

.action-qr {
  background: #FEF3C7;
  color: var(--warning);
}

.action-qr:hover {
  background: #FDE68A;
}

.action-delete {
  background: var(--danger-light);
  color: var(--danger);
}

.action-delete:hover {
  background: #FECACA;
}

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

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  font-size: 0.9375rem;
  font-weight: 500;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  pointer-events: auto;
  max-width: 360px;
}

.toast.show {
  transform: translateX(0);
}

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

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

.toast-warning {
  border-left: 4px solid var(--warning);
}

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

/* ==========================================
   Modal
   ========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.show,
.modal-overlay:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 420px;
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.show .modal {
  transform: scale(1);
}

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

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-900);
}

.modal-body {
  padding: 1.5rem;
}

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

/* Confirm Modal */
.confirm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.confirm-modal-overlay.show {
  opacity: 1;
}

.confirm-modal {
  background: white;
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.confirm-modal-overlay.show .confirm-modal {
  transform: scale(1);
}

.confirm-message {
  font-size: 1rem;
  color: var(--gray-800);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.confirm-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.confirm-btn {
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.confirm-btn-cancel {
  background: var(--gray-100);
  color: var(--gray-700);
}

.confirm-btn-cancel:hover {
  background: var(--gray-200);
}

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

.confirm-btn-confirm:hover {
  background: var(--danger-hover);
}

/* ==========================================
   Empty State
   ========================================== */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--gray-500);
}

.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  background: var(--gray-100);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-icon svg {
  width: 32px;
  height: 32px;
  color: var(--gray-400);
}

.empty-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.5rem;
}

.empty-text {
  margin-bottom: 1.5rem;
}

/* ==========================================
   Utilities
   ========================================== */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.875rem; }
.text-danger { color: var(--danger); }
.w-full { width: 100%; }

/* Page sections */
.page-section {
  background: white;
  border-radius: var(--radius-xl);
  border: 1px solid var(--gray-200);
  margin-bottom: var(--space-xl);
  overflow: hidden;
}

.section-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.section-body {
  padding: var(--space-lg);
}

/* Chart */
.chart-container {
  margin-top: var(--space-lg);
}

.chart-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: var(--space-lg);
}

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

.chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.chart-subtitle {
  font-size: 0.8125rem;
  color: var(--gray-500);
}

.chart-wrapper {
  height: 200px;
  position: relative;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 160px;
  gap: 8px;
  padding: 0 8px;
}

.chart-bar-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.chart-bar {
  width: 100%;
  max-width: 40px;
  background: linear-gradient(to top, var(--primary), #60A5FA);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height 0.3s ease;
  min-height: 4px;
}

.chart-bar:hover {
  opacity: 0.8;
}

.chart-label {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  color: var(--gray-400);
  font-size: 0.875rem;
}

/* Activity compact */
.activity-compact {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.activity-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--gray-50);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.activity-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.activity-chip-time {
  color: var(--gray-400);
  font-size: 0.75rem;
}

/* Color inputs */
.color-input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-input-group input[type="color"] {
  width: 48px;
  height: 40px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 0;
}

.color-input-group input[type="text"] {
  flex: 1;
}

/* Back link */
.back-link {
  color: var(--gray-500);
  text-decoration: none;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.back-link:hover {
  color: var(--gray-700);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-top: 1px solid var(--gray-200);
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--gray-600);
}

.pagination-buttons {
  display: flex;
  gap: 0.5rem;
}

.pagination-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: white;
  color: var(--gray-700);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--gray-50);
}

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

/* Modal for field editor */
.modal-content {
  max-height: 80vh;
  overflow-y: auto;
}

/* Field list in builder */
.field-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.field-item {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  transition: all 0.2s ease;
}

.field-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

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

.field-item-label {
  font-weight: 600;
  color: var(--gray-800);
}

.field-item-type {
  font-size: 0.75rem;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
}

.field-item-meta {
  display: flex;
  gap: var(--space-md);
  font-size: 0.8125rem;
  color: var(--gray-500);
}

.field-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--gray-100);
}

/* Logo preview */
.logo-preview {
  margin-top: 1rem;
}

.logo-preview img {
  max-width: 150px;
  max-height: 80px;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
}

/* QR Modal */
.qr-modal-content {
  text-align: center;
}

.qr-modal-content img {
  max-width: 250px;
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
}

.qr-url {
  font-size: 0.8125rem;
  color: var(--gray-600);
  word-break: break-all;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--gray-50);
  border-radius: var(--radius-md);
}

/* Field type icon */
.field-type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-right: 0.5rem;
  color: var(--gray-500);
}

.field-type-icon svg {
  width: 16px;
  height: 16px;
}

/* Responsive */
@media (max-width: 768px) {
  .admin-container {
    padding: var(--space-md);
  }
  
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .table-container {
    font-size: 0.875rem;
  }
  
  .actions {
    flex-direction: column;
  }
  
  .action-btn {
    justify-content: center;
  }
}