/* TableRead Admin Console — layout & components */

.admin-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

/* ── Header ── */
.admin-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.admin-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.admin-header .admin-lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  max-width: 52rem;
}

.admin-header .admin-lead code {
  font-size: 0.85em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(79, 140, 255, 0.12);
  color: color-mix(in srgb, var(--accent) 85%, var(--text));
}

/* ── Auth bar ── */
.admin-auth-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.admin-auth-bar .admin-field {
  flex: 1 1 240px;
  min-width: 0;
}

.admin-auth-bar .admin-field-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ── Tabs ── */
.admin-tabs {
  display: inline-flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  padding: 0.25rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
}

.admin-tabs button {
  padding: 0.55rem 1.15rem;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.admin-tabs button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.admin-tabs button[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(79, 140, 255, 0.35);
}

.admin-panel[hidden] {
  display: none !important;
}

/* ── Grid layout ── */
.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 960px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.admin-detail-column {
  min-width: 0;
}

/* ── Cards ── */
.admin-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.admin-card-header {
  padding: 1rem 1.15rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
}

.admin-card-header h2,
.admin-card-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.admin-card-header p {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

.admin-card-body {
  padding: 1rem 1.15rem 1.15rem;
}

.admin-card-section + .admin-card-section {
  margin-top: 1.15rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border);
}

.admin-card-section-title {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.admin-card-empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.admin-card-empty strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 1rem;
  color: var(--text);
}

.admin-card-empty p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* ── Form fields ── */
.admin-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-field > span,
.admin-field > label > span:first-child {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.admin-field input[type="text"],
.admin-field input[type="email"],
.admin-field input[type="password"],
.admin-field input[type="search"],
.admin-field input[type="number"],
.admin-field textarea,
.admin-field select,
.admin-form-grid input[type="text"],
.admin-form-grid input[type="email"],
.admin-form-grid input[type="password"],
.admin-form-grid input[type="search"],
.admin-form-grid input[type="number"],
.admin-form-grid textarea,
.admin-form-grid select {
  width: 100%;
  padding: 0.58rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.4;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.admin-field select,
.admin-form-grid select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b9cb3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-size: 1rem;
  cursor: pointer;
}

.admin-field input:hover,
.admin-field textarea:hover,
.admin-field select:hover,
.admin-form-grid input:hover,
.admin-form-grid textarea:hover,
.admin-form-grid select:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.admin-field input:focus,
.admin-field textarea:focus,
.admin-field select:focus,
.admin-form-grid input:focus,
.admin-form-grid textarea:focus,
.admin-form-grid select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.22);
}

.admin-field textarea {
  resize: vertical;
  min-height: 5rem;
}

.admin-form-grid {
  display: grid;
  gap: 0.85rem;
}

.admin-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.admin-checkbox-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.admin-form-grid + .admin-form-grid {
  margin-top: 0.85rem;
}

.admin-checkbox-row input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Buttons ── */
.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.58rem 1.1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.admin-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.admin-btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.admin-btn-secondary {
  background: color-mix(in srgb, var(--bg) 70%, var(--panel));
  color: var(--text);
  border-color: var(--border);
}

.admin-btn-secondary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--text);
}

.admin-btn-danger {
  background: rgba(255, 107, 107, 0.12);
  color: #ffb4b4;
  border-color: rgba(255, 107, 107, 0.45);
}

.admin-btn-danger:hover:not(:disabled) {
  background: rgba(255, 107, 107, 0.22);
  border-color: rgba(255, 107, 107, 0.65);
  color: #ffd0d0;
}

.admin-btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.admin-btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.admin-btn-block {
  width: 100%;
}

.admin-btn-sm {
  padding: 0.42rem 0.75rem;
  font-size: 0.84rem;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.25rem;
}

/* ── User list ── */
.admin-user-list {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.admin-user-list li button {
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.admin-user-list li button:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}

.admin-user-list li button[aria-current="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg));
  box-shadow: 0 0 0 1px rgba(79, 140, 255, 0.25);
}

.admin-user-list .user-email {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.admin-user-list .user-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.admin-user-list .user-meta code {
  font-size: 0.76rem;
  word-break: break-all;
}

.admin-plan-badge {
  display: inline-block;
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-plan-badge.trial {
  background: rgba(79, 140, 255, 0.18);
  color: #9ec0ff;
}

.admin-plan-badge.standard {
  background: rgba(61, 214, 140, 0.18);
  color: #7dffb0;
}

.admin-plan-badge.pro {
  background: rgba(240, 200, 120, 0.2);
  color: #ffd27a;
}

.admin-plan-badge.expired {
  background: rgba(255, 107, 107, 0.18);
  color: #ff9a9a;
}

/* ── User detail ── */
.admin-detail-grid {
  display: grid;
  grid-template-columns: minmax(7rem, 9rem) minmax(0, 1fr);
  gap: 0.55rem 1rem;
  margin: 0;
  font-size: 0.92rem;
}

.admin-detail-grid dt {
  margin: 0;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.82rem;
}

.admin-detail-grid dd {
  margin: 0;
  color: var(--text);
  word-break: break-word;
  line-height: 1.45;
}

.admin-detail-grid dd code {
  font-size: 0.85em;
  padding: 0.12em 0.35em;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
}

/* ── Status bar ── */
.admin-status-bar {
  margin-top: 1rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
  border: 1px solid transparent;
  background: rgba(0, 0, 0, 0.15);
  color: var(--muted);
}

.admin-status-bar:empty {
  display: none;
}

.admin-status-bar.is-ok {
  color: var(--success);
  background: rgba(61, 214, 140, 0.1);
  border-color: rgba(61, 214, 140, 0.3);
}

.admin-status-bar.is-error {
  color: var(--error);
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.35);
}

/* ── Announcement preview ── */
.admin-live-preview {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text);
}

.admin-live-preview.level-info {
  border-color: rgba(79, 140, 255, 0.4);
  background: rgba(79, 140, 255, 0.1);
}

.admin-live-preview.level-warning {
  border-color: rgba(240, 180, 60, 0.45);
  background: rgba(240, 180, 60, 0.12);
  color: #ffe4a8;
}

.admin-live-preview.level-error {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.12);
  color: #ffb4b4;
}

/* ── Bulk import drop zone ── */
.bulk-import-dropzone {
  margin-bottom: 1rem;
  padding: 1.35rem 1.25rem;
  border: 2px dashed rgba(79, 140, 255, 0.45);
  border-radius: 12px;
  background: rgba(79, 140, 255, 0.06);
  text-align: center;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.bulk-import-dropzone:hover,
.bulk-import-dropzone.is-dragover {
  border-color: rgba(79, 140, 255, 0.85);
  background: rgba(79, 140, 255, 0.12);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

.bulk-import-dropzone.is-busy {
  pointer-events: none;
  opacity: 0.65;
}

.bulk-import-dropzone-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.bulk-import-dropzone-hint {
  margin: 0.45rem 0 0;
  font-size: 0.88rem;
  color: var(--muted, #9aa3b2);
  line-height: 1.45;
}

.bulk-import-dropzone-action {
  margin: 0.65rem 0 0;
  font-size: 0.84rem;
  color: rgba(79, 140, 255, 0.95);
}

.bulk-import-file-input {
  display: none;
}

.bulk-import-file-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  max-height: 140px;
  overflow-y: auto;
  font-size: 0.84rem;
  color: var(--muted, #9aa3b2);
}

.bulk-import-file-list li {
  padding: 0.2rem 0;
}

.bulk-import-progress-panel {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.bulk-import-progress-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 0.55rem;
  font-size: 0.88rem;
}

.bulk-import-current-file {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-import-progress-pct {
  font-variant-numeric: tabular-nums;
  color: var(--muted, #9aa3b2);
}

.bulk-import-progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bulk-import-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4f8cff, #6aa8ff);
  transition: width 0.35s ease;
}

.pack-admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  margin-bottom: 0.85rem;
}

.pack-admin-search {
  flex: 1 1 16rem;
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.pack-admin-search-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.pack-admin-search input[type="search"] {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.4;
}

.pack-admin-search input[type="search"]:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.pack-admin-search input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.22);
}

.pack-admin-filter-status {
  margin: 0;
  flex: 0 0 auto;
  font-size: 0.82rem;
  white-space: nowrap;
}

.pack-admin-list-wrap {
  max-height: min(70vh, 42rem);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

#admin-packs-table tbody td {
  vertical-align: middle;
}

.pack-list-cover-col {
  width: 3.25rem;
  text-align: center;
}

.pack-list-cover-cell {
  text-align: center;
  vertical-align: middle;
}

.pack-list-cover-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 3.35rem;
  border-radius: 4px;
  overflow: visible;
  cursor: default;
}

.pack-list-cover-thumb {
  display: block;
  width: 2.5rem;
  height: 3.35rem;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel-elevated, var(--panel));
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.pack-list-cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 3.35rem;
  border-radius: 4px;
  border: 1px dashed var(--border);
  background: color-mix(in srgb, var(--panel) 88%, var(--muted) 12%);
  color: var(--muted);
}

.pack-list-cover-placeholder svg {
  width: 1.35rem;
  height: auto;
}

.pack-list-cover-zoom {
  position: absolute;
  right: calc(100% + 0.5rem);
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.14s ease,
    visibility 0.14s ease;
  z-index: 40;
  padding: 0.35rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.28),
    0 2px 8px rgba(0, 0, 0, 0.12);
}

.pack-list-cover-zoom img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(14rem, 38vw);
  max-height: min(20rem, 52vh);
  object-fit: contain;
  border-radius: 4px;
}

.pack-list-cover-wrap:not(:hover):not(:focus-within) .pack-list-cover-zoom {
  display: none;
}

.pack-list-cover-wrap:hover .pack-list-cover-zoom,
.pack-list-cover-wrap:focus-within .pack-list-cover-zoom {
  display: block;
  opacity: 1;
  visibility: visible;
}
