/* ═══════════════════════════════════════════════════════
   DJI Enterprise Tool — Admin Portal Styles
   ═══════════════════════════════════════════════════════ */

/* ─── Admin Top Bar ────────────────────────────────────── */
.admin-top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  background: var(--white);
  border-bottom: 2px solid var(--black);
  padding: 18px 28px;
  flex-wrap: wrap;
}
.admin-top-left h2 {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--black);
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 4px;
}
.admin-top-left p {
  font-size: .82rem;
  color: var(--muted);
}
.admin-top-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Status bar */
.admin-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .79rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--r);
  max-width: 400px;
  line-height: 1.4;
}
.status-ok      { background: #f0faf0; color: #1a6e2e; border: 1px solid #9ddaaa; }
.status-err     { background: #fff5f5; color: #c00; border: 1px solid #ffb3b3; }
.status-loading { background: var(--bg); color: var(--dark); border: 1px solid var(--border); }

.admin-resync-btn {
  display: flex; align-items: center; gap: 7px;
  background: var(--black); color: var(--white);
  border: none; padding: 9px 18px; border-radius: var(--r);
  font-family: var(--font); font-size: .79rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: background .14s;
}
.admin-resync-btn:hover { background: var(--ink); }
.admin-resync-btn:disabled { background: var(--muted); cursor: not-allowed; }

/* ─── Stats Strip ──────────────────────────────────────── */
.admin-stats-strip {
  display: flex;
  gap: 0;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.admin-stat-tile {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 24px;
  border-right: 1px solid var(--border);
  min-width: 140px;
  flex-shrink: 0;
}
.admin-stat-tile:last-child { border-right: none; }
.admin-stat-tile > i {
  font-size: 1.1rem;
  color: var(--muted);
  flex-shrink: 0;
}
.admin-stat-tile strong {
  display: block;
  font-size: 1.30rem;
  font-weight: 900;
  color: var(--black);
  line-height: 1.1;
}
.admin-stat-tile span {
  font-size: .67rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ─── Sheet Tab Bar ────────────────────────────────────── */
.admin-sheet-tabs {
  display: flex;
  gap: 0;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  padding: 0 28px;
}
.admin-sheet-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 12px 22px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 700;
  color: var(--mid);
  cursor: pointer;
  transition: color .14s, border-color .14s;
  white-space: nowrap;
  gap: 2px;
}
.admin-sheet-tab i { font-size: .82rem; margin-right: 5px; }
.admin-sheet-tab .tab-subtitle {
  font-size: .65rem;
  font-weight: 500;
  color: var(--light);
  display: block;
  padding-left: 17px;
}
.admin-sheet-tab:hover { color: var(--dark); }
.admin-sheet-tab.active {
  color: var(--black);
  border-bottom-color: var(--black);
  background: var(--white);
}
.admin-sheet-tab.tab-upload { margin-left: auto; }

/* ─── Sheet Panel ──────────────────────────────────────── */
.admin-sheet-panel {
  display: none;
  flex-direction: column;
}
.admin-sheet-panel.active { display: flex; }

/* ─── Toolbar ──────────────────────────────────────────── */
.sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.sheet-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sheet-toolbar-right { display: flex; gap: 8px; flex-shrink: 0; }

.sheet-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-off);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 0 12px;
  min-width: 260px;
}
.sheet-search-wrap i { color: var(--muted); font-size: .80rem; flex-shrink: 0; }
.sheet-search-wrap input {
  border: none; background: transparent;
  font-family: var(--font); font-size: .83rem; color: var(--ink);
  padding: 8px 0; outline: none; width: 100%;
}
.sheet-search-wrap input::placeholder { color: var(--light); }

.sheet-type-filter {
  border: 1.5px solid var(--border); border-radius: var(--r);
  padding: 7px 10px; font-family: var(--font); font-size: .80rem;
  color: var(--ink); background: var(--bg-off);
  outline: none; cursor: pointer;
}
.sheet-type-filter:focus { border-color: var(--black); }

.sheet-row-count {
  font-size: .75rem; color: var(--muted);
  font-weight: 600; white-space: nowrap;
}

.sheet-add-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--black); color: var(--white);
  border: none; padding: 8px 18px; border-radius: var(--r);
  font-family: var(--font); font-size: .79rem; font-weight: 700;
  cursor: pointer; transition: background .13s; white-space: nowrap;
}
.sheet-add-btn:hover { background: var(--ink); }

/* ─── Sheet Table ──────────────────────────────────────── */
.sheet-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 340px);
  min-height: 300px;
  background: var(--white);
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .80rem;
  table-layout: fixed;
}

/* Column widths */
.col-num     { width: 42px; }
.col-product { width: 230px; }
.col-type    { width: 120px; }
.col-item    { width: 240px; }
.col-qty     { width: 60px; }
.col-compat  { width: 82px; }
.col-must    { width: 90px; }
.col-dep     { width: 120px; }
.col-desc    { width: 80px; }
.col-actions { width: 80px; }

/* Header */
.sheet-table thead th {
  background: var(--black);
  color: var(--white);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
  border-right: 1px solid rgba(255,255,255,.08);
}
.sheet-table thead th:last-child { border-right: none; }

/* Sortable header */
.sheet-table thead th.sortable { cursor: pointer; user-select: none; }
.sheet-table thead th.sortable:hover { background: var(--ink); }
.sort-icon { font-size: .60rem; margin-left: 4px; opacity: .65; }

/* Sub-header hint row */
.thead-sub td {
  background: #f0f0f0;
  font-size: .67rem;
  color: var(--muted);
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 40px;
  z-index: 9;
}
.col-hint { font-style: italic; }
.col-hint code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: 'Courier New', monospace;
  font-size: .66rem;
  color: var(--dark);
}

/* Body rows */
.sheet-table tbody tr {
  border-bottom: 1px solid var(--border-lt);
  transition: background .09s;
}
.sheet-table tbody tr:hover { background: #fafafa; }

/* Group separator — first row of a new product */
.prod-group-start td:first-child {
  border-left: 3px solid var(--black);
}
.prod-group-start {
  border-top: 2px solid var(--border);
}
.sheet-table tbody tr:first-child.prod-group-start {
  border-top: none;
}

.sheet-table tbody td {
  padding: 8px 12px;
  color: var(--ink);
  vertical-align: top;
  overflow: hidden;
}

/* Loading state */
.tbl-loading {
  text-align: center;
  padding: 32px;
  color: var(--muted);
  font-size: .84rem;
}

/* ─── Cell contents ────────────────────────────────────── */
.col-num { text-align: right; color: var(--light); font-size: .70rem; font-weight: 700; padding-right: 8px; }

.prod-name-cell { display: flex; flex-direction: column; gap: 2px; }
.prod-name-text {
  font-size: .81rem; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 200px;
}
.prod-repeat-dash { color: var(--light); font-size: .82rem; padding-left: 2px; }

.ean-mono {
  font-family: 'Courier New', monospace;
  font-size: .67rem;
  color: var(--muted);
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  display: inline-block;
  margin-top: 2px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ean-mono.small { font-size: .63rem; }

.item-name-wrap { display: flex; flex-direction: column; gap: 2px; }
.item-name-text {
  font-size: .80rem; font-weight: 500; color: var(--ink);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.qty-badge {
  display: inline-block;
  background: var(--ink); color: var(--white);
  font-size: .64rem; font-weight: 800;
  padding: 2px 7px; border-radius: 3px;
  white-space: nowrap;
}

/* Category type badge */
.type-badge {
  display: inline-block;
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--dark);
}
.type-badge.type-aircraft              { background: #e8f0ff; color: #1a4fb5; border-color: #b3c8ff; }
.type-badge.type-battery               { background: #fff8e8; color: #9a5800; border-color: #ffdd8a; }
.type-badge.type-battery-station       { background: #fffbe8; color: #7a6000; border-color: #ffe99a; }
.type-badge.type-smart-controller      { background: #f0e8ff; color: #5a1ab5; border-color: #c8a8ff; }
.type-badge.type-payload               { background: #e8fff0; color: #1a6e2e; border-color: #8adaaa; }
.type-badge.type-accessories           { background: #f4f4f4; color: #444; border-color: #ddd; }
.type-badge.type-integration-accessories { background: #fff0e8; color: #9a3500; border-color: #ffb88a; }

/* Compat / Must flags */
.flag-yes  { display: inline-block; background: #e8fff0; color: #1a6e2e; border: 1px solid #8adaaa; font-size: .63rem; font-weight: 800; padding: 2px 7px; border-radius: 3px; }
.flag-no   { display: inline-block; background: #fff5f5; color: #c00; border: 1px solid #ffb3b3; font-size: .63rem; font-weight: 800; padding: 2px 7px; border-radius: 3px; }
.flag-must { display: inline-block; background: var(--ink); color: var(--white); font-size: .62rem; font-weight: 800; padding: 2px 7px; border-radius: 3px; white-space: nowrap; }
.flag-opt  { color: var(--light); font-size: .80rem; }

/* Dependency badge */
.dep-badge {
  display: inline-block;
  background: #555; color: var(--white);
  font-size: .60rem; font-weight: 700;
  padding: 2px 6px; border-radius: 3px;
  white-space: nowrap; max-width: 110px;
  overflow: hidden; text-overflow: ellipsis;
}

/* Description indicator */
.has-desc { color: var(--dark); font-size: .80rem; cursor: help; }
.no-desc  { color: var(--light); font-size: .80rem; }

/* Action buttons */
.col-actions { vertical-align: middle; }
.tbl-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 4px;
  border: 1.5px solid var(--border);
  background: var(--white); color: var(--dark);
  cursor: pointer; transition: all .12s; font-size: .72rem;
  margin-right: 3px;
}
.tbl-btn:hover { border-color: var(--dark); }
.tbl-edit:hover { background: var(--black); color: var(--white); border-color: var(--black); }
.tbl-del:hover  { background: #c00; color: var(--white); border-color: #c00; }

/* ─── Pagination ───────────────────────────────────────── */
.sheet-pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 20px;
  background: var(--white);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.pg-info {
  font-size: .72rem; color: var(--muted);
  margin-right: 8px; white-space: nowrap;
}
.pg-btn {
  min-width: 30px; height: 28px; padding: 0 6px;
  border: 1.5px solid var(--border); border-radius: 4px;
  background: var(--white); color: var(--dark);
  font-family: var(--font); font-size: .74rem; font-weight: 600;
  cursor: pointer; transition: all .1s; display: flex; align-items: center; justify-content: center;
}
.pg-btn:hover:not(:disabled) { border-color: var(--dark); background: var(--bg); }
.pg-btn.pg-active { background: var(--black); color: var(--white); border-color: var(--black); }
.pg-btn:disabled { opacity: .35; cursor: not-allowed; }
.pg-ellipsis { font-size: .80rem; color: var(--light); padding: 0 2px; }

/* ─── CSV Upload Panel ─────────────────────────────────── */
.upload-panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 24px 28px;
  max-width: 1200px;
}
.upload-panel-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.upload-panel-card-full { grid-column: 1 / -1; }
.upload-panel-card-title {
  background: var(--black); color: var(--white);
  padding: 11px 18px; font-size: .82rem; font-weight: 800;
  display: flex; align-items: center; gap: 8px; letter-spacing: .02em;
}
.upload-panel-desc {
  font-size: .79rem; color: var(--mid); padding: 14px 18px 10px;
  line-height: 1.55;
}
.upload-panel-desc code {
  font-family: 'Courier New', monospace; font-size: .72rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 5px; color: var(--dark);
  word-break: break-all;
}
.upload-zone-large {
  border: 2px dashed var(--border); border-radius: var(--r);
  margin: 0 18px 18px; padding: 24px 18px;
  text-align: center; background: var(--bg-off);
  transition: border-color .13s;
}
.upload-zone-large:hover { border-color: var(--dark); }
.upload-zone-large i { color: var(--muted); margin-bottom: 10px; display: block; }
.upload-zone-large p { font-size: .82rem; font-weight: 600; color: var(--dark); margin-bottom: 12px; }
.upload-zone-large input[type="file"] { display: none; }

.upload-actions { padding: 14px 18px 8px; }
.upload-note {
  font-size: .76rem; color: var(--muted);
  margin-top: 10px; line-height: 1.5;
  display: flex; gap: 6px; align-items: flex-start;
}
.upload-note i { margin-top: 2px; flex-shrink: 0; }

#sync-status {
  margin: 0 18px 14px;
  padding: 10px 14px;
  border-radius: var(--r);
  font-size: .79rem;
  font-weight: 600;
  display: none;
}
#sync-status.ok  { background: #f0faf0; color: #1a6e2e; border: 1px solid #9ddaaa; display: block; }
#sync-status.err { background: #fff5f5; color: #c00; border: 1px solid #ffb3b3; display: block; }

/* ─── Modals ───────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.modal-backdrop.modal-open {
  display: flex;
}

.modal-box {
  background: var(--white);
  border-radius: var(--r-md);
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn .18s ease;
}
.modal-box-wide { max-width: 900px; }

@keyframes modalIn {
  from { transform: translateY(-18px) scale(.97); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: var(--black); color: var(--white);
  font-size: .88rem; font-weight: 800;
  letter-spacing: .02em; flex-shrink: 0;
}
.modal-close-btn {
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.20);
  color: var(--white); width: 28px; height: 28px;
  border-radius: 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .80rem; transition: background .12s;
}
.modal-close-btn:hover { background: rgba(255,255,255,.22); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-err {
  background: #fff5f5; color: #c00;
  border: 1px solid #ffb3b3;
  border-radius: var(--r);
  padding: 9px 13px;
  font-size: .79rem; font-weight: 600;
  margin-bottom: 14px;
}
.modal-section-label {
  font-size: .70rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* Two-column layout inside wide modal */
.modal-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Form rows */
.form-row {
  margin-bottom: 13px;
}
.form-row label {
  display: block;
  font-size: .75rem; font-weight: 700;
  color: var(--dark); margin-bottom: 5px;
}
.form-row input[type="text"],
.form-row input[type="number"],
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font); font-size: .83rem;
  color: var(--ink); background: var(--bg-off);
  outline: none; transition: border-color .13s;
  box-sizing: border-box;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus { border-color: var(--black); background: var(--white); }
.form-row input::placeholder,
.form-row textarea::placeholder { color: var(--light); }
.form-row textarea { resize: vertical; min-height: 70px; }
.form-row select { cursor: pointer; }
.form-row-half { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.req { color: #c00; }
.field-hint { color: var(--muted); font-weight: 400; font-size: .70rem; }

.modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px; padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-off);
  flex-shrink: 0;
}
.modal-cancel-btn {
  background: var(--white); border: 1.5px solid var(--border);
  color: var(--dark); padding: 8px 20px; border-radius: var(--r);
  font-family: var(--font); font-size: .81rem; font-weight: 700;
  cursor: pointer; transition: all .12s;
}
.modal-cancel-btn:hover { border-color: var(--dark); background: var(--bg); }
.modal-save-btn {
  background: var(--black); border: 1.5px solid var(--black);
  color: var(--white); padding: 8px 22px; border-radius: var(--r);
  font-family: var(--font); font-size: .81rem; font-weight: 700;
  cursor: pointer; transition: background .13s;
  display: flex; align-items: center; gap: 7px;
}
.modal-save-btn:hover { background: var(--ink); }
.modal-save-btn:disabled { background: var(--muted); cursor: not-allowed; border-color: var(--muted); }

/* ─── Responsive ───────────────────────────────────────── */
@media (max-width: 900px) {
  .modal-two-col { grid-template-columns: 1fr; }
  .modal-box-wide { max-width: 98vw; }
  .upload-panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .admin-top-bar { flex-direction: column; }
  .admin-sheet-tabs { padding: 0 10px; }
  .admin-sheet-tab { padding: 10px 14px; font-size: .75rem; }
  .sheet-toolbar { padding: 10px 14px; }
  .sheet-search-wrap { min-width: 180px; }
  .sheet-table-wrap { max-height: 55vh; }
  .upload-panel-grid { padding: 16px; }
}
