/* ============================================================================
   Módulo Movimentações de Estoque — Grupo Rocha Saúde
   Material Design 3 Light · paleta verde GRS · DM Sans + Roboto Flex
   ============================================================================ */

:root {
  --mov-radius: 12px;
  --mov-radius-sm: 8px;
  --mov-radius-lg: 16px;
  --mov-gap: 16px;
  --mov-gap-sm: 8px;
  --mov-gap-lg: 24px;
  --mov-border: 1px solid var(--md-outline-variant, #e0e3e1);
  --mov-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.05);
  --mov-shadow-2: 0 4px 16px rgba(0, 0, 0, 0.08);
  --mov-font: 'DM Sans', 'Roboto Flex', system-ui, -apple-system, sans-serif;

  --mov-primary: var(--md-primary, #1b5e20);
  --mov-primary-container: var(--md-primary-container, #d7f3d4);
  --mov-on-primary: var(--md-on-primary, #ffffff);
  --mov-surface: var(--md-surface, #ffffff);
  --mov-surface-container: var(--md-surface-container, #f6f8f6);
  --mov-surface-container-low: var(--md-surface-container-low, #fbfcfb);
  --mov-on-surface: var(--md-on-surface, #1a1c1a);
  --mov-on-surface-variant: var(--md-on-surface-variant, #43474a);
  --mov-outline: var(--md-outline, #72797a);
  --mov-outline-variant: var(--md-outline-variant, #e0e3e1);

  --mov-success: #1b5e20;
  --mov-success-bg: #ecf7ec;
  --mov-warn: #b26a00;
  --mov-warn-bg: #fff3e0;
  --mov-danger: #b71c1c;
  --mov-danger-bg: #ffebee;
  --mov-info: #01579b;
  --mov-info-bg: #e3f2fd;
}

/* Root */
.mov-root {
  font-family: var(--mov-font);
  color: var(--mov-on-surface);
  padding: var(--mov-gap-lg);
  max-width: 1600px;
  margin: 0 auto;
}

/* Header */
.mov-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--mov-gap);
  margin-bottom: var(--mov-gap-lg);
  flex-wrap: wrap;
}
.mov-title {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 4px 0;
  letter-spacing: -0.01em;
}
.mov-subtitle {
  font-size: 14px;
  color: var(--mov-on-surface-variant);
  margin: 0;
}
.mov-header-actions {
  display: flex;
  gap: var(--mov-gap-sm);
  align-items: center;
}

/* Tabs */
.mov-tabs {
  display: flex;
  gap: 4px;
  border-bottom: var(--mov-border);
  margin-bottom: var(--mov-gap-lg);
  overflow-x: auto;
}
.mov-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--mov-on-surface-variant);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.mov-tab:hover {
  color: var(--mov-on-surface);
  background: var(--mov-surface-container-low);
}
.mov-tab .material-icons { font-size: 20px; }
.mov-tab-active {
  color: var(--mov-primary);
  border-bottom-color: var(--mov-primary);
}

/* Buttons */
.mov-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--mov-radius-lg);
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  line-height: 1;
  text-decoration: none;
}
.mov-btn .material-icons { font-size: 18px; }
.mov-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.mov-btn-primary {
  background: var(--mov-primary);
  color: var(--mov-on-primary);
}
.mov-btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.mov-btn-text {
  background: transparent;
  color: var(--mov-primary);
}
.mov-btn-text:hover:not(:disabled) { background: var(--mov-primary-container); }
.mov-btn-danger {
  background: var(--mov-danger);
  color: #fff;
}
.mov-btn-danger:hover:not(:disabled) { filter: brightness(1.1); }

.mov-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--mov-on-surface-variant);
  cursor: pointer;
  transition: background 0.18s ease;
}
.mov-icon-btn:hover { background: var(--mov-surface-container); color: var(--mov-on-surface); }
.mov-icon-btn .material-icons { font-size: 20px; }
.mov-icon-success { color: var(--mov-success); }
.mov-icon-danger { color: var(--mov-danger); }

/* Dropdown */
.mov-dropdown { position: relative; }
.mov-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--mov-surface);
  border: var(--mov-border);
  border-radius: var(--mov-radius);
  box-shadow: var(--mov-shadow-2);
  min-width: 240px;
  padding: 6px;
  z-index: 100;
  display: none;
}
.mov-dropdown-open { display: block; }
.mov-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: var(--mov-radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--mov-on-surface);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}
.mov-dropdown-item:hover { background: var(--mov-surface-container); }
.mov-dropdown-item .material-icons { font-size: 20px; color: var(--mov-on-surface-variant); }

/* Cards resumo */
.mov-cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--mov-gap);
  margin-bottom: var(--mov-gap-lg);
}
.mov-card {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: var(--mov-surface);
  border: var(--mov-border);
  border-radius: var(--mov-radius);
  box-shadow: var(--mov-shadow-1);
}
.mov-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--mov-primary-container);
  color: var(--mov-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mov-card-icon .material-icons { font-size: 22px; }
.mov-card-body { min-width: 0; flex: 1; }
.mov-card-title {
  font-size: 12px;
  color: var(--mov-on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.mov-card-value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.mov-card-warn .mov-card-icon { background: var(--mov-warn-bg); color: var(--mov-warn); }

/* Filters */
.mov-filters {
  display: flex;
  gap: var(--mov-gap-sm);
  margin-bottom: var(--mov-gap);
  flex-wrap: wrap;
  align-items: center;
}
.mov-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--mov-surface);
  border: var(--mov-border);
  border-radius: var(--mov-radius);
  min-width: 280px;
  flex: 1;
  max-width: 420px;
}
.mov-input-group .material-icons { color: var(--mov-on-surface-variant); font-size: 20px; }
.mov-input-group input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font: inherit;
  color: var(--mov-on-surface);
}
.mov-select,
.mov-input-date {
  padding: 10px 12px;
  border: var(--mov-border);
  border-radius: var(--mov-radius);
  background: var(--mov-surface);
  font: inherit;
  color: var(--mov-on-surface);
  cursor: pointer;
}
.mov-select:focus,
.mov-input-date:focus { outline: 2px solid var(--mov-primary); outline-offset: -1px; }

/* Table */
.mov-table-wrapper {
  background: var(--mov-surface);
  border: var(--mov-border);
  border-radius: var(--mov-radius);
  overflow: auto;
  box-shadow: var(--mov-shadow-1);
}
.mov-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.mov-table thead th {
  text-align: left;
  font-weight: 500;
  color: var(--mov-on-surface-variant);
  padding: 12px 16px;
  background: var(--mov-surface-container-low);
  border-bottom: var(--mov-border);
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mov-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--mov-outline-variant);
  vertical-align: middle;
}
.mov-table tbody tr:last-child td { border-bottom: none; }
.mov-table tbody tr:hover { background: var(--mov-surface-container-low); }
.mov-table tfoot td {
  padding: 12px 16px;
  background: var(--mov-surface-container-low);
  border-top: var(--mov-border);
  font-size: 13px;
}
.mov-table code {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 12px;
  background: var(--mov-surface-container);
  padding: 2px 6px;
  border-radius: 4px;
}
.mov-ta-right { text-align: right; }
.mov-ta-center { text-align: center; }
.mov-grams {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.mov-row-warn { background: var(--mov-warn-bg) !important; }
.mov-row-warn:hover { background: #ffe8c2 !important; }

/* Badges */
.mov-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}
.mov-badge-entry { background: var(--mov-success-bg); color: var(--mov-success); }
.mov-badge-exit { background: var(--mov-danger-bg); color: var(--mov-danger); }
.mov-badge-loss { background: #ffe0e0; color: #7a1111; }
.mov-badge-adjust { background: var(--mov-info-bg); color: var(--mov-info); }
.mov-badge-transfer { background: #ede7f6; color: #4527a0; }
.mov-badge-default { background: var(--mov-surface-container); color: var(--mov-on-surface-variant); }

.mov-badge-op-draft { background: #eceff1; color: #455a64; }
.mov-badge-op-validated { background: var(--mov-info-bg); color: var(--mov-info); }
.mov-badge-op-producing { background: var(--mov-warn-bg); color: var(--mov-warn); }
.mov-badge-op-done { background: var(--mov-success-bg); color: var(--mov-success); }
.mov-badge-op-cancelled { background: var(--mov-danger-bg); color: var(--mov-danger); }

/* Empty state */
.mov-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--mov-on-surface-variant);
}
.mov-empty .material-icons {
  font-size: 48px;
  color: var(--mov-outline);
  margin-bottom: 12px;
  display: block;
}
.mov-empty h4 {
  margin: 0 0 6px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--mov-on-surface);
}
.mov-empty p { margin: 0; font-size: 14px; }

/* Pagination */
.mov-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  margin-top: var(--mov-gap);
  font-size: 13px;
  color: var(--mov-on-surface-variant);
}
.mov-pagination > div { display: flex; gap: 4px; }

/* Loading */
.mov-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 64px;
  color: var(--mov-on-surface-variant);
  font-size: 14px;
}
.mov-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--mov-outline-variant);
  border-top-color: var(--mov-primary);
  border-radius: 50%;
  animation: mov-spin 0.9s linear infinite;
  display: inline-block;
}
@keyframes mov-spin { to { transform: rotate(360deg); } }

/* Modal */
.mov-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: mov-fade-in 0.2s ease;
}
@keyframes mov-fade-in { from { opacity: 0; } to { opacity: 1; } }
.mov-modal {
  background: var(--mov-surface);
  border-radius: var(--mov-radius-lg);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--mov-shadow-2);
  overflow: hidden;
  animation: mov-slide-up 0.25s ease;
}
@keyframes mov-slide-up { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.mov-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: var(--mov-border);
}
.mov-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.mov-modal-header h3 .material-icons { color: var(--mov-primary); font-size: 22px; }
.mov-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.mov-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: var(--mov-border);
  background: var(--mov-surface-container-low);
}

/* Form */
.mov-form-row {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--mov-gap);
  margin-bottom: var(--mov-gap);
}
.mov-form-row:last-child { margin-bottom: 0; }
.mov-col-12 { grid-column: span 12; }
.mov-col-6 { grid-column: span 6; }
@media (max-width: 640px) {
  .mov-col-6 { grid-column: span 12; }
}
.mov-form-field { display: flex; flex-direction: column; gap: 6px; }
.mov-form-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--mov-on-surface-variant);
}
.mov-form-field input,
.mov-form-field select,
.mov-form-field textarea {
  padding: 10px 12px;
  border: var(--mov-border);
  border-radius: var(--mov-radius-sm);
  background: var(--mov-surface);
  font: inherit;
  color: var(--mov-on-surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.mov-form-field input:focus,
.mov-form-field select:focus,
.mov-form-field textarea:focus {
  outline: none;
  border-color: var(--mov-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mov-primary) 15%, transparent);
}
.mov-form-field textarea { resize: vertical; min-height: 60px; }
.mov-hint {
  font-size: 12px;
  color: var(--mov-on-surface-variant);
}

/* Typeahead */
.mov-typeahead-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--mov-surface);
  border: var(--mov-border);
  border-radius: var(--mov-radius-sm);
  box-shadow: var(--mov-shadow-2);
  max-height: 280px;
  overflow-y: auto;
  z-index: 2000;
  display: none;
}
.mov-typeahead-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--mov-outline-variant);
  font-size: 14px;
  transition: background 0.12s ease;
}
.mov-typeahead-item:last-child { border-bottom: none; }
.mov-typeahead-item:hover { background: var(--mov-primary-container); }
.mov-typeahead-item code,
.mov-typeahead-item strong { font-weight: 600; color: var(--mov-primary); }
.mov-typeahead-empty {
  padding: 12px;
  color: var(--mov-on-surface-variant);
  font-size: 13px;
  text-align: center;
}

/* Stepper (OP wizard) */
.mov-stepper {
  display: flex;
  gap: 4px;
  margin-bottom: var(--mov-gap-lg);
  padding-bottom: 12px;
  border-bottom: var(--mov-border);
}
.mov-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--mov-on-surface-variant);
  position: relative;
  border-radius: var(--mov-radius-sm);
}
.mov-step span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--mov-outline-variant);
  color: var(--mov-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.mov-step-active {
  color: var(--mov-primary);
  font-weight: 500;
}
.mov-step-active span {
  background: var(--mov-primary);
  color: var(--mov-on-primary);
}
.mov-step-done span {
  background: var(--mov-success-bg);
  color: var(--mov-success);
}
.mov-step-done { color: var(--mov-on-surface); }

/* OP wizard body */
.mov-op-wizard { min-height: 200px; }

/* BOM table */
.mov-bom-table tbody tr.mov-bom-row-ok { background: color-mix(in srgb, var(--mov-success-bg) 50%, transparent); }
.mov-bom-table tbody tr.mov-bom-row-insufficient { background: var(--mov-danger-bg); }

/* Alerts */
.mov-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--mov-radius);
  margin-bottom: var(--mov-gap);
  font-size: 14px;
}
.mov-alert .material-icons { flex-shrink: 0; font-size: 22px; margin-top: 1px; }
.mov-alert-success { background: var(--mov-success-bg); color: var(--mov-success); }
.mov-alert-warn { background: var(--mov-warn-bg); color: var(--mov-warn); }
.mov-alert-danger { background: var(--mov-danger-bg); color: var(--mov-danger); }

/* OP summary */
.mov-op-summary {
  padding: 20px;
  background: var(--mov-surface-container-low);
  border-radius: var(--mov-radius);
  border: var(--mov-border);
  margin-bottom: var(--mov-gap);
}
.mov-op-summary h4 { margin: 0 0 12px 0; font-size: 15px; font-weight: 600; }

/* Key-Value */
.mov-kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--mov-outline-variant);
  font-size: 14px;
  gap: var(--mov-gap);
}
.mov-kv:last-child { border-bottom: none; }
.mov-kv > span:first-child { color: var(--mov-on-surface-variant); font-size: 13px; }
.mov-kv > strong { color: var(--mov-on-surface); font-weight: 600; text-align: right; }
.mov-kv-block { flex-direction: column; align-items: flex-start; }
.mov-kv-block p { margin: 4px 0 0 0; color: var(--mov-on-surface); }

/* Drawer */
.mov-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 900;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.mov-drawer-open { opacity: 1; }
.mov-drawer {
  background: var(--mov-surface);
  width: 560px;
  max-width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.1);
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.mov-drawer-open .mov-drawer { transform: translateX(0); }
.mov-drawer-header {
  padding: 20px 24px;
  border-bottom: var(--mov-border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.mov-drawer-header h3 { margin: 0 0 4px 0; font-size: 18px; font-weight: 600; }
.mov-drawer-header p { margin: 0; font-size: 13px; color: var(--mov-on-surface-variant); }
.mov-drawer-op { background: var(--mov-surface-container-low); }
.mov-drawer-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.mov-drawer-body h4 {
  margin: 20px 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--mov-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mov-drawer-body h4:first-child { margin-top: 0; }
.mov-drawer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: var(--mov-border);
  background: var(--mov-surface-container-low);
}

/* Toast */
.mov-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--mov-surface);
  border: var(--mov-border);
  border-radius: var(--mov-radius);
  padding: 12px 18px;
  box-shadow: var(--mov-shadow-2);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 3000;
  max-width: calc(100% - 40px);
}
.mov-toast-show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.mov-toast .material-icons { font-size: 20px; }
.mov-toast-success { border-left: 4px solid var(--mov-success); }
.mov-toast-success .material-icons { color: var(--mov-success); }
.mov-toast-error { border-left: 4px solid var(--mov-danger); }
.mov-toast-error .material-icons { color: var(--mov-danger); }
.mov-toast-warn { border-left: 4px solid var(--mov-warn); }
.mov-toast-warn .material-icons { color: var(--mov-warn); }
.mov-toast-info { border-left: 4px solid var(--mov-info); }
.mov-toast-info .material-icons { color: var(--mov-info); }

/* Responsive */
@media (max-width: 860px) {
  .mov-root { padding: var(--mov-gap); }
  .mov-title { font-size: 22px; }
  .mov-header-actions { width: 100%; justify-content: flex-end; }
  .mov-cards-row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .mov-card-value { font-size: 18px; }
  .mov-table { font-size: 13px; }
  .mov-table thead th,
  .mov-table tbody td { padding: 8px 10px; }
  .mov-stepper { overflow-x: auto; }
  .mov-step { white-space: nowrap; }
}
