/**
 * Plaswill Indicators — Customer, Orders & Goals Drill-Down CSS
 * Design System: Industrial Intelligence (Dark Corporate Telemetry)
 */

.pw-cd-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.72);
  backdrop-filter: blur(5px);
  z-index: 9500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.pw-cd-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.pw-cd-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(1140px, 92vw);
  background: #0B111E;
  border-left: 1px solid rgba(56, 189, 248, 0.22);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.75);
  z-index: 9510;
  display: flex;
  flex-direction: column;
  transform: translateX(102%);
  transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1), width 0.24s ease;
  color: #F8FAFC;
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
  overflow: hidden;
}

.pw-cd-drawer.open {
  transform: translateX(0);
}

.pw-cd-drawer.expanded-full {
  width: 100vw;
  border-left: none;
}

/* Top Header */
.pw-cd-header {
  padding: 16px 22px;
  background: linear-gradient(180deg, rgba(16, 75, 97, 0.32) 0%, rgba(11, 17, 30, 0.95) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.pw-cd-title-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.pw-cd-badges-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pw-cd-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pw-cd-badge.code {
  background: rgba(56, 189, 248, 0.14);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-family: 'JetBrains Mono', monospace;
}

.pw-cd-badge.class-A {
  background: rgba(255, 222, 0, 0.16);
  color: #FFDE00;
  border: 1px solid rgba(255, 222, 0, 0.35);
}

.pw-cd-badge.class-B {
  background: rgba(6, 182, 212, 0.16);
  color: #22D3EE;
  border: 1px solid rgba(6, 182, 212, 0.35);
}

.pw-cd-badge.class-C {
  background: rgba(148, 163, 184, 0.15);
  color: #CBD5E1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.pw-cd-badge.status-active {
  background: rgba(16, 185, 129, 0.14);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.pw-cd-client-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 0;
}

.pw-cd-client-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 0.76rem;
  color: #94A3B8;
}

.pw-cd-client-meta strong {
  color: #E2E8F0;
  font-weight: 600;
}

.pw-cd-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pw-cd-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #E2E8F0;
  white-space: nowrap;
}

.pw-cd-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.24);
  color: #FFFFFF;
}

.pw-cd-btn.primary {
  background: rgba(16, 75, 97, 0.65);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38BDF8;
}

.pw-cd-btn.primary:hover {
  background: rgba(16, 75, 97, 0.9);
  color: #FFFFFF;
}

.pw-cd-btn.accent {
  background: rgba(255, 222, 0, 0.12);
  border-color: rgba(255, 222, 0, 0.35);
  color: #FFDE00;
}

.pw-cd-btn.accent:hover {
  background: rgba(255, 222, 0, 0.22);
}

/* Scrollable Body */
.pw-cd-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 22px 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* KPI Strip (6 cards) */
.pw-cd-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.pw-cd-kpi-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-top: 2px solid #38BDF8;
  border-radius: 7px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pw-cd-kpi-label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94A3B8;
}

.pw-cd-kpi-value {
  font-size: 1.05rem;
  font-weight: 800;
  color: #F8FAFC;
  font-variant-numeric: tabular-nums;
}

.pw-cd-kpi-sub {
  font-size: 0.67rem;
  color: #64748B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Meta & Reconciliation Strip + Evolution Chart Row */
.pw-cd-analytics-row {
  display: grid;
  grid-template-columns: 1.05fr 1.25fr;
  gap: 12px;
}

.pw-cd-panel {
  background: #0F172A;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pw-cd-panel-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 7px;
}

.pw-cd-panel-title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #CBD5E1;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Filter Bar */
.pw-cd-filter-bar {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.16);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pw-cd-filter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.pw-cd-period-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.pw-cd-pill {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 0.71rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94A3B8;
  cursor: pointer;
  transition: all 0.14s ease;
}

.pw-cd-pill:hover {
  color: #E2E8F0;
  border-color: rgba(255, 255, 255, 0.22);
}

.pw-cd-pill.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: #38BDF8;
  color: #38BDF8;
  font-weight: 700;
}

.pw-cd-filter-inputs {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1.2fr 0.9fr 0.9fr 0.75fr 0.75fr auto;
  gap: 8px;
  align-items: end;
}

.pw-cd-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pw-cd-field label {
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748B;
}

.pw-cd-input,
.pw-cd-select {
  background: rgba(6, 10, 19, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  color: #F8FAFC;
  font-size: 0.74rem;
  padding: 6px 8px;
  outline: none;
  width: 100%;
  font-family: inherit;
}

.pw-cd-input:focus,
.pw-cd-select:focus {
  border-color: #38BDF8;
}

/* Orders Table */
.pw-cd-table-wrap {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pw-cd-table-scroll {
  overflow-x: auto;
}

.pw-cd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.pw-cd-table thead th {
  background: rgba(6, 10, 19, 0.9);
  color: #94A3B8;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  user-select: none;
  white-space: nowrap;
}

.pw-cd-table thead th.sortable {
  cursor: pointer;
}

.pw-cd-table thead th.sortable:hover {
  color: #38BDF8;
}

.pw-cd-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.12s ease;
  cursor: pointer;
}

.pw-cd-table tbody tr:hover {
  background: rgba(56, 189, 248, 0.08);
}

.pw-cd-table tbody td {
  padding: 9px 10px;
  color: #E2E8F0;
  vertical-align: middle;
}

/* Status Pill inside Table */
.pw-ord-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  white-space: nowrap;
}

.pw-ord-status.faturado-total {
  background: rgba(16, 185, 129, 0.14);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.pw-ord-status.gerado {
  background: rgba(245, 158, 11, 0.15);
  color: #FBBF24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.pw-ord-status.parcial {
  background: rgba(56, 189, 248, 0.15);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.pw-ord-status.cancelado {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

/* Pagination Bar */
.pw-cd-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(6, 10, 19, 0.65);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.74rem;
  color: #94A3B8;
}

/* Level-2 Order Detail Modal Overlay */
.pw-od-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 5, 11, 0.92);
  backdrop-filter: blur(12px);
  z-index: 9600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.pw-od-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.pw-od-modal {
  width: min(1040px, 96vw);
  max-height: 90vh;
  background: #0B1221;
  border: 1px solid rgba(56, 189, 248, 0.38);
  border-radius: 10px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pw-od-header {
  padding: 14px 20px;
  background: linear-gradient(90deg, rgba(16, 75, 97, 0.4) 0%, rgba(13, 21, 38, 0.95) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pw-od-body {
  padding: 16px 20px 22px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pw-od-meta-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.pw-od-meta-box {
  background: #060A13;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px 10px;
}

.pw-od-meta-box .lbl {
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748B;
  margin-bottom: 2px;
}

.pw-od-meta-box .val {
  font-size: 0.8rem;
  font-weight: 700;
  color: #F8FAFC;
}

/* Clickable Row Affordance in Dashboards */
.pw-clickable-client-row {
  cursor: pointer;
  transition: background 0.14s ease, transform 0.12s ease;
}

.pw-clickable-client-row:hover {
  background: rgba(56, 189, 248, 0.12) !important;
}

.pw-clickable-client-row:hover td:nth-child(2) {
  color: #38BDF8 !important;
  text-decoration: underline;
}

/* Responsive Breakpoints */
@media (max-width: 1100px) {
  .pw-cd-kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .pw-cd-analytics-row {
    grid-template-columns: 1fr;
  }
  .pw-cd-filter-inputs {
    grid-template-columns: repeat(2, 1fr);
  }
  .pw-od-meta-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .pw-cd-drawer {
    width: 100vw;
  }
  .pw-cd-header {
    flex-direction: column;
    padding: 12px 14px;
  }
  .pw-cd-header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }
  .pw-cd-btn {
    padding: 6px 9px;
    font-size: 0.71rem;
  }
  .pw-cd-body {
    padding: 12px 14px 24px 14px;
  }
  .pw-cd-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .pw-cd-filter-inputs {
    grid-template-columns: 1fr;
  }
}
