/* SyncVDS Admin — Styles */
:root {
  --primary: #4f46e5;
  --primary-light: #e0e7ff;
  --primary-dark: #3730a3;
  --green: #16a34a;
  --green-light: #dcfce7;
  --green-dark: #15803d;
  --red: #dc2626;
  --red-light: #fee2e2;
  --red-dark: #b91c1c;
  --orange: #ea580c;
  --orange-light: #fff7ed;
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --purple: #9333ea;
  --teal: #0d9488;
  --teal-light: #ccfbf1;
  --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;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
}

/* Layout */
.app-header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.app-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-nav { display: flex; gap: 4px; }
.app-nav button {
  background: none;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.app-nav button:hover { background: var(--gray-100); color: var(--gray-700); }
.app-nav button.active { background: var(--primary-light); color: var(--primary); }

.page { max-width: 900px; margin: 0 auto; padding: 24px; }

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 12px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-green { background: var(--green); color: white; }
.btn-green:hover:not(:disabled) { background: var(--green-dark); }
.btn-red { background: var(--red); color: white; }
.btn-red:hover:not(:disabled) { background: var(--red-dark); }
.btn-outline {
  background: white;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-400); }
.btn-ghost { background: none; color: var(--gray-500); }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--gray-700); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: 6px; }
.btn-danger-text { background: none; color: var(--red); font-size: 12px; }
.btn-danger-text:hover { background: var(--red-light); }

/* Inputs */
.input-group { margin-bottom: 14px; }
.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 4px;
}
.input-group input, .input-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.input-group input:focus, .input-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn .15s;
}
.modal {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 90%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s;
}
.modal-header {
  padding: 20px 24px 0;
  font-size: 18px;
  font-weight: 700;
}
.modal-body { padding: 16px 24px; }
.modal-footer {
  padding: 12px 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 16px;
  border-radius: 10px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideUp .2s;
  max-width: 360px;
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-warning { background: var(--orange); }

/* Client list */
.client-row {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background .1s;
}
.client-row:last-child { border-bottom: none; }
.client-row:hover { background: var(--gray-50); }
.client-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.client-avatar.active { background: var(--primary-light); color: var(--primary); }
.client-avatar.inactive { background: var(--gray-200); color: var(--gray-400); }
.client-info { flex: 1; margin-left: 14px; min-width: 0; }
.client-name { font-weight: 600; font-size: 15px; }
.client-sub { font-size: 13px; color: var(--gray-500); }
.client-actions { display: flex; align-items: center; gap: 6px; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-inactive { background: var(--orange-light); color: var(--orange); }
.badge-active { background: var(--green-light); color: var(--green-dark); }
.badge-expired { background: var(--red-light); color: var(--red-dark); }
.badge-days { background: var(--green-light); color: var(--green-dark); }

/* Detail page */
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.back-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray-500);
  padding: 4px;
  border-radius: 6px;
}
.back-btn:hover { background: var(--gray-100); }

.info-card { padding: 20px; }
.info-card .avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  flex-shrink: 0;
}
.info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--gray-600);
  margin-top: 6px;
}

.tariff-bar {
  padding: 10px 16px;
  background: var(--primary-light);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

/* Shop card */
.shop-card { margin-bottom: 12px; }
.shop-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
}
.shop-header:hover { background: var(--gray-50); }
.shop-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}
.shop-icon.active { background: var(--teal-light); color: var(--teal); }
.shop-icon.inactive { background: var(--gray-200); color: var(--gray-400); }
.shop-info { flex: 1; margin-left: 12px; }
.shop-name { font-weight: 600; font-size: 14px; }
.shop-db { font-size: 11px; color: var(--gray-400); font-family: monospace; }
.shop-expand { color: var(--gray-400); transition: transform .2s; }
.shop-expand.open { transform: rotate(180deg); }
.shop-body { padding: 0 18px 18px; display: none; }
.shop-body.open { display: block; }

/* Subscription banner */
.sub-banner {
  padding: 12px 14px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.sub-banner.active {
  background: linear-gradient(135deg, #22c55e, #14b8a6);
  color: white;
}
.sub-banner.inactive {
  background: var(--red-light);
  border: 1px solid #fecaca;
  color: var(--red-dark);
}
.sub-banner .sub-text { flex: 1; }
.sub-banner .sub-text strong { display: block; font-size: 14px; }
.sub-banner .sub-text small { font-size: 12px; opacity: .8; }
.sub-days {
  padding: 4px 10px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 13px;
}
.sub-banner.active .sub-days { background: rgba(255,255,255,.2); }

/* Payment row */
.payment-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: 10px;
  margin-bottom: 6px;
}
.pay-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.pay-info { flex: 1; }
.pay-amount { font-weight: 700; font-size: 14px; }
.pay-days { font-size: 11px; font-weight: 700; color: var(--green-dark); background: var(--green-light); padding: 1px 6px; border-radius: 8px; margin-left: 6px; }
.pay-meta { font-size: 11px; color: var(--gray-500); }
.pay-comment { font-size: 11px; color: var(--gray-400); }

/* Preview box */
.preview-box {
  padding: 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-weight: 700;
  font-size: 16px;
}
.preview-box.green { background: var(--green-light); border: 1px solid #bbf7d0; color: var(--green-dark); }
.preview-box.blue { background: var(--blue-light); border: 1px solid #bfdbfe; color: var(--blue); }

/* Settings */
.settings-section { margin-bottom: 32px; }
.settings-section h2 { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.tariff-card {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: background .1s;
}
.tariff-card:hover { background: var(--gray-50); }
.tariff-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.tariff-info { flex: 1; }
.tariff-price { font-size: 18px; font-weight: 700; }
.tariff-daily { font-size: 13px; color: var(--gray-500); }

.test-result {
  margin-top: 12px;
  font-size: 15px;
  font-weight: 600;
}
.test-result.ok { color: var(--green); }
.test-result.fail { color: var(--red); }

/* Setup screen */
.setup-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
}
.setup-box {
  text-align: center;
  padding: 48px;
}
.setup-box .icon { font-size: 64px; color: var(--primary); margin-bottom: 16px; }
.setup-box h2 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.setup-box p { color: var(--gray-500); font-size: 16px; margin-bottom: 24px; }

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--gray-400);
  font-size: 15px;
}
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}
.empty .icon { font-size: 48px; margin-bottom: 12px; }
.empty p { font-size: 16px; }

/* Error state */
.error-state {
  text-align: center;
  padding: 48px 24px;
}
.error-state .icon { font-size: 48px; color: var(--red); margin-bottom: 12px; }
.error-state p { color: var(--gray-600); margin-bottom: 16px; }

/* Responsive */
@media (max-width: 640px) {
  .page { padding: 12px; }
  .modal { width: 95%; max-width: none; }
  .app-header { padding: 0 12px; }
  .info-card { padding: 14px; }
}

/* Divider */
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 14px 0; }

/* Flex helpers */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.ml-auto { margin-left: auto; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--gray-500); }
.fw-600 { font-weight: 600; }
