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

/* ─── Variables ─────────────────────────────────────────── */
:root {
  --primary: #000000;
  --primary-hover: #161616;
  --primary-light: #eef2ff;
  --primary-mid: rgba(79, 70, 229, 0.15);

  --success: #059669;
  --success-hover: #047857;
  --success-light: #d1fae5;

  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-light: #fee2e2;

  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --border-focus: #a5b4fc;

  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --header-h: 68px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08),
    0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -4px rgba(0, 0, 0, 0.07);
}

/* ─── Reset / Base ──────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

/* ─── Header ────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: linear-gradient(135deg, #000000 0%, #333333 100%);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.app-logo-icon {
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: white;
}

.app-logo-icon svg {
  width: 22px;
  height: 22px;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.2;
}

.app-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  margin: 0;
  line-height: 1;
}

.app-badge {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: white;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 4px 14px;
  border-radius: 20px;
}

/* ─── Main ──────────────────────────────────────────────── */
.app-main {
  padding: 24px 0 48px;
}

/* ─── Card Panel ────────────────────────────────────────── */
.card-panel {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  flex-shrink: 0;
}

.panel-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.panel-label svg {
  width: 15px;
  height: 15px;
  color: var(--primary);
  flex-shrink: 0;
}

.areas-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 22px;
  text-align: center;
  line-height: 1.6;
}

.card-panel-body {
  padding: 20px;
  flex: 1;
}

.card-panel-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  flex-shrink: 0;
}

/* ─── Upload Zone ───────────────────────────────────────── */
#uploadLabel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 300px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #fafbfc;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
  text-align: center;
  padding: 40px 24px;
  margin: 0;
  color: var(--text-muted);
  position: relative;
  overflow: hidden;
}

#uploadLabel:hover,
#uploadLabel.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

#uploadLabel.loading {
  pointer-events: none;
  opacity: 0.7;
}

.upload-spinner {
  display: none;
  width: 36px;
  height: 36px;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 16px;
}

#uploadLabel.loading .upload-spinner {
  display: block;
}
#uploadLabel.loading .upload-icon-wrap {
  display: none;
}

.upload-icon-wrap {
  width: 72px;
  height: 72px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  transition: background 0.2s, color 0.2s;
  color: var(--primary);
}

.upload-icon-wrap svg {
  width: 30px;
  height: 30px;
}

#uploadLabel:hover .upload-icon-wrap,
#uploadLabel.drag-over .upload-icon-wrap {
  background: var(--primary);
  color: white;
}

.upload-main {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}

.upload-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.upload-sub span {
  color: var(--primary);
  font-weight: 500;
}

.upload-hint {
  font-size: 11px;
  color: var(--text-light);
  background: var(--border);
  padding: 3px 12px;
  border-radius: 20px;
  margin: 0;
}

#uploadImage {
  display: none;
}

/* ─── Image Map Wrapper ─────────────────────────────────── */
.imagemaps-wrapper {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  overflow: visible;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.imagemaps-wrapper.is-hidden {
  display: none !important;
}

.imagemaps-wrapper img {
  max-width: 100%;
  display: block;
  border-radius: var(--radius-sm);
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: white;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  font-family: inherit;
}

.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-ghost svg {
  width: 13px;
  height: 13px;
}

.btn-primary-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
  font-family: inherit;
  line-height: 1;
}

.btn-primary-sm:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  transform: translateY(-1px);
}

.btn-primary-sm svg {
  width: 13px;
  height: 13px;
}

.btn-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  background: linear-gradient(
    135deg,
    var(--success) 0%,
    var(--success-hover) 100%
  );
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, box-shadow 0.2s, transform 0.15s;
  font-family: inherit;
}

.btn-generate:hover {
  opacity: 0.92;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.4);
  transform: translateY(-1px);
}

.btn-generate svg {
  width: 16px;
  height: 16px;
}

/* ─── Areas Panel ───────────────────────────────────────── */
.areas-panel-body {
  overflow: auto;
}

.areas-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}

.areas-empty-icon {
  width: 56px;
  height: 56px;
  background: var(--bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  color: var(--text-light);
}

.areas-empty-icon svg {
  width: 26px;
  height: 26px;
}

.areas-empty p {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.areas-empty small {
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.5;
}

/* ─── Areas Table ───────────────────────────────────────── */
.areas-table-wrap {
  overflow: auto;
}

.areas-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.areas-table thead th {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  color: var(--text-light);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 9px 12px;
  white-space: nowrap;
}

.areas-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

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

.areas-table tbody tr:hover {
  background: #fafbfc;
}

.areas-table td {
  padding: 9px 10px;
  vertical-align: middle;
}

.col-num {
  width: 36px;
  text-align: center;
}
.col-target {
  width: 90px;
}
.col-del {
  width: 40px;
  text-align: center;
}

.area-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
}

.area-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: white;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.area-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-mid);
}

.area-input::placeholder {
  color: var(--text-light);
}

.area-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: white;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
  appearance: auto;
}

.area-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-mid);
}

.btn-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-light);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-del:hover {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-del svg {
  width: 13px;
  height: 13px;
}

/* ─── Modal ─────────────────────────────────────────────── */
.modern-modal {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modern-modal .modal-header {
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title-icon {
  width: 34px;
  height: 34px;
  background: var(--primary-light);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.modal-title-icon svg {
  width: 16px;
  height: 16px;
}

.modern-modal .modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

/* Code Block */
.code-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.code-block-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
}

.code-lang-tag {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.code-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-xs);
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}
.code-copy-btn.copied {
  background: rgba(5, 150, 105, 0.3);
  border-color: rgba(5, 150, 105, 0.5);
  color: #34d399;
}

.code-copy-btn svg {
  width: 13px;
  height: 13px;
}

.code-textarea {
  display: block;
  width: 100%;
  font-family: "Courier New", Consolas, "Fira Code", monospace;
  font-size: 12px;
  line-height: 1.65;
  background: #0f172a;
  color: #cbd5e1;
  border: none;
  border-radius: 0;
  padding: 16px 20px;
  resize: vertical;
  outline: none;
  box-shadow: none;
}

/* Legal Text Field */
.legal-text-wrap {
  margin-top: 16px;
}

.legal-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.legal-label svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.legal-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-light);
}

.legal-textarea {
  display: block;
  width: 100%;
  font-family: "Inter", sans-serif;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  resize: vertical;
  outline: none;
  box-shadow: none;
  transition: border-color 0.15s;
}

.legal-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(165, 180, 252, 0.2);
}

.legal-textarea::placeholder {
  color: var(--text-light);
}

.legal-unsub-fixed {
  margin-top: 8px;
  padding: 8px 12px;
  background: #f8f9fa;
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-family: Arial, sans-serif;
  font-size: 11px;
  color: #666;
  text-align: center;
}

.legal-unsub-fixed a {
  color: black !important;
}

/* Modal Footer */
.modern-modal .modal-footer {
  background: #fafbfc;
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  gap: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s, box-shadow 0.2s;
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.btn-export:hover {
  background: var(--primary-hover);
  color: white;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-export svg {
  width: 15px;
  height: 15px;
}

.btn-modal-close {
  padding: 9px 18px;
  background: white;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.btn-modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

/* ─── Toast ─────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease;
  pointer-events: auto;
  max-width: 320px;
  background: #1e293b;
}

.toast-item.toast-success {
  background: var(--success);
}
.toast-item.toast-error {
  background: var(--danger);
}

.toast-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 991px) {
  .app-header {
    height: auto;
    padding: 12px 0;
  }
  .app-main {
    padding: 16px 0 32px;
  }
}

@media (max-width: 576px) {
  .app-badge {
    display: none;
  }
  .app-title {
    font-size: 16px;
  }
}
