/* =========================================
   潮顺危固废智慧管家 - 对话框 & 高级组件样式
   ========================================= */

/* ===================================
   MODAL / DIALOG
   =================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: oklch(14% 0.01 250 / 0.5);
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  backdrop-filter: blur(2px);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px oklch(14% 0.01 250 / 0.2);
  min-width: 460px;
  max-width: 90vw;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(16px) scale(0.97);
  transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
}

/* ===================================
   FORM COMPONENTS
   =================================== */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.form-row.single { grid-template-columns: 1fr; }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-field label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.86rem;
  color: var(--text-primary);
  background: var(--gray-50);
  transition: var(--transition);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px oklch(52% 0.18 160 / 0.1);
}

.form-field textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* ===================================
   TOAST NOTIFICATIONS
   =================================== */
.toast-container {
  position: fixed;
  top: calc(var(--topbar-height) + 16px);
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border-left: 3px solid var(--primary);
  font-size: 0.86rem;
  color: var(--text-primary);
  min-width: 260px;
  animation: toastIn 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  pointer-events: all;
}

.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===================================
   LOADING SPINNER
   =================================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: oklch(100% 0 0 / 0.8);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===================================
   CONFIRM DIALOG
   =================================== */
.confirm-dialog {
  min-width: 360px;
}

.confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--danger-bg);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.confirm-text {
  text-align: center;
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.6;
}

.confirm-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 6px;
}

/* ===================================
   QR CODE DIALOG
   =================================== */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: var(--space-md) 0;
}

.qr-placeholder {
  width: 180px;
  height: 180px;
  background: var(--gray-100);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.qr-info {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ===================================
   DETAIL DRAWER
   =================================== */
.detail-drawer {
  position: fixed;
  top: var(--topbar-height);
  right: -500px;
  width: 480px;
  height: calc(100vh - var(--topbar-height));
  background: white;
  box-shadow: -4px 0 24px oklch(14% 0.01 250 / 0.12);
  z-index: 600;
  transition: right 0.28s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-drawer.open { right: 0; }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

.detail-section {
  margin-bottom: var(--space-lg);
}

.detail-section-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail-label {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.detail-value {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* ===================================
   DRAG OVERLAY (sidebar resize)
   =================================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 150;
}

/* ===================================
   FORM DRAWER (右侧滑出表单)
   =================================== */
.form-drawer {
  position: fixed;
  top: var(--topbar-height);
  right: -600px;
  width: 560px;
  max-width: 92vw;
  height: calc(100vh - var(--topbar-height));
  background: white;
  box-shadow: -4px 0 24px oklch(14% 0.01 250 / 0.12);
  z-index: 650;
  transition: right 0.28s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.form-drawer.open { right: 0; }

.form-drawer .drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--gray-50);
}

.form-drawer .drawer-header .drawer-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-drawer .drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

.form-drawer .drawer-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
  flex-shrink: 0;
}

/* Form sections inside drawer */
.drawer-section {
  margin-bottom: var(--space-lg);
}

.drawer-section-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1.5px solid var(--primary-border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.drawer-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.drawer-form-row.single { grid-template-columns: 1fr; }
.drawer-form-row.triple { grid-template-columns: 1fr 1fr 1fr; }

.drawer-form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.drawer-form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.drawer-form-group label .required-mark {
  color: var(--danger);
  margin-left: 2px;
}

.drawer-form-group input,
.drawer-form-group select,
.drawer-form-group textarea {
  padding: 8px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--gray-50);
  transition: var(--transition);
}

.drawer-form-group input:focus,
.drawer-form-group select:focus,
.drawer-form-group textarea:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px oklch(52% 0.18 160 / 0.1);
}

.drawer-form-group textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.5;
}

.drawer-help-text {
  margin-top: var(--space-sm);
  padding: 9px 11px;
  border-radius: var(--radius);
  background: var(--gray-50);
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* Waste detail table */
.waste-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: var(--space-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.waste-detail-table thead {
  background: var(--gray-50);
}

.waste-detail-table th {
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border);
}

.waste-detail-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.waste-detail-table .form-input-sm {
  width: 100%;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

/* Conditional fields */
.conditional-fields {
  display: none;
  padding: var(--space-md);
  background: var(--warning-bg);
  border-radius: var(--radius);
  border: 1px dashed oklch(75% 0.12 65);
  margin-top: var(--space-md);
}

/* Drawer overlay */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: oklch(14% 0.01 250 / 0.35);
  z-index: 640;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.drawer-overlay.active {
  opacity: 1;
  pointer-events: all;
}

@media (max-width: 768px) {
  .sidebar-overlay { display: block; }
  .form-drawer {
    width: 100vw;
    max-width: 100vw;
    right: -100vw;
  }
}
/* Enterprise REST integration states */
.topbar-right { position: relative; }

.topbar-btn { position: relative; }

.notification-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}

.notification-panel {
  position: absolute;
  z-index: 1200;
  top: calc(100% + 10px);
  right: 140px;
  width: 340px;
  max-height: 430px;
  overflow: hidden;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.16);
}

.notification-panel-title {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
}

.notification-panel-body {
  max-height: 370px;
  overflow-y: auto;
  padding: 8px;
  color: var(--gray-600);
}

.notification-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border-radius: 7px;
}

.notification-item + .notification-item { border-top: 1px solid var(--gray-100); }
.notification-item.is-unread { background: rgba(22, 163, 74, 0.07); }
.notification-item strong { color: var(--gray-800); font-size: 13px; }
.notification-item p { margin: 0; color: var(--gray-600); font-size: 12px; line-height: 1.5; }
.notification-item span { font-size: 12px; color: var(--gray-500); }

.empty-state.is-error { color: #dc2626; }

.monthly-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 8px;
  min-height: 190px;
  padding: 12px 8px 0;
  border-bottom: 1px solid var(--gray-200);
}

.chart-area.is-daily-chart {
  overflow-x: auto;
}

.monthly-bars.is-daily {
  min-width: max(100%, 960px);
  justify-content: flex-start;
  gap: 6px;
}

.monthly-bars.is-daily .monthly-bar-column {
  flex: 1 0 24px;
  min-width: 24px;
}

.monthly-bars.is-daily .monthly-bar {
  width: min(20px, 72%);
}

.monthly-bar-column {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  height: 180px;
  color: var(--gray-500);
  font-size: 11px;
}

.monthly-bar {
  width: min(28px, 70%);
  min-height: 2px;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, #16a34a, #86efac);
  transition: height .2s ease;
}

.rest-detail-list {
  display: grid;
  grid-template-columns: minmax(100px, auto) 1fr;
  gap: 8px 18px;
  max-height: 55vh;
  margin: 18px 0;
  overflow-y: auto;
}

.rest-detail-list dt { color: var(--gray-500); }
.rest-detail-list dd { margin: 0; color: var(--gray-900); word-break: break-all; }

/* 台账详情：参考省平台的分区表格布局 */
.ledger-detail-modal {
  width: min(1000px, 94vw);
  min-width: 0;
  max-height: 90vh;
}
.ledger-detail-header { padding: 16px 22px; }
.ledger-detail-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: #f5faf7;
  border-bottom: 1px solid var(--border);
}
.ledger-detail-toolbar .btn-danger {
  background: #ef6a6a;
  color: white;
}
.ledger-detail-toolbar .btn-success {
  background: var(--primary);
  color: white;
}
.ledger-detail-body { padding: 18px 22px 24px; overflow-y: auto; }
.ledger-detail-section + .ledger-detail-section { margin-top: 24px; }
.ledger-detail-section h4 {
  margin: 0 0 10px;
  padding: 0 0 9px;
  border-bottom: 2px solid var(--primary);
  color: var(--text-primary);
  font-size: 1rem;
}
.ledger-detail-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: .84rem;
}
.ledger-detail-table td {
  border: 1px solid #d7e1ee;
  padding: 9px 12px;
  vertical-align: top;
  word-break: break-word;
}
.ledger-detail-table td.label {
  width: 14%;
  background: #f7fafc;
  color: #4b5563;
  text-align: right;
  white-space: normal;
}
.ledger-detail-table td.value { width: 36%; color: #334155; }
.ledger-detail-table td.wide { width: 86%; }
.ledger-detail-weight-input {
  width: 100%;
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid var(--primary);
  border-radius: 4px;
  color: #334155;
  background: #fff;
  outline: none;
}
.ledger-detail-weight-input:focus { box-shadow: 0 0 0 2px rgb(22 163 74 / 12%); }
.ledger-detail-modal .modal-footer { padding: 12px 22px; }
.quick-inbound-modal {
  width: min(480px, 92vw);
  min-width: 0;
}
.quick-inbound-body {
  display: grid;
  gap: 14px;
  padding: 20px 26px 24px;
}
.quick-inbound-field {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: .84rem;
}
.quick-inbound-field > span { text-align: right; }
.quick-inbound-field b { color: #ef4444; font-weight: 500; }
.quick-inbound-field input,
.quick-inbound-field select {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid #d6deea;
  border-radius: 4px;
  background: #f8fbff;
  color: #334155;
  outline: none;
}
.quick-inbound-field input:focus,
.quick-inbound-field select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgb(22 163 74 / 12%); }
.quick-inbound-footer { justify-content: center; gap: 12px; padding: 14px 22px 22px; }
@media (max-width: 720px) {
  .ledger-detail-modal { width: 96vw; }
  .ledger-detail-toolbar { padding: 9px 14px; overflow-x: auto; }
  .ledger-detail-body { padding: 14px; }
  .ledger-detail-table { font-size: .76rem; }
  .ledger-detail-table td { padding: 7px 8px; }
  .ledger-detail-table td.label { width: 22%; }
  .ledger-detail-table td.value { width: 28%; }
  .quick-inbound-field { grid-template-columns: 96px 1fr; }
}
.qr-modal { text-align: center; }
.qr-modal .qr-code { display: flex; justify-content: center; margin: 18px auto 12px; }
.qr-modal .qr-code img,
.qr-modal .qr-code canvas { display: block; width: 240px; height: 240px; max-width: 100%; }
.qr-modal .qr-payload-text { margin: 12px 0 16px; padding: 10px 12px; border-radius: 6px; background: var(--gray-50); color: var(--text-muted); font-family: monospace; font-size: .75rem; line-height: 1.5; text-align: left; word-break: break-all; }
.btn-action:disabled { cursor: not-allowed; opacity: .45; }

@media (max-width: 720px) {
  .notification-panel { position: fixed; top: 58px; right: 12px; left: 12px; width: auto; }
  .monthly-bars { gap: 3px; }
  .monthly-bar-column { font-size: 9px; }
}
