/* ═══ Painel Admin v2 ═══ */

.admin-shell {
  position: fixed;
  inset: 0;
  z-index: 30000;
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #060910;
  color: #fff;
}

.admin-shell[hidden] {
  display: none !important;
}

/* Sidebar */
.admin-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  background: #0a0e16;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 20px 14px;
}

.admin-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 16px;
}

.admin-brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #df5837, #b42748);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.admin-sidebar-brand strong {
  display: block;
  font-family: "Poppins", sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-sidebar-brand small {
  color: #9c9c9d;
  font-size: 0.72rem;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #9c9c9d;
  font-family: "Inter", sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.admin-nav-item .nav-ico {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
}

.admin-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.admin-nav-item.active {
  background: rgba(223, 88, 55, 0.15);
  color: #fff;
  box-shadow: inset 3px 0 0 #df5837;
}

.admin-sidebar-foot {
  padding: 14px 10px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.78rem;
  color: #9c9c9d;
}

.admin-sidebar-foot span::before {
  content: "👤 ";
}

/* Main area */
.admin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: #060910;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 14, 22, 0.6);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.admin-topbar h2 {
  font-family: "Poppins", sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}

.admin-topbar p {
  font-size: 0.82rem;
  color: #9c9c9d;
}

.admin-topbar-actions {
  display: flex;
  gap: 8px;
}

.admin-viewport {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 24px 28px 40px;
  position: relative;
}

.admin-viewport::-webkit-scrollbar {
  width: 10px;
}

.admin-viewport::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
}

.admin-viewport::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #df5837, #b42748);
  border-radius: 999px;
  border: 2px solid #060910;
}

.admin-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(6, 9, 16, 0.7);
  backdrop-filter: blur(4px);
  color: #9c9c9d;
  font-size: 0.88rem;
}

.admin-loading[hidden] {
  display: none !important;
}

.admin-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #df5837;
  border-radius: 50%;
  animation: adminSpin 0.8s linear infinite;
}

@keyframes adminSpin {
  to { transform: rotate(360deg); }
}

.admin-panel {
  display: none;
  flex-direction: column;
  gap: 20px;
  animation: adminFadeIn 0.25s ease;
}

.admin-panel.active {
  display: flex;
  min-height: min-content;
  padding-bottom: 8px;
}

.admin-panel[data-panel="products"].active {
  gap: 16px;
}

@keyframes adminFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPI cards */
.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.admin-kpi {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s;
}

.admin-kpi:hover {
  border-color: rgba(223, 88, 55, 0.3);
}

.admin-kpi .kpi-ico {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.admin-kpi strong {
  font-family: "Poppins", sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: #df5837;
  line-height: 1;
}

.admin-kpi span {
  font-size: 0.78rem;
  color: #9c9c9d;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-kpi.accent strong {
  color: #4ade80;
}

/* Cards */
.admin-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 20px 22px;
}

.admin-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.admin-card-head h3,
.admin-card h3 {
  font-family: "Poppins", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-card-table {
  padding: 0;
  overflow: hidden;
}

.admin-card-form h3 {
  margin-bottom: 14px;
}

/* Toolbar */
.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.admin-search {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 11px 16px;
  color: #fff;
  font-family: "Inter", sans-serif;
  font-size: 0.88rem;
  outline: none;
}

.admin-search:focus {
  border-color: rgba(223, 88, 55, 0.5);
  box-shadow: 0 0 0 3px rgba(223, 88, 55, 0.12);
}

.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: #9c9c9d;
  font-family: "Inter", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.admin-chip:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.admin-chip.active {
  background: rgba(223, 88, 55, 0.15);
  border-color: rgba(223, 88, 55, 0.4);
  color: #fff;
}

/* Tables */
.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.admin-table th,
.admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}

.admin-table th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9c9c9d;
  background: rgba(0, 0, 0, 0.2);
}

.admin-table tbody tr {
  transition: background 0.15s;
}

.admin-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.admin-table code {
  font-size: 0.72rem;
  color: #9c9c9d;
  word-break: break-all;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-badge.paid,
.status-badge.delivered {
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
}

.status-badge.pending {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
}

.status-badge.failed,
.status-badge.cancelled {
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
}

.status-badge.open {
  background: rgba(96, 165, 250, 0.12);
  color: #60a5fa;
}

/* Product editor grid */
.admin-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.admin-product-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-product-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-product-card-head .p-ico {
  font-size: 1.8rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
}

.admin-product-card-head .p-meta strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

.admin-product-card-head .p-meta small {
  color: #9c9c9d;
  font-size: 0.72rem;
}

.admin-product-card .checkout-input {
  margin-bottom: 0;
  font-size: 0.88rem;
  padding: 10px 12px;
}

.admin-product-card .checkout-label {
  font-size: 0.72rem;
  margin-bottom: 4px;
}

.admin-savebar {
  position: sticky;
  bottom: 0;
  z-index: 4;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 16px 20px;
  background: rgba(6, 9, 16, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  backdrop-filter: blur(8px);
}

.admin-savebar span {
  color: #fbbf24;
  font-size: 0.82rem;
  font-weight: 600;
}

/* Form row */
.admin-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.admin-form-row .checkout-input {
  flex: 1;
  min-width: 140px;
  margin-bottom: 0;
}

/* Settings */
.admin-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.admin-settings-grid .admin-card .checkout-label {
  margin-top: 12px;
}

.admin-settings-grid .admin-card .checkout-label:first-of-type {
  margin-top: 0;
}

/* Tickets layout */
.admin-tickets-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  min-height: 480px;
}

.admin-tickets-list {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.admin-tickets-list .admin-card-head {
  padding: 16px 18px 0;
  margin-bottom: 8px;
}

.admin-tickets-list #adminTicketList {
  overflow-y: auto;
  flex: 1;
  padding: 8px 12px 12px;
}

.admin-tickets-chat {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

#adminTicketChat {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 18px;
  overflow-y: auto;
}

.admin-ticket-chat-head {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-ticket-chat-head h4 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.admin-ticket-chat-head small {
  color: #9c9c9d;
}

.admin-ticket-msgs {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  max-height: 320px;
}

.admin-ticket-reply {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-ticket-reply textarea {
  resize: vertical;
  min-height: 80px;
}

/* Coupon toggle */
.coupon-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: background 0.2s;
}

.coupon-toggle.on {
  background: rgba(74, 222, 128, 0.35);
}

.coupon-toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

.coupon-toggle.on::after {
  transform: translateX(20px);
}

/* Empty state */
.admin-empty {
  text-align: center;
  padding: 48px 24px;
  color: #9c9c9d;
  font-size: 0.9rem;
}

.admin-empty::before {
  content: "📭";
  display: block;
  font-size: 2rem;
  margin-bottom: 10px;
  opacity: 0.5;
}

/* Order detail expand */
.order-items-cell {
  max-width: 220px;
  font-size: 0.78rem;
  color: #9c9c9d;
}

/* Responsive */
@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .admin-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px;
    gap: 8px;
  }

  .admin-sidebar-brand {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
    flex: 1;
  }

  .admin-nav {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    order: 3;
  }

  .admin-nav-item {
    flex: 1;
    min-width: 100px;
    justify-content: center;
    padding: 10px;
    font-size: 0.78rem;
  }

  .admin-nav-item .nav-ico {
    display: none;
  }

  .admin-sidebar-foot {
    display: none;
  }

  .admin-tickets-layout {
    grid-template-columns: 1fr;
  }

  .admin-topbar {
    padding: 16px 18px;
  }

  .admin-viewport {
    padding: 16px 18px 24px;
  }
}
