/* ============================================================
   META ADS UPLOADER — Stylesheet
   ============================================================ */

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

:root {
  --sidebar-bg:   #0f172a;
  --sidebar-w:    260px;
  --accent:       #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #dbeafe;
  --success:      #16a34a;
  --success-bg:   #dcfce7;
  --error:        #dc2626;
  --error-bg:     #fee2e2;
  --warning:      #d97706;
  --warning-bg:   #fef3c7;
  --bg:           #f1f5f9;
  --card:         #ffffff;
  --border:       #e2e8f0;
  --text:         #1e293b;
  --muted:        #64748b;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo h1 {
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -.3px;
}

.sidebar-logo p {
  font-size: 12px;
  color: #64748b;
  margin-top: 3px;
}

.sidebar-steps {
  padding: 24px 16px;
  flex: 1;
}

.sidebar-steps h3 {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #475569;
  margin-bottom: 12px;
  padding: 0 4px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 8px;
  border-radius: 6px;
  margin-bottom: 2px;
  cursor: default;
  transition: background .15s;
}

.step-item.clickable { cursor: pointer; }
.step-item.clickable:hover { background: rgba(255,255,255,.05); }

.step-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
  background: rgba(255,255,255,.07);
  color: #475569;
  border: 1.5px solid rgba(255,255,255,.08);
  transition: all .2s;
}

.step-label {
  font-size: 13px;
  color: #475569;
  font-weight: 500;
  transition: color .2s;
}

.step-item.completed .step-num {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.step-item.completed .step-num::after { content: "✓"; font-size: 11px; }
.step-item.completed .step-label { color: #94a3b8; }

.step-item.active .step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.step-item.active .step-label { color: #f1f5f9; font-weight: 600; }

.step-item.pending .step-num {}
.step-item.pending .step-label {}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 13px; color: #e2e8f0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .logout-link { font-size: 11px; color: #475569; text-decoration: none; cursor: pointer; }
.sidebar-user .logout-link:hover { color: #94a3b8; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */

#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 20px 32px;
}

.page-header h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.page-header p {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

.page-body {
  padding: 28px 32px;
  flex: 1;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header h3 { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* ============================================================
   FORMS
   ============================================================ */

.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

label .optional {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
  margin-left: 4px;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

input[readonly] { background: #f8fafc; color: var(--muted); }

.input-prefix {
  position: relative;
}
.input-prefix span {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--muted);
  pointer-events: none;
}
.input-prefix input { padding-left: 24px; }

.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

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

.btn-secondary { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); }

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

.btn-ghost { background: transparent; color: var(--accent); padding: 6px 10px; }
.btn-ghost:hover:not(:disabled) { background: var(--accent-light); }

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

.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-group { display: flex; gap: 10px; align-items: center; }

/* ============================================================
   AUTH SCREEN
   ============================================================ */

.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 40px;
}

.auth-logo {
  margin-bottom: 24px;
}

.auth-logo-img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  border-radius: 22%;
}

.auth-screen h2 { font-size: 24px; font-weight: 700; letter-spacing: -.5px; }
.auth-screen p { color: var(--muted); margin-top: 10px; max-width: 400px; font-size: 15px; line-height: 1.6; }
.auth-screen .btn { margin-top: 28px; }

.auth-error {
  background: var(--error-bg);
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 12px 16px;
  color: var(--error);
  font-size: 13px;
  margin-top: 16px;
  max-width: 400px;
}

/* ============================================================
   ACCOUNT SELECTION
   ============================================================ */

.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.account-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.account-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.account-card.selected { border-color: var(--accent); background: var(--accent-light); }

.account-card .acct-name { font-weight: 700; font-size: 15px; }
.account-card .acct-id   { font-size: 12px; color: var(--muted); margin-top: 2px; font-family: monospace; }
.account-card .acct-meta { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; gap: 12px; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.badge-active  { background: var(--success-bg); color: var(--success); }
.badge-paused  { background: var(--warning-bg); color: var(--warning); }
.badge-error   { background: var(--error-bg);   color: var(--error); }
.badge-info    { background: var(--accent-light); color: var(--accent); }
.badge-neutral { background: #f1f5f9; color: var(--muted); }

/* ============================================================
   CAMPAIGN / ADSET LISTS
   ============================================================ */

.list-select { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .15s;
}

.list-item:hover { border-color: var(--accent); }
.list-item.selected { border-color: var(--accent); background: var(--accent-light); }

.list-item-left .name  { font-weight: 600; font-size: 14px; }
.list-item-left .meta  { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ============================================================
   TOGGLE TABS
   ============================================================ */

.tab-group {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
  width: fit-content;
  margin-bottom: 20px;
}

.tab {
  padding: 7px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: background .15s, color .15s;
  border: none;
  background: transparent;
  font-family: inherit;
}

.tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
}

/* ============================================================
   PLACEMENT CHECKBOXES
   ============================================================ */

.placement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.placement-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: 13px;
  font-weight: 500;
  user-select: none;
}

.placement-item:hover { border-color: var(--accent); }
.placement-item.checked { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.placement-item input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); flex-shrink: 0; }

/* ============================================================
   TAG INPUT (interests / locations)
   ============================================================ */

.tag-input-wrap {
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: #fff;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 44px;
  cursor: text;
  transition: border-color .15s;
}

.tag-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
}

.tag button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: .7;
}
.tag button:hover { opacity: 1; }

.tag-input-wrap input {
  border: none !important;
  box-shadow: none !important;
  padding: 2px 6px !important;
  min-width: 120px;
  flex: 1;
  font-size: 13px;
}

.autocomplete-list {
  position: absolute;
  z-index: 1000;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  max-height: 200px;
  overflow-y: auto;
  width: 100%;
  top: 100%;
  left: 0;
  margin-top: 4px;
}

.autocomplete-list li {
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  list-style: none;
}
.autocomplete-list li:hover { background: var(--bg); }

.relative { position: relative; }

/* ============================================================
   DRAG & DROP IMAGE UPLOAD
   ============================================================ */

.adset-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.adset-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  border-radius: var(--radius) var(--radius) 0 0;
}

.adset-block-header .adset-num {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
}

.adset-block-body { padding: 16px; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: #f8fafc;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.drop-zone p { font-size: 14px; color: var(--muted); margin-top: 8px; }
.drop-zone .drop-icon { font-size: 36px; }
.drop-zone .drop-btn { font-size: 13px; color: var(--accent); font-weight: 600; text-decoration: underline; cursor: pointer; }

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.image-thumb {
  border: 1.5px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #f8fafc;
  position: relative;
}

.image-thumb img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}

.image-thumb .thumb-name {
  padding: 6px 8px;
}

.image-thumb .thumb-name input {
  width: 100%;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 4px;
}

.image-thumb .thumb-remove {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,.55);
  color: #fff;
  border: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.image-thumb .thumb-remove:hover { background: var(--error); }

.image-thumb.uploading { opacity: .6; }
.image-thumb.upload-error { border-color: var(--error); }
.image-thumb.upload-ok { border-color: var(--success); }

.thumb-status {
  position: absolute;
  bottom: 4px; right: 4px;
  font-size: 16px;
}

/* ============================================================
   REVIEW STEP
   ============================================================ */

.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.review-section { margin-bottom: 24px; }
.review-section h4 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.review-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.review-table td { padding: 7px 0; vertical-align: top; }
.review-table td:first-child { color: var(--muted); width: 50%; padding-right: 12px; }
.review-table td:last-child { font-weight: 500; }

.ai-verification {
  background: var(--success-bg);
  border: 1px solid #86efac;
  border-radius: var(--radius);
  padding: 16px 20px;
}

.ai-verification h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px;
}

.ai-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #166534;
}

.ai-check-item .check { font-size: 14px; }

.adset-summary {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
}

.adset-summary-header {
  background: #f8fafc;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.adset-summary-body {
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.img-tag {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--muted);
}

/* ============================================================
   RESULTS STEP
   ============================================================ */

.progress-bar-wrap {
  background: var(--border);
  border-radius: 99px;
  height: 8px;
  margin: 12px 0;
  overflow: hidden;
}

.progress-bar {
  background: var(--accent);
  height: 100%;
  border-radius: 99px;
  transition: width .3s ease;
}

.result-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.result-item.success { border-color: #86efac; background: var(--success-bg); }
.result-item.error   { border-color: #fca5a5; background: var(--error-bg); }
.result-item.pending { background: #f8fafc; }

.result-icon { font-size: 18px; flex-shrink: 0; }
.result-name { font-weight: 600; flex: 1; }
.result-detail { font-size: 11px; color: var(--muted); }
.result-error-msg { font-size: 11px; color: var(--error); }

/* ============================================================
   LOADING / EMPTY STATES
   ============================================================ */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--muted);
  gap: 10px;
  font-size: 14px;
}

.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
  font-size: 14px;
}

.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }

/* ============================================================
   ALERT / NOTICE BANNERS
   ============================================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-icon { font-size: 16px; flex-shrink: 0; }
.alert-info    { background: var(--accent-light); color: #1e40af; border: 1px solid #93c5fd; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fcd34d; }
.alert-error   { background: var(--error-bg); color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-bg); color: #14532d; border: 1px solid #86efac; }

/* ============================================================
   MISC UTILITIES
   ============================================================ */

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--muted); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ============================================================
   Transmission loader — Hue Waveform
   ============================================================ */

.trippy-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px;
  gap: 18px;
}

#transmit-wave {
  display: block;
  border-radius: 8px;
  max-width: 100%;
}

.transmit-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  animation: text-pulse 2s ease-in-out infinite;
}

@keyframes text-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
