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

:root {
  --admin-bg-1: #e8f1ff;
  --admin-bg-2: #f4f8ff;
  --admin-hero-1: #08203c;
  --admin-hero-2: #0f4d70;
  --admin-hero-3: #136f63;
  --admin-text: #0f2038;
  --admin-muted: #5a6d88;
  --admin-line: #d2def0;
  --admin-card: #ffffff;
  --admin-accent: #136f63;
  --admin-accent-2: #0a5ba7;
  --admin-danger: #9f2b37;
  --admin-radius: 14px;
  --admin-shadow: 0 4px 24px rgba(20, 44, 72, 0.07);
  --admin-shadow-hover: 0 8px 32px rgba(20, 44, 72, 0.13);
}

/* ============ BASE ============ */

.admin-body {
  font-family: "Manrope", "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(circle at 10% -10%, #b8d2ff 0%, transparent 45%),
    radial-gradient(circle at 90% 0%, #b3e6db 0%, transparent 38%),
    linear-gradient(180deg, var(--admin-bg-1), var(--admin-bg-2));
  color: var(--admin-text);
  min-height: 100vh;
}

/* ============ HERO / HEADER ============ */

.admin-hero {
  background: linear-gradient(135deg, var(--admin-hero-1) 0%, var(--admin-hero-2) 50%, var(--admin-hero-3) 100%);
  color: #f4fbff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 34px rgba(5, 20, 39, 0.22);
  position: relative;
  overflow: hidden;
}

.admin-hero::before {
  content: "";
  position: absolute;
  top: -60%;
  right: -10%;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(19, 111, 99, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.hero-inner {
  padding-top: 24px;
  padding-bottom: 28px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  position: relative;
  z-index: 1;
}

.admin-hero h1 {
  margin: 0;
  font-size: clamp(1.3rem, 2.5vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.01em;
}

.admin-hero .sub {
  color: rgba(231, 245, 255, 0.9);
  margin-top: 8px;
  margin-bottom: 0;
}

.hero-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(233, 247, 255, 0.42);
  color: #f5fcff;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 6px 14px;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.hero-link:hover {
  background: rgba(255, 255, 255, 0.26);
  transform: translateY(-1px);
}

.hero-link.ghost {
  background: rgba(4, 11, 18, 0.22);
}

.hero-link.ghost:hover {
  background: rgba(4, 11, 18, 0.35);
}

.hero-status {
  display: grid;
  gap: 4px;
  text-align: right;
  font-size: 0.92rem;
  color: rgba(236, 250, 255, 0.95);
}

/* ============ LAYOUT ============ */

.admin-container {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding-bottom: 28px;
}

#admin-sections {
  display: grid;
  gap: 16px;
}

.hidden {
  display: none !important;
}

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

.admin-card {
  border: 1px solid rgba(163, 184, 214, 0.5);
  border-radius: var(--admin-radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(251, 254, 255, 0.93));
  padding: 18px;
  box-shadow: var(--admin-shadow);
  transition: box-shadow 0.2s ease;
}

.admin-card:hover {
  box-shadow: var(--admin-shadow-hover);
}

.admin-card h2,
.admin-card h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
}

.login-card {
  border-color: #9ec4f3;
  background:
    linear-gradient(180deg, #f7fbff, #ffffff),
    radial-gradient(circle at 95% 0, #dcecff 0%, transparent 34%);
}

.admin-two-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* ============ STATS ============ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat-card {
  border: 1px solid #c6d9f4;
  border-radius: var(--admin-radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(140deg, #ffffff 0%, #edf5ff 72%, #f4ffff 100%);
  border-left: 4px solid #6ea9e5;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(20, 44, 72, 0.1);
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -18px;
  top: -20px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(115, 170, 233, 0.14);
}

.stat-card span {
  display: block;
  color: var(--admin-muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
  font-weight: 800;
  color: #112845;
}

/* Colored accent borders for stat cards */
.stat-card.stat-active {
  border-left-color: #2e7d32;
}

.stat-card.stat-inactive {
  border-left-color: #c62828;
}

.stat-card.stat-expired {
  border-left-color: #e65100;
}

.stat-card.stat-today {
  border-left-color: #1565c0;
}

.stat-card.stat-total-req {
  border-left-color: #6a1b9a;
}

.stat-card.stat-logos {
  border-left-color: #00838f;
}

.stat-card.stat-channel-logos {
  border-left-color: #4527a0;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.form-grid label {
  display: grid;
  gap: 6px;
}

.form-grid span {
  font-size: 0.8rem;
  color: var(--admin-muted);
  font-weight: 600;
}

.form-grid input,
.form-grid select,
.inline-actions input,
.inline-actions select,
.toolbar input,
.toolbar select,
.bulk-bar select {
  border: 1px solid var(--admin-line);
  border-radius: 10px;
  background: #fff;
  color: #122742;
  min-height: 38px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-grid input:focus,
.form-grid select:focus,
.inline-actions input:focus,
.inline-actions select:focus,
.toolbar input:focus,
.toolbar select:focus,
.bulk-bar select:focus {
  border-color: #6ea9e5;
  box-shadow: 0 0 0 3px rgba(97, 152, 219, 0.16);
}

.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}

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

.btn-refresh,
.action-btn {
  border: 1px solid var(--admin-line);
  background: #fff;
  border-radius: 10px;
  color: #23415f;
  cursor: pointer;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  transition: all 0.18s ease;
}

.btn-refresh:hover,
.action-btn:hover {
  transform: translateY(-1px);
  border-color: #9dc2ea;
  box-shadow: 0 6px 18px rgba(28, 57, 93, 0.1);
}

.btn-refresh:active,
.action-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(28, 57, 93, 0.08);
}

.btn-refresh:disabled,
.action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.primary-btn {
  background: linear-gradient(135deg, var(--admin-accent) 0%, var(--admin-accent-2) 100%);
  color: #fff;
  border: 1px solid transparent;
}

.primary-btn:hover {
  box-shadow: 0 6px 20px rgba(10, 91, 167, 0.3);
}

.warn-btn,
.action-btn.warn {
  border-color: #e8b6bd;
  color: var(--admin-danger);
  background: #fff6f7;
}

.warn-btn:hover,
.action-btn.warn:hover {
  background: #ffe8ea;
  border-color: #d4868f;
}

.action-btn.ok {
  border-color: #9ad5c7;
  color: #0a6f5e;
  background: #ecfff8;
}

.action-btn.ok:hover {
  background: #d5fae9;
  border-color: #6ec4ae;
}

.auto-refresh-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--admin-muted);
}

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

.logos-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  border-bottom: 2px solid var(--admin-line);
}

.logos-tab-btn {
  position: relative;
  background: none;
  border: none;
  padding: 10px 22px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--admin-muted);
  cursor: pointer;
  transition: color 0.2s ease;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

.logos-tab-btn:hover {
  color: var(--admin-accent-2);
}

.logos-tab-btn.active {
  color: var(--admin-accent-2);
  border-bottom-color: var(--admin-accent-2);
}

.logos-tab-btn .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 999px;
  background: #e3ecf7;
  color: #3a5a80;
  font-size: 0.7rem;
  font-weight: 800;
}

.logos-tab-btn.active .tab-count {
  background: var(--admin-accent-2);
  color: #fff;
}

.logos-tab-panel {
  display: none;
  padding-top: 16px;
}

.logos-tab-panel.active {
  display: block;
}

/* ============ LOGO GRID VIEW ============ */

.logos-view-toggle {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.logos-view-btn {
  background: none;
  border: 1px solid var(--admin-line);
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--admin-muted);
  transition: all 0.15s ease;
}

.logos-view-btn.active {
  background: var(--admin-accent-2);
  color: #fff;
  border-color: var(--admin-accent-2);
}

.logos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.logo-grid-card {
  border: 1px solid var(--admin-line);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  text-align: center;
  transition: all 0.2s ease;
  position: relative;
}

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

.logo-grid-card img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin-bottom: 8px;
  border-radius: 6px;
  background: #f5f7fa;
  padding: 4px;
}

.logo-grid-card .logo-grid-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--admin-text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logo-grid-card .logo-grid-slug {
  font-size: 0.68rem;
  color: var(--admin-muted);
  margin-bottom: 8px;
}

.logo-grid-card .logo-grid-actions {
  display: flex;
  justify-content: center;
}

.logo-grid-card .logo-grid-actions .action-btn {
  font-size: 0.72rem;
  padding: 4px 10px;
}

/* ============ TABLES ============ */

.feeds-chooser {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0;
  font-size: 0.9rem;
}

.feeds-chooser label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.toolbar h2 {
  margin: 0;
}

.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border: 1px dashed #bfd2eb;
  border-radius: 11px;
  background: #f4f9ff;
}

.table-wrap {
  overflow-x: auto;
}

.tokens-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1120px;
}

.tokens-table th,
.tokens-table td {
  border-bottom: 1px solid #e1eaf6;
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 0.82rem;
}

.tokens-table th {
  font-size: 0.72rem;
  color: #5e7392;
  background: #f0f5fc;
  position: sticky;
  top: 0;
  z-index: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.tokens-table tbody tr {
  transition: background 0.12s ease;
}

.tokens-table tbody tr:hover {
  background: rgba(110, 169, 229, 0.06);
}

.tokens-table code {
  color: #0f3d6a;
  font-size: 0.74rem;
}

.audit-table {
  min-width: 780px;
}

.audit-table td:nth-child(5) {
  max-width: 380px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Logos table has fewer columns - narrower min-width */
.logos-table {
  min-width: 680px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.71rem;
  font-weight: 800;
}

.status-active {
  background: #e9fff5;
  color: #0d7b63;
}

.status-inactive {
  background: #fff0f1;
  color: #a42e3b;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ============ CODE BOX ============ */

.code-box {
  border: 1px solid #c4d5ef;
  border-radius: 12px;
  background: linear-gradient(180deg, #0f2239, #132a45);
  color: #dcecff;
  padding: 14px;
  font-size: 0.76rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 230px;
  overflow: auto;
}

/* ============ CHECKBOX / DIALOG / ETC ============ */

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}

.checkbox-row span {
  margin: 0;
}

.edit-dialog {
  border: 1px solid #bed2ee;
  border-radius: var(--admin-radius);
  padding: 18px;
  width: min(760px, 96%);
  background: #f9fcff;
  box-shadow: 0 20px 60px rgba(5, 20, 39, 0.2);
}

.edit-dialog::backdrop {
  background: rgba(5, 12, 23, 0.5);
  backdrop-filter: blur(4px);
}

.muted-text {
  color: var(--admin-muted);
  font-size: 0.84rem;
}

.error-box {
  border: 1px solid #f5b6bf;
  background: #fff2f4;
  color: #9b2230;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 600;
}

/* ============ DOWNLOAD STATUS ============ */

.download-status-box {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 980px) {
  .admin-two-cols {
    grid-template-columns: 1fr;
  }

  .hero-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-status {
    text-align: left;
  }

  .logos-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 720px) {
  .admin-card {
    border-radius: 12px;
    padding: 14px;
  }

  .tokens-table {
    min-width: 960px;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
  }

  .stat-card {
    padding: 10px 12px;
  }

  .stat-card strong {
    font-size: 1.15rem;
  }

  .logos-tab-btn {
    padding: 8px 14px;
    font-size: 0.82rem;
  }

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

@media (max-width: 480px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar .inline-actions {
    justify-content: flex-start;
  }

  .admin-card {
    padding: 12px;
  }

  .hero-inner {
    padding-top: 16px;
    padding-bottom: 20px;
  }
}
