/* Dealer Ads Manager — V3 Frontend Styles */
/* Extracted from V2 server.js embedded template */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #050b14;
  --bg2:       #060d18;
  --bg3:       #0a1220;
  --border:    #1e2d45;
  --border2:   #0d1629;
  --text:      #e2e8f0;
  --text2:     #94a3b8;
  --text3:     #475569;
  --text4:     #334155;
  --blue:      #3b82f6;
  --blue-dark: #1d4ed8;
  --green:     #4ade80;
  --orange:    #fb923c;
  --red:       #f87171;
  --purple:    #a78bfa;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border2);
  background: rgba(255,255,255,.015);
  flex-shrink: 0;
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.logo-text {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: #f1f5f9;
  letter-spacing: -.3px;
}
.logo-sub {
  font-size: 10px;
  color: var(--text4);
  margin-top: 1px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.connect-btn {
  background: linear-gradient(135deg, #0f4c9e, #1d4ed8);
  border: none;
  color: white;
  padding: 8px 20px;
  font-size: 13px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  border-radius: 7px;
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 0 20px rgba(29,78,216,.3);
}
.connect-btn:hover {
  background: linear-gradient(135deg, #1d6fd8, #3b82f6);
  transform: translateY(-1px);
}
.connected-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #071a0e;
  border: 1px solid #166534;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--green);
}
.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulseDot 2s ease-in-out infinite;
}
@keyframes pulseDot {
  0%,100% { opacity:1; transform:scale(1); }
  50%     { opacity:.4; transform:scale(.65); }
}
.logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text3);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  transition: all .15s;
}
.logout-btn:hover { color: var(--text2); border-color: #2d4a6e; }
.nav-link {
  color: var(--text3);
  text-decoration: none;
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  padding: 6px 14px;
  border: 2px solid #7c3aed;
  border-radius: 6px;
  transition: all .15s;
}
.nav-link:hover { color: var(--text2); border-color: #a78bfa; }

/* ── MAIN LAYOUT ── */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 61px);
}

/* ── SIDEBAR ── */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border2);
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar-section {
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--border2);
}
.sidebar-label {
  font-size: 10px;
  color: var(--text4);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* Account selector */
.account-select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-family: 'DM Mono', monospace;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.account-select:focus { outline: none; border-color: var(--blue); }

/* Account tree */
.tree { padding: 8px 0; flex: 1; }
.tree-campaign {
  border-bottom: 1px solid var(--border2);
}
.tree-camp-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 16px;
  cursor: pointer;
  transition: background .1s;
  font-size: 12px;
}
.tree-camp-header:hover { background: rgba(255,255,255,.025); }
.tree-camp-header.open { background: #0a1628; }
.tree-arrow { color: var(--text4); font-size: 9px; width: 10px; flex-shrink: 0; }
.tree-camp-name { color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.enabled  { background: var(--green); }
.status-dot.paused   { background: var(--orange); }
.status-dot.removed  { background: var(--red); }
.tree-budget { font-size: 10px; color: var(--text4); flex-shrink: 0; }

.tree-ag {
  background: #040a12;
  border-bottom: 1px solid #080f1a;
}
.tree-ag-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 16px 5px 32px;
  cursor: pointer;
  font-size: 11.5px;
  transition: background .1s;
}
.tree-ag-header:hover { background: rgba(255,255,255,.02); }
.tree-ag-name { color: var(--text2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-kw-count { font-size: 10px; color: var(--text4); flex-shrink: 0; }

.tree-keywords { background: #020609; }
.tree-kw {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 16px 4px 52px;
  border-bottom: 1px solid #06090f;
  font-size: 11px;
}
.match-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}
.match-badge.exact   { background: #1a2e50; color: #60a5fa; border: 1px solid #1d4ed8; }
.match-badge.phrase  { background: #2d1a50; color: #a78bfa; border: 1px solid #6d28d9; }
.match-badge.broad   { background: #1a2a1a; color: #6b7280; border: 1px solid #374151; }
.kw-text { color: #cbd5e1; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── CONTENT AREA ── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* Not connected state */
.not-connected {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  gap: 16px;
}
.not-connected-icon {
  width: 64px; height: 64px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.not-connected h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: #f1f5f9;
}
.not-connected p {
  font-size: 13px;
  color: var(--text3);
  max-width: 340px;
  line-height: 1.6;
}

/* Freshdesk panel */
.freshdesk-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
  overflow: hidden;
}
.freshdesk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border2);
}
.freshdesk-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text4);
}
.freshdesk-refresh-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text3);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 7px;
  line-height: 1;
}
.freshdesk-refresh-btn:hover { color: var(--text2); border-color: #2d4a6e; }
.freshdesk-list {
  max-height: 200px;
  overflow-y: auto;
}
.freshdesk-ticket {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border2);
  transition: background 0.15s;
}
.freshdesk-ticket:last-child { border-bottom: none; }
.freshdesk-ticket:hover { background: var(--bg3); }
.freshdesk-ticket.selected { background: #0c1a30; border-left: 2px solid var(--blue); }
.freshdesk-priority-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.freshdesk-priority-dot.urgent { background: var(--red); }
.freshdesk-priority-dot.high   { background: var(--orange); }
.freshdesk-priority-dot.medium { background: var(--blue); }
.freshdesk-priority-dot.low    { background: var(--green); }
.freshdesk-ticket-body { flex: 1; min-width: 0; }
.freshdesk-ticket-subject {
  font-size: 12.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.freshdesk-ticket-meta {
  font-size: 10px;
  color: var(--text4);
  margin-top: 2px;
}
.freshdesk-empty {
  padding: 14px;
  text-align: center;
  color: var(--text4);
  font-size: 12px;
}

/* Task area */
.task-area { max-width: 780px; }
.section-title {
  font-size: 11px;
  color: var(--text4);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.task-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
}
.task-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border2);
}
.task-box-dots {
  display: flex;
  gap: 5px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; }
textarea {
  width: 100%;
  min-height: 180px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.75;
  padding: 16px 18px;
  resize: vertical;
  font-family: 'DM Mono', monospace;
}
textarea:focus { outline: none; }
textarea::placeholder { color: var(--text4); }

.btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.btn-primary {
  background: linear-gradient(135deg, #0f4c9e, #1d4ed8);
  border: none; color: white;
  padding: 12px 26px;
  font-size: 14px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 0 20px rgba(29,78,216,.3);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d6fd8, #3b82f6);
  transform: translateY(-1px);
}
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-secondary {
  background: none;
  border: 1px solid var(--border);
  color: var(--text3);
  padding: 10px 18px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12.5px;
  font-family: 'DM Mono', monospace;
  transition: all .15s;
}
.btn-secondary:hover { border-color: #2d4a6e; color: var(--text2); }

/* Plan card */
.plan-card {
  background: var(--bg2);
  border: 1px solid #1e3a5f;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
  animation: slideUp .3s ease-out;
}
@keyframes slideUp {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:translateY(0); }
}
.plan-header {
  padding: 14px 18px;
  background: #0a1628;
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.plan-summary {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  color: #93c5fd;
  font-weight: 500;
  flex: 1;
}
.plan-count {
  font-size: 11px;
  color: var(--text4);
  flex-shrink: 0;
}

.change-list { padding: 8px 0; }
.change-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border2);
  font-size: 12.5px;
}
.change-item:last-child { border-bottom: none; }
.change-type-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  font-weight: 500;
  margin-top: 1px;
}
.change-desc { color: var(--text2); line-height: 1.5; }
.change-campaign { color: var(--text3); font-size: 11px; margin-top: 2px; }

.warnings-box {
  background: #2a1f0d;
  border: 1px solid #92400e;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 14px;
}
.warnings-title {
  font-size: 11px;
  color: #f59e0b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.warning-item {
  font-size: 12.5px;
  color: #fbbf24;
  margin-top: 4px;
}

/* Apply buttons */
.apply-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.btn-dryrun {
  background: #1a2e50;
  border: 1px solid #1d4ed8;
  color: #93c5fd;
  padding: 11px 22px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  transition: all .2s;
}
.btn-dryrun:hover { background: #1e3a6a; }
.btn-apply {
  background: linear-gradient(135deg, #065f46, #059669);
  border: none;
  color: white;
  padding: 11px 26px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  transition: all .2s;
  box-shadow: 0 0 20px rgba(5,150,105,.3);
}
.btn-apply:hover { background: linear-gradient(135deg, #047857, #10b981); transform: translateY(-1px); }
.btn-apply:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* Results */
.results-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
  animation: slideUp .3s ease-out;
}
.results-header {
  padding: 12px 18px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border2);
  font-size: 12px;
  color: var(--text3);
}
.result-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border2);
  font-size: 12.5px;
}
.result-item:last-child { border-bottom: none; }
.result-icon { flex-shrink: 0; font-size: 13px; }
.result-text { color: var(--text2); }

/* Loading spinner */
.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state for account tree */
.tree-empty {
  padding: 20px 16px;
  font-size: 12px;
  color: var(--text4);
  line-height: 1.6;
  text-align: center;
}

/* No account selected */
.select-account-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  text-align: center;
}
.select-account-prompt p {
  font-size: 13px;
  color: var(--text3);
  max-width: 300px;
  line-height: 1.6;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #071a0e;
  border: 1px solid #166534;
  color: var(--green);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  animation: toastIn .3s ease-out;
  z-index: 1000;
}
@keyframes toastIn {
  from { opacity:0; transform:translateY(10px); }
  to   { opacity:1; transform:translateY(0); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
