/* =============================================================================
   Bee Identifier — Rock Identifier layout (normal educational tool)
   Namespaced .ap- / .apisscan-root to avoid theme conflicts.
   ============================================================================= */

.apisscan-root *,
.apisscan-root *::before,
.apisscan-root *::after {
  box-sizing: border-box;
}

.apisscan-root {
  --ap-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ap-radius: 12px;
  --ap-radius-sm: 8px;
  --ap-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
  --ap-shadow-md: 0 4px 24px rgba(0, 0, 0, 0.12);
  --ap-border: #e2e8f0;
  --ap-bg: #f8fafc;
  --ap-card-bg: #ffffff;
  --ap-text: #1e293b;
  --ap-text-muted: #64748b;
  --ap-accent: #d97706;
  --ap-accent-dark: #92400e;
  --ap-accent-light: #fef3c7;
  --ap-green: #16a34a;
  --ap-amber: #d97706;
  --ap-red: #dc2626;
  --ap-transition: 200ms ease;

  font-family: var(--ap-font);
  color: var(--ap-text);
  line-height: 1.6;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 24px;
  background: var(--ap-bg);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
}

.apisscan-loading {
  padding: 2rem;
  text-align: center;
  color: var(--ap-text-muted);
}

.ap-hidden {
  display: none !important;
}

/* ── Header / tabs ─────────────────────────────────────────────────────────── */
.ap-header {
  text-align: center;
  padding: 32px 8px 16px;
}

.ap-header-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 8px;
}

.ap-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ap-text);
}

.ap-subtitle {
  color: var(--ap-text-muted);
  font-size: 0.95rem;
  margin: 0 0 16px;
}

.ap-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.ap-tabs button,
.ap-btn {
  font-family: var(--ap-font);
  border: 1px solid var(--ap-border);
  background: var(--ap-card-bg);
  color: var(--ap-text);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  transition: background var(--ap-transition), border-color var(--ap-transition);
}

.ap-tabs button.active,
.ap-btn-primary {
  background: var(--ap-accent);
  color: #fff;
  border-color: transparent;
}

.ap-tabs button:hover:not(.active),
.ap-btn:hover {
  border-color: var(--ap-accent);
  background: var(--ap-accent-light);
}

/* ── Drop zone ─────────────────────────────────────────────────────────────── */
.ap-dropzone {
  position: relative;
  border: 2px dashed var(--ap-border);
  border-radius: var(--ap-radius);
  background: var(--ap-card-bg);
  cursor: pointer;
  transition: border-color var(--ap-transition), background var(--ap-transition);
  overflow: hidden;
}

.ap-dropzone:hover,
.ap-dropzone:focus,
.ap-dropzone.ap-dropzone--active {
  border-color: var(--ap-accent);
  background: var(--ap-accent-light);
  outline: none;
}

.ap-dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  pointer-events: none;
  text-align: center;
}

.ap-upload-icon {
  width: 52px;
  height: 52px;
  color: var(--ap-accent);
  margin-bottom: 12px;
}

.ap-dropzone-label {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 4px;
}

.ap-dropzone-sublabel,
.ap-dropzone-formats {
  font-size: 0.85rem;
  color: var(--ap-text-muted);
  margin: 0;
}

.ap-camera-row {
  text-align: center;
  margin: 12px 0 4px;
}

.ap-camera-btn {
  background: var(--ap-card-bg);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-sm);
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ap-accent-dark);
  cursor: pointer;
  font-family: var(--ap-font);
  transition: background var(--ap-transition);
}

.ap-camera-btn:hover {
  background: var(--ap-accent-light);
}

.ap-preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 8px;
}

.ap-thumb {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: var(--ap-radius-sm);
  overflow: hidden;
  border: 2px solid var(--ap-border);
  flex-shrink: 0;
}

.ap-thumb img,
.ap-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ap-preview.ap-preview-video {
  width: 100%;
  max-height: 240px;
  height: auto;
  border-radius: var(--ap-radius);
  margin-top: 12px;
  background: #0f172a;
}

.ap-image-counter {
  font-size: 0.85rem;
  color: var(--ap-text-muted);
  margin: 4px 0 16px;
}

/* ── Optional details ──────────────────────────────────────────────────────── */
.ap-details-section {
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-sm);
  margin-bottom: 16px;
  background: var(--ap-card-bg);
}

.ap-details-summary {
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ap-details-summary::-webkit-details-marker {
  display: none;
}

.ap-details-chevron {
  margin-left: auto;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--ap-text-muted);
  border-bottom: 2px solid var(--ap-text-muted);
  transform: rotate(45deg);
  transition: transform var(--ap-transition);
}

.ap-details-section[open] .ap-details-chevron {
  transform: rotate(-135deg);
}

.ap-details-body {
  padding: 4px 18px 18px;
  display: grid;
  gap: 14px;
}

@media (min-width: 640px) {
  .ap-details-body {
    grid-template-columns: 1fr 1fr;
  }
}

.ap-field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ap-label {
  font-size: 0.875rem;
  font-weight: 600;
}

.ap-input,
.ap-select,
.ap-textarea,
.ap-search {
  padding: 10px 12px;
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-sm);
  font-size: 0.9rem;
  font-family: var(--ap-font);
  color: var(--ap-text);
  background: var(--ap-card-bg);
  width: 100%;
}

.ap-input:focus,
.ap-select:focus,
.ap-textarea:focus,
.ap-search:focus {
  outline: none;
  border-color: var(--ap-accent);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18);
}

.ap-search {
  margin-bottom: 16px;
}

/* ── Submit ────────────────────────────────────────────────────────────────── */
.ap-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 24px;
  background: var(--ap-accent);
  color: #fff;
  border: none;
  border-radius: var(--ap-radius);
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--ap-font);
  cursor: pointer;
  transition: background var(--ap-transition), opacity var(--ap-transition);
}

.ap-submit-btn:hover:not(:disabled) {
  background: #b45309;
}

.ap-submit-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.ap-helper-text {
  text-align: center;
  font-size: 0.82rem;
  color: var(--ap-text-muted);
  margin: 8px 0 0;
}

.ap-error-box {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: var(--ap-radius-sm);
  color: #b91c1c;
  padding: 12px 16px;
  font-size: 0.9rem;
  margin: 16px 0;
}

/* ── Result card ───────────────────────────────────────────────────────────── */
.ap-result-section {
  padding: 24px 0 8px;
}

.ap-result-card {
  background: var(--ap-card-bg);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  box-shadow: var(--ap-shadow);
  overflow: hidden;
}

.ap-result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 24px 20px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-bottom: 1px solid var(--ap-border);
  gap: 16px;
}

.ap-bug-name {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0 0 4px;
  color: var(--ap-text);
}

.ap-scientific-name {
  font-style: italic;
  color: var(--ap-text-muted);
  font-size: 0.95rem;
  margin: 0 0 10px;
}

.ap-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.ap-result-header-icon {
  font-size: 2.5rem;
  flex-shrink: 0;
}

.ap-type-badge,
.ap-subtype-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.ap-type-badge {
  background: #eff6ff;
  color: #1d4ed8;
  text-transform: uppercase;
}

.ap-subtype-badge {
  background: #f1f5f9;
  color: #475569;
  font-weight: 500;
}

.ap-role-beneficial {
  background: #f0fdf4;
  color: #15803d;
}
.ap-role-harmless {
  background: #f1f5f9;
  color: #475569;
}
.ap-role-pest,
.ap-role-potential-pest {
  background: #fffbeb;
  color: #92400e;
}
.ap-role-harmful {
  background: #f5f3ff;
  color: #6d28d9;
}

.ap-confidence-section {
  padding: 20px 24px;
  border-bottom: 1px solid var(--ap-border);
}

.ap-confidence-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.ap-confidence-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.ap-confidence-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.ap-confidence-track {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.ap-confidence-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.ap-conf-high {
  background: var(--ap-green);
}
.ap-conf-mid {
  background: var(--ap-amber);
}
.ap-conf-low {
  background: var(--ap-red);
}

.ap-confidence-reason {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--ap-text-muted);
}

.ap-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--ap-border);
  border-top: 1px solid var(--ap-border);
  border-bottom: 1px solid var(--ap-border);
}

.ap-info-card {
  background: var(--ap-card-bg);
  padding: 18px 20px;
}

.ap-info-full {
  grid-column: 1 / -1;
}

.ap-info-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ap-text-muted);
  margin: 0 0 8px;
}

.ap-info-value {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--ap-text);
}

.ap-info-card p {
  margin: 0;
  font-size: 0.95rem;
}

.ap-properties-section {
  padding: 20px 24px;
  border-bottom: 1px solid var(--ap-border);
}

.ap-section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 14px;
}

.ap-properties-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

@media (min-width: 480px) {
  .ap-properties-list {
    grid-template-columns: 1fr 1fr;
  }
}

.ap-property-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.9rem;
  background: var(--ap-bg);
  padding: 10px 12px;
  border-radius: var(--ap-radius-sm);
  border: 1px solid var(--ap-border);
}

.ap-prop-bullet {
  color: var(--ap-accent);
  flex-shrink: 0;
}

.ap-tip-box {
  background: #f8fafc;
  border-top: 1px solid var(--ap-border);
  padding: 16px 24px;
}

.ap-tip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.ap-tip-box p,
.ap-tip-box ul {
  margin: 0;
  font-size: 0.9rem;
}

.ap-tip-box ul {
  padding-left: 1.1rem;
  margin-top: 8px;
  color: var(--ap-text-muted);
}

.ap-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 24px;
}

.ap-btn-result {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: var(--ap-radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--ap-font);
  cursor: pointer;
  border: none;
}

.ap-btn-result-primary {
  background: var(--ap-accent);
  color: #fff;
}

.ap-btn-result-secondary {
  background: var(--ap-bg);
  color: var(--ap-text);
  border: 1px solid var(--ap-border);
}

/* ── Learn / encyclopedia ──────────────────────────────────────────────────── */
.ap-view {
  padding-bottom: 8px;
}

.ap-learn-card,
.ap-panel {
  background: var(--ap-card-bg);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  padding: 20px;
  margin-bottom: 16px;
}

.ap-learn-card h3,
.ap-panel h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.ap-muted {
  color: var(--ap-text-muted);
  font-size: 0.9rem;
}

.ap-score {
  font-weight: 600;
  margin: 12px 0;
}

.ap-lifecycle {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 12px 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ap-accent-dark);
}

.ap-quiz-options {
  display: grid;
  gap: 8px;
}

.ap-quiz-options button {
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-sm);
  background: var(--ap-card-bg);
  font-family: var(--ap-font);
  font-weight: 600;
  cursor: pointer;
}

.ap-quiz-options button.correct {
  background: #dcfce7;
  border-color: #86efac;
}

.ap-quiz-options button.wrong {
  background: #fef2f2;
  border-color: #fecaca;
}

.ap-grid {
  display: grid;
  gap: 12px;
}

.ap-cards {
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .ap-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 760px) {
  .ap-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

.ap-card {
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius);
  padding: 16px;
  background: var(--ap-card-bg);
  cursor: pointer;
  transition: transform var(--ap-transition), box-shadow var(--ap-transition);
}

.ap-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--ap-shadow);
}

.ap-card h3 {
  margin: 0.35rem 0 0.15rem;
  font-size: 1rem;
}

.ap-cam-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

@media (max-width: 560px) {
  .ap-info-grid {
    grid-template-columns: 1fr;
  }

  .ap-info-full {
    grid-column: 1;
  }

  .ap-result-header {
    flex-direction: column;
  }

  .ap-result-header-icon {
    display: none;
  }

  .ap-bug-name {
    font-size: 1.35rem;
  }

  .ap-result-actions {
    flex-direction: column;
  }

  .ap-btn-result {
    width: 100%;
    justify-content: center;
  }
}

.ap-role-dangerous,
.ap-role-venomous,
.ap-role-high {
  background: #fef2f2;
  color: #b91c1c;
}
.ap-role-mild,
.ap-role-moderate,
.ap-role-uncommon {
  background: #fffbeb;
  color: #92400e;
}
.ap-role-common,
.ap-role-low,
.ap-role-resident {
  background: #eff6ff;
  color: #1d4ed8;
}
.ap-role-indoor-pest,
.ap-role-occasional-invader,
.ap-role-agricultural-pest {
  background: #fff7ed;
  color: #9a3412;
}
