/* TAPPI OPERATIONAL ADMIN STYLES — Phase 3 MVP */

.admin-wrapper {
  min-height: 100vh;
  background-color: #F8F9FA;
  padding: 1.5rem 2rem;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  color: #1A1A1A;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #E5E7EB;
  flex-wrap: wrap;
  gap: 1rem;
}

.admin-badge {
  background-color: #1E293B;
  color: #FFFFFF;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Operational KPI Grid */
.admin-kpis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.admin-kpi-card {
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
}

.admin-kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.admin-kpi-val {
  font-size: 1.45rem;
  font-weight: 800;
  color: #0F172A;
  line-height: 1.2;
}

.admin-kpi-sub {
  font-size: 0.7rem;
  color: #94A3B8;
  margin-top: 0.25rem;
}

/* Admin Toolbar */
.admin-toolbar {
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.admin-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  flex: 1;
}

.admin-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.admin-input, .admin-select {
  padding: 0.45rem 0.75rem;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: inherit;
  background-color: #FFFFFF;
  color: #111827;
  outline: none;
  transition: border-color 0.15s;
}

.admin-input:focus, .admin-select:focus {
  border-color: #2563EB;
}

.admin-input {
  min-width: 220px;
}

/* Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-generated { background: #F1F5F9; color: #475569; }
.status-produced  { background: #E0E7FF; color: #3730A3; }
.status-available { background: #FEF3C7; color: #92400E; }
.status-allocated { background: #E0F2FE; color: #0369A1; }
.status-active    { background: #DCFCE7; color: #166534; }
.status-disabled  { background: #FEE2E2; color: #991B1B; }

/* Order Lifecycle Statuses */
.status-pending_payment { background: #FEF3C7; color: #92400E; }
.status-paid { background: #E0E7FF; color: #3730A3; }
.status-processing { background: #E0F2FE; color: #0369A1; }
.status-shipped { background: #EDE9FE; color: #6D28D9; }
.status-delivered { background: #DCFCE7; color: #166534; }
.status-completed { background: #D1FAE5; color: #065F46; }
.status-cancelled { background: #FEE2E2; color: #991B1B; }

.status-dot-sm {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.status-generated .status-dot-sm { background: #64748B; }
.status-produced  .status-dot-sm { background: #4F46E5; }
.status-available .status-dot-sm { background: #D97706; }
.status-allocated .status-dot-sm { background: #0284C7; }
.status-active    .status-dot-sm { background: #16A34A; }
.status-disabled  .status-dot-sm { background: #DC2626; }
.status-pending_payment .status-dot-sm { background: #D97706; }
.status-paid .status-dot-sm { background: #4F46E5; }
.status-processing .status-dot-sm { background: #0284C7; }
.status-shipped .status-dot-sm { background: #7C3AED; }
.status-delivered .status-dot-sm { background: #16A34A; }
.status-completed .status-dot-sm { background: #059669; }
.status-cancelled .status-dot-sm { background: #DC2626; }

/* Admin View Nav Tabs */
.admin-nav-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid #E5E7EB;
}

.admin-nav-tab {
  padding: 0.65rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #64748B;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: -2px;
}

.admin-nav-tab:hover {
  color: #0F172A;
}

.admin-nav-tab.active {
  color: #2563EB;
  border-bottom-color: #2563EB;
}

/* Product Badge */
.product-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #F3F4F6;
  color: #374151;
  border: 1px solid #E5E7EB;
}

/* Table Container */
.admin-table-container {
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  overflow-x: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.82rem;
}

.admin-table th {
  background: #F8FAFC;
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: #475569;
  border-bottom: 1px solid #E2E8F0;
  white-space: nowrap;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #F1F5F9;
  color: #1E293B;
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background: #F8FAFC;
}

.admin-code-pill {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: #0F172A;
  background: #F1F5F9;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  border: 1px solid #CBD5E1;
  display: inline-block;
}

.admin-batch-pill {
  font-family: monospace;
  font-size: 0.75rem;
  color: #475569;
}

/* Button variants */
.btn-admin {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-admin-primary {
  background: #0F172A;
  color: #FFFFFF;
}
.btn-admin-primary:hover {
  background: #334155;
}

.btn-admin-secondary {
  background: #FFFFFF;
  color: #334155;
  border: 1px solid #D1D5DB;
}
.btn-admin-secondary:hover {
  background: #F8FAFC;
  border-color: #9CA3AF;
}

.btn-admin-danger {
  background: #FEF2F2;
  color: #B91C1C;
  border: 1px solid #FECACA;
}
.btn-admin-danger:hover {
  background: #FEE2E2;
}

.btn-admin-success {
  background: #F0FDF4;
  color: #15803D;
  border: 1px solid #BBF7D0;
}
.btn-admin-success:hover {
  background: #DCFCE7;
}

.btn-admin-xs {
  padding: 0.2rem 0.5rem;
  font-size: 0.74rem;
  border-radius: 6px;
}

/* Modal specifics */
.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.admin-modal-box {
  background: #FFFFFF;
  border-radius: 14px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  border: 1px solid #E2E8F0;
  display: flex;
  flex-direction: column;
}

.admin-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.admin-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #E2E8F0;
  background: #F8FAFC;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  font-size: 0.82rem;
}

.spec-item {
  background: #F8FAFC;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid #E2E8F0;
}

.spec-item-label {
  font-size: 0.7rem;
  color: #64748B;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 2px;
}

.spec-item-value {
  font-weight: 600;
  color: #0F172A;
  word-break: break-all;
}

/* ======================================================== */
/* ADMIN RESPONSIVE OVERRIDES                               */
/* ======================================================== */
@media (max-width: 1023px) {
  .admin-wrapper {
    padding: 1.25rem 1rem;
  }
  .admin-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }
  .admin-toolbar-left {
    width: 100%;
  }
  .admin-toolbar-right {
    width: 100%;
    justify-content: flex-start;
  }
  .admin-kpis-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 639px) {
  .admin-wrapper {
    padding: 1rem 0.75rem calc(1.5rem + var(--sab));
  }
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .admin-header > div:last-child {
    width: 100%;
    display: flex;
    gap: 0.5rem;
  }
  .admin-header > div:last-child .btn-admin {
    flex: 1;
    justify-content: center;
    font-size: 0.78rem;
  }
  .admin-nav-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    padding-bottom: 2px;
  }
  .admin-nav-tab {
    white-space: nowrap;
    padding: 0.55rem 0.85rem;
    font-size: 0.8rem;
  }
  .admin-kpis-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }
  .admin-kpi-card {
    padding: 0.75rem 0.85rem;
  }
  .admin-kpi-val {
    font-size: 1.25rem;
  }
  .admin-toolbar-left {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .admin-input, .admin-select {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    box-sizing: border-box;
  }
  .admin-toolbar-right {
    flex-direction: column;
    align-items: stretch;
  }
  .admin-toolbar-right .btn-admin {
    width: 100%;
    justify-content: center;
    min-height: 42px;
  }
  .admin-table-container {
    border: none;
    background: transparent;
    box-shadow: none;
    overflow-x: visible;
  }
  .admin-table,
  .admin-table thead,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block;
  }
  .admin-table thead {
    display: none;
  }
  .admin-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  .admin-table tbody tr {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  .admin-table td {
    padding: 0;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
  }
  .admin-table td:first-child {
    border-bottom: 1px solid #F1F5F9;
    padding-bottom: 0.5rem;
    margin-bottom: 0.25rem;
  }
  .admin-table td:last-child {
    border-top: 1px solid #F1F5F9;
    padding-top: 0.75rem;
    margin-top: 0.25rem;
    justify-content: flex-end;
  }
  .admin-table td:last-child > div {
    width: 100%;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .admin-table td:last-child .btn-admin {
    flex: 1;
    justify-content: center;
    min-height: 40px;
  }
  .spec-grid {
    grid-template-columns: 1fr;
  }
  .admin-modal-box {
    max-height: 90dvh;
    border-radius: 18px 18px 0 0;
    width: 100%;
  }
  .admin-modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
}
