/* ==========================================================================
   Wildlife Trade Reporter - Admin
   Matches public site design tokens
   ========================================================================== */

:root {
  --color-primary: #0B3D2E;
  --color-primary-dark: #072E22;

  --color-text: #0B0C0C;
  --color-text-secondary: #505A5F;
  --color-text-light: #6F777B;

  --color-bg: #FFFFFF;
  --color-bg-light: #F3F2F1;

  --color-border: #B1B4B6;
  --color-border-input: #0B0C0C;

  --color-focus: #FFDD00;
  --color-focus-text: #0B0C0C;

  --color-error: #D4351C;
  --color-success: #00703C;
  --color-warning: #F47738;
  --color-info: #1D70B8;

  --color-link: #1D70B8;
  --color-link-hover: #003078;

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* ---------- Reset ---------- */

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

body {
  font-family: var(--font-body);
  background: var(--color-bg-light);
  color: var(--color-text);
  line-height: 1.5;
}

/* ---------- Focus ---------- */

:focus {
  outline: 3px solid var(--color-focus);
  outline-offset: 0;
}

:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 0;
}

/* ---------- Login ---------- */

#login-view {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--color-bg-light);
}

.login-box {
  background: var(--color-bg);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  margin: 16px;
  border-top: 5px solid var(--color-primary);
}

.login-box h1 {
  font-size: 1.3rem;
  margin-bottom: 16px;
  color: var(--color-text);
}

.login-box input {
  width: 100%;
  padding: 10px;
  border: 2px solid var(--color-border-input);
  border-radius: 0;
  font-size: 16px;
  font-family: inherit;
  margin-bottom: 12px;
  min-height: 44px;
}

.login-box input:focus {
  outline: 3px solid var(--color-focus);
  box-shadow: inset 0 0 0 2px var(--color-border-input);
}

.login-box button {
  width: 100%;
  padding: 10px;
  background: var(--color-primary);
  color: #fff;
  border: 2px solid var(--color-primary);
  border-radius: 0;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-height: 44px;
  box-shadow: 0 2px 0 var(--color-primary-dark);
}

.login-box button:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

.login-box button:active {
  box-shadow: none;
  transform: translateY(1px);
}

.error {
  color: var(--color-error);
  font-size: 0.9rem;
  margin-top: 8px;
}

.hidden {
  display: none !important;
}

/* ---------- Dashboard Header ---------- */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--color-primary);
  color: #FFFFFF;
}

header h1 {
  font-size: 1.125rem;
  color: #FFFFFF;
}

#logout-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 0;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  color: #FFFFFF;
  min-height: 36px;
}

#logout-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #FFFFFF;
}

/* ---------- Tab Bar ---------- */

.tab-bar {
  display: flex;
  gap: 0;
  padding: 0 20px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.tab {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--color-text-secondary);
  cursor: pointer;
  min-height: 44px;
}

.tab:hover {
  color: var(--color-text);
}

.tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ---------- Filters ---------- */

.filters {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.filters input,
.filters select {
  padding: 8px 10px;
  border: 2px solid var(--color-border-input);
  border-radius: 0;
  font-size: 0.9rem;
  font-family: inherit;
  flex: 1;
  min-width: 120px;
  min-height: 40px;
}

.filters input:focus,
.filters select:focus {
  outline: 3px solid var(--color-focus);
  box-shadow: inset 0 0 0 2px var(--color-border-input);
}

.filters button {
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border: 2px solid var(--color-primary);
  border-radius: 0;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  min-height: 40px;
}

.filters button:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

/* ---------- Stats ---------- */

.stats-bar {
  display: flex;
  justify-content: space-between;
  padding: 8px 20px;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

/* ---------- Table ---------- */

.table-wrap {
  overflow-x: auto;
  padding: 0 20px;
}

table {
  width: 100%;
  min-width: 1400px;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 2px solid var(--color-text);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--color-text);
  white-space: nowrap;
}

td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

tr {
  cursor: pointer;
}

tr:hover {
  background: var(--color-bg-light);
}

/* ---------- Status Badges ---------- */

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.status-pending {
  background: #FEF3C7;
  color: #92400E;
  border-left: 3px solid var(--color-warning);
}

.status-completed {
  background: #D1FAE5;
  color: #065F46;
  border-left: 3px solid var(--color-success);
}

.status-failed {
  background: #FEE2E2;
  color: #991B1B;
  border-left: 3px solid var(--color-error);
}

/* ---------- Detail Actions ---------- */

.detail-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 8px;
}

.enrich-btn {
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border: 2px solid var(--color-primary);
  border-radius: 0;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  min-height: 40px;
}

.enrich-btn:hover {
  background: var(--color-primary-dark);
}

.enrich-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.delete-btn {
  padding: 8px 16px;
  background: var(--color-error);
  color: #fff;
  border: 2px solid var(--color-error);
  border-radius: 0;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  min-height: 40px;
}

.delete-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 16px;
}

.pagination button {
  padding: 6px 14px;
  border: 2px solid var(--color-border-input);
  border-radius: 0;
  background: var(--color-bg);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 700;
  min-height: 40px;
}

.pagination button:hover:not(:disabled) {
  background: var(--color-bg-light);
}

.pagination button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#page-info,
#seller-page-info {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

/* ---------- Modal ---------- */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}

.modal-content {
  background: var(--color-bg);
  padding: 24px;
  width: 100%;
  max-width: 640px;
  position: relative;
  border-top: 5px solid var(--color-primary);
}

.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 4px 8px;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.modal-content h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 12px;
  font-size: 0.9rem;
}

.detail-label {
  font-weight: 700;
  color: var(--color-text-secondary);
}

.detail-value {
  word-break: break-word;
}

.detail-value a {
  color: var(--color-link);
  text-decoration: underline;
}

.detail-value a:hover {
  color: var(--color-link-hover);
}

.detail-screenshots {
  margin-top: 16px;
}

.detail-screenshots h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

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

.screenshot-grid img {
  width: 100%;
  border: 1px solid var(--color-border);
}

/* ---------- Sellers Table ---------- */

#sellers-table {
  min-width: 600px;
}

.seller-identities {
  margin-bottom: 16px;
}

.seller-identities h3,
.seller-reports h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.identity-list {
  list-style: none;
  font-size: 0.9rem;
}

.identity-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
}

.identity-list li:last-child {
  border-bottom: none;
}

.identity-list a {
  color: var(--color-link);
  text-decoration: underline;
}

.seller-reports {
  margin-bottom: 16px;
}

.seller-reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.seller-reports-table th {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 2px solid var(--color-text);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--color-text);
}

.seller-reports-table td {
  padding: 6px;
  border-bottom: 1px solid var(--color-border);
}

.seller-reports-table tr {
  cursor: pointer;
}

.seller-reports-table tr:hover {
  background: var(--color-bg-light);
}

.seller-info-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.seller-info-section a {
  color: var(--color-link);
  text-decoration: underline;
  cursor: pointer;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
}

/* ---------- Edit Mode ---------- */

.edit-btn {
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border: 2px solid var(--color-primary);
  border-radius: 0;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  min-height: 40px;
}

.save-btn {
  padding: 8px 16px;
  background: var(--color-success);
  color: #fff;
  border: 2px solid var(--color-success);
  border-radius: 0;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  min-height: 40px;
}

.save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cancel-btn {
  padding: 8px 16px;
  background: var(--color-text-secondary);
  color: #fff;
  border: 2px solid var(--color-text-secondary);
  border-radius: 0;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  min-height: 40px;
}

.edit-input {
  width: 100%;
  padding: 6px 8px;
  border: 2px solid var(--color-border-input);
  border-radius: 0;
  font-size: 0.9rem;
  font-family: inherit;
  min-height: 36px;
}

.edit-input:focus {
  outline: 3px solid var(--color-focus);
  box-shadow: inset 0 0 0 2px var(--color-border-input);
}

.edit-mode .detail-label {
  padding-top: 8px;
}

/* ---------- Event History ---------- */

.event-history {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.event-history h3 {
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.event-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.event-entry {
  padding: 10px 12px;
  background: var(--color-bg-light);
  border-left: 3px solid var(--color-border);
}

.event-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.event-type-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.event-type-report-created {
  background: #D1FAE5;
  color: #065F46;
  border-left: 3px solid var(--color-success);
}

.event-type-poster-resolved {
  background: #DBEAFE;
  color: #1E40AF;
  border-left: 3px solid var(--color-info);
}

.event-type-report-enriched {
  background: #E0E7FF;
  color: #3730A3;
  border-left: 3px solid #6366F1;
}

.event-type-enrichment-failed {
  background: #FEE2E2;
  color: #991B1B;
  border-left: 3px solid var(--color-error);
}

.event-type-report-edited {
  background: #FEF3C7;
  color: #92400E;
  border-left: 3px solid var(--color-warning);
}

.event-type-report-deleted {
  background: #FEE2E2;
  color: #991B1B;
  border-left: 3px solid var(--color-error);
}

.event-actor {
  font-size: 0.8rem;
  color: var(--color-text-light);
}

.event-time {
  font-size: 0.8rem;
  color: var(--color-text-light);
  margin-left: auto;
}

.event-changes {
  font-size: 0.85rem;
  margin-top: 4px;
}

.event-change {
  padding: 2px 0;
}

.event-field {
  font-weight: 700;
  color: var(--color-text);
}

.old-value {
  color: #991B1B;
  text-decoration: line-through;
}

.arrow {
  color: var(--color-text-light);
  margin: 0 2px;
}

.new-value {
  color: #065F46;
}

/* ---------- Login extras ---------- */

.login-signup-link {
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  text-align: center;
}

.login-signup-link a {
  color: var(--color-link);
  text-decoration: underline;
}

/* ---------- Users table ---------- */

#users-table {
  min-width: 550px;
}

.role-select {
  padding: 4px 8px;
  border: 2px solid var(--color-border-input);
  border-radius: 0;
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--color-bg);
  cursor: pointer;
  min-height: 32px;
}

.role-select:focus {
  outline: 3px solid var(--color-focus);
  box-shadow: inset 0 0 0 2px var(--color-border-input);
}

.user-reports-link {
  color: var(--color-link);
  text-decoration: underline;
  font-weight: 700;
}

.user-reports-link:hover {
  color: var(--color-link-hover);
}

.reset-btn {
  padding: 4px 10px;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border-input);
  border-radius: 0;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  min-height: 32px;
}

.reset-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.reset-link-box {
  display: flex;
  flex-direction: column;
}

/* ---------- Reduced Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
