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

:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --border-hover: #D1D5DB;
  --text: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --success: #059669;
  --success-bg: #D1FAE5;
  --warning: #D97706;
  --warning-bg: #FEF3C7;
  --danger: #DC2626;
  --danger-bg: #FEE2E2;
  --yelp: #FF1A1A;
  --google: #4285F4;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --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);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* Header */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-left { flex: 0 0 auto; }
.header-center { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; }
.header-right { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }

.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 18px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}
.logo-name { font-weight: 700; font-size: 17px; color: var(--text); letter-spacing: -0.3px; }
.logo-name span { color: var(--primary); }
.logo-tagline { font-size: 11px; color: var(--text-muted); font-weight: 400; }

.stat-card {
  text-align: center; padding: 6px 16px;
  border-right: 1px solid var(--border);
}
.stat-card:last-child { border-right: none; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text); }
.stat-value.pending { color: var(--warning); }
.stat-value.success { color: var(--success); }
.stat-value.draft { color: var(--primary); }
.stat-label { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  transition: all 0.15s ease; white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text-secondary); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); border-color: var(--border-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-google { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-google:hover:not(:disabled) { background: #F8FAFF; border-color: #93C5FD; }
.btn-google.connected { color: var(--success); border-color: #A7F3D0; background: #F0FDF4; }
.btn-sync { background: var(--surface); color: var(--primary); border-color: var(--border); }
.btn-sync:hover:not(:disabled) { background: var(--primary-light); border-color: var(--primary); }
.btn-sync.loading svg { animation: spin 1s linear infinite; }
.btn-demo { background: #FFF7ED; color: #C2410C; border: 1px solid #FED7AA; font-size: 13px; }
.btn-demo:hover { background: #FEF3C7; border-color: #FBB04C; }
.btn-batch { background: linear-gradient(135deg, #7C3AED, var(--primary)); color: white; border: none; font-size: 12px; padding: 7px 14px; }
.btn-batch:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border); cursor: pointer;
  color: var(--text-secondary); transition: all 0.15s ease;
}
.btn-icon:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #FECACA; }
.btn-danger:hover { background: #FEE2E2; }

/* Layout */
.layout { display: flex; height: calc(100vh - 64px); overflow: hidden; }

/* Sidebar */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  padding: 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h3 { font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

.businesses-list { flex: 1; overflow-y: auto; padding: 8px; }
.empty-sidebar { padding: 24px 8px; text-align: center; color: var(--text-muted); font-size: 13px; }
.empty-sidebar p { margin-bottom: 12px; }

.biz-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.15s;
  border: 1px solid transparent; margin-bottom: 3px;
  position: relative;
}
.biz-item:hover, .biz-item.active {
  background: var(--primary-light); border-color: #C7D2FE;
}
.biz-source-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.biz-source-dot.yelp { background: var(--yelp); }
.biz-source-dot.google { background: var(--google); }
.biz-name { font-size: 13px; font-weight: 500; color: var(--text); flex: 1; line-height: 1.3; }
.biz-count { font-size: 11px; color: var(--text-muted); }
.biz-remove {
  opacity: 0; width: 20px; height: 20px; border-radius: 4px;
  background: var(--danger-bg); color: var(--danger);
  border: none; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s; flex-shrink: 0;
}
.biz-item:hover .biz-remove { opacity: 1; }

/* Main Content */
.main-content { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }

/* Filters */
.filters-bar {
  background: var(--surface); border-radius: var(--radius);
  padding: 10px 16px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.filter-tabs { display: flex; align-items: center; gap: 4px; }
.filter-tab {
  padding: 6px 14px; border-radius: 20px;
  border: 1px solid transparent; background: none;
  font-size: 13px; font-weight: 500; cursor: pointer;
  color: var(--text-secondary); transition: all 0.15s;
  display: flex; align-items: center; gap: 5px; font-family: inherit;
}
.filter-tab:hover { background: var(--bg); color: var(--text); }
.filter-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.badge {
  background: var(--warning-bg); color: var(--warning);
  font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 10px;
}
.filter-tab.active .badge { background: rgba(255,255,255,0.25); color: white; }
.filter-actions { display: flex; align-items: center; gap: 8px; }
.sort-select {
  padding: 6px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; font-family: inherit; color: var(--text);
  cursor: pointer;
}

/* Reviews Container */
.reviews-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(520px, 1fr)); gap: 14px; align-content: start; }

.empty-state {
  grid-column: 1 / -1; text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* Review Card */
.review-card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  overflow: hidden; transition: box-shadow 0.15s, border-color 0.15s;
}
.review-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-hover); }

.card-header { padding: 14px 16px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.reviewer-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px; color: white; flex-shrink: 0;
  background: linear-gradient(135deg, #667eea, #764ba2);
}
.reviewer-meta { flex: 1; min-width: 0; }
.reviewer-name { font-weight: 600; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review-date { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.card-badges { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.source-badge {
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 10px;
  display: flex; align-items: center; gap: 4px;
}
.source-badge.yelp { background: #FFF0F0; color: var(--yelp); }
.source-badge.google { background: #EFF6FF; color: var(--google); }
.status-badge {
  font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 10px;
}
.status-badge.pending { background: var(--warning-bg); color: var(--warning); }
.status-badge.draft { background: var(--primary-light); color: var(--primary); }
.status-badge.published { background: var(--success-bg); color: var(--success); }

.card-business { padding: 6px 16px 0; font-size: 12px; color: var(--text-muted); font-weight: 500; }

.stars { display: flex; align-items: center; gap: 2px; padding: 8px 16px 0; }
.star { color: #D1D5DB; font-size: 14px; }
.star.filled { color: #F59E0B; }

.review-text {
  padding: 8px 16px 14px; font-size: 14px; color: var(--text); line-height: 1.6;
  border-bottom: 1px solid var(--border);
}
.review-text.truncated { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.read-more { font-size: 12px; color: var(--primary); cursor: pointer; background: none; border: none; padding: 4px 16px; display: block; font-family: inherit; }
.read-more:hover { text-decoration: underline; }

/* Reply Section */
.reply-section { padding: 14px 16px; }
.reply-section.has-reply { background: #FAFAFA; }

.reply-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.reply-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.reply-tone {
  font-size: 12px; padding: 3px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  font-family: inherit; color: var(--text-secondary); cursor: pointer;
}

.existing-reply {
  background: var(--success-bg); border: 1px solid #A7F3D0;
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 13px; color: #065F46; line-height: 1.5; margin-bottom: 8px;
}
.existing-reply-label { font-size: 11px; font-weight: 600; color: var(--success); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

.reply-textarea {
  width: 100%; min-height: 90px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; color: var(--text);
  resize: vertical; line-height: 1.5; background: var(--surface);
  transition: border-color 0.15s;
}
.reply-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.reply-textarea.generating { opacity: 0.6; background: var(--bg); }

.reply-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.reply-actions .btn { font-size: 12px; padding: 6px 14px; }
.char-count { font-size: 11px; color: var(--text-muted); margin-left: auto; }

/* Spinning loader */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; }
.spinner.dark { border-color: rgba(79,70,229,0.2); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 1000; padding: 60px 16px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 580px; max-height: 80vh;
  box-shadow: var(--shadow-lg); overflow: hidden;
  display: flex; flex-direction: column;
  animation: modalIn 0.2s ease;
}
.modal-sm { max-width: 420px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

.modal-header {
  padding: 18px 20px 14px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--bg);
  font-size: 20px; cursor: pointer; color: var(--text-muted); display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }

.modal-tabs { display: flex; border-bottom: 1px solid var(--border); }
.modal-tab {
  flex: 1; padding: 12px; border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--text-secondary); font-family: inherit;
  border-bottom: 2px solid transparent; transition: all 0.15s; margin-bottom: -1px;
}
.modal-tab:hover { color: var(--text); background: var(--bg); }
.modal-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: none; }

.modal-tab-content { display: none; padding: 20px; overflow-y: auto; }
.modal-tab-content.active { display: block; }

.search-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  background: var(--surface); color: var(--text); transition: border-color 0.15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }

.search-results { max-height: 320px; overflow-y: auto; }
.search-result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 8px; transition: all 0.15s; cursor: default;
}
.search-result-item:hover { border-color: var(--primary); background: var(--primary-light); }
.result-image {
  width: 48px; height: 48px; border-radius: var(--radius-sm); object-fit: cover;
  background: var(--bg); flex-shrink: 0;
}
.result-info { flex: 1; min-width: 0; }
.result-name { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.result-meta { font-size: 12px; color: var(--text-muted); }
.result-rating { color: #F59E0B; }

.google-auth-prompt { text-align: center; padding: 30px 20px; color: var(--text-secondary); }
.google-auth-prompt p { margin-bottom: 16px; }

.location-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.location-item-name { font-weight: 500; }
.location-item-addr { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.code-block {
  background: #F3F4F6; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px; font-family: 'Courier New', monospace; font-size: 13px;
  color: var(--primary); margin: 12px 0; word-break: break-all;
}
.hint { font-size: 12px; color: var(--text-muted); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: white; padding: 12px 18px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); min-width: 250px; max-width: 380px;
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.25s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(30px); } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

/* Loading */
.loading-reviews { grid-column: 1/-1; text-align: center; padding: 40px; color: var(--text-muted); }
.pulse { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

@media (max-width: 900px) {
  .sidebar { width: 200px; }
  .reviews-container { grid-template-columns: 1fr; }
  .header-center { display: none; }
}
