/* ═══════════════════════════════════════════════════════
   GIS-Điện Bàn Bắc — M3 Components
   ═══════════════════════════════════════════════════════ */

/* ─── Buttons ─── */
.md-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 24px;
  border: none; border-radius: var(--md-sys-shape-full); cursor: pointer;
  font-family: var(--md-sys-typescale-font-family-text);
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  line-height: var(--md-sys-typescale-label-large-line-height);
  transition: all var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
  position: relative; overflow: hidden; white-space: nowrap; text-decoration: none;
}
.md-btn .material-symbols-outlined { font-size: 18px; }
.md-btn:active { transform: scale(0.97); }

.md-btn-filled {
  background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary);
}
.md-btn-filled:hover { box-shadow: var(--md-sys-elevation-1); filter: brightness(1.08); }

.md-btn-outlined {
  background: transparent; color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline);
}
.md-btn-outlined:hover { background: rgba(0,109,91,0.08); }

.md-btn-text {
  background: transparent; color: var(--md-sys-color-primary);
  padding: 0 12px;
}
.md-btn-text:hover { background: rgba(0,109,91,0.08); }

.md-btn-tonal {
  background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container);
}
.md-btn-tonal:hover { box-shadow: var(--md-sys-elevation-1); }

.md-btn-icon {
  width: 40px; height: 40px; padding: 0;
  background: transparent; color: var(--md-sys-color-on-surface-variant);
  border: none; border-radius: var(--md-sys-shape-full); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.md-btn-icon:hover { background: rgba(0,0,0,0.08); }

.md-btn-icon-filled {
  width: 40px; height: 40px; padding: 0;
  background: var(--md-sys-color-surface); color: var(--md-sys-color-on-surface);
  border: none; border-radius: var(--md-sys-shape-medium); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--md-sys-elevation-1);
  transition: all var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.md-btn-icon-filled:hover { box-shadow: var(--md-sys-elevation-2); }

.md-btn:disabled, .md-btn-icon:disabled {
  opacity: 0.38; cursor: not-allowed; pointer-events: none;
}

/* ─── FAB ─── */
.md-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 100;
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 20px;
  background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container);
  border: none; border-radius: var(--md-sys-shape-large); cursor: pointer;
  box-shadow: var(--md-sys-elevation-3);
  font-family: var(--md-sys-typescale-font-family-text);
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  transition: all var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized);
}
.md-fab:hover { box-shadow: var(--md-sys-elevation-4); }
.md-fab .material-symbols-outlined { font-size: 24px; }

/* ─── Cards ─── */
.md-card {
  border-radius: var(--md-sys-shape-medium); padding: 20px;
  transition: all var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.md-card-elevated {
  background: var(--md-sys-color-surface); box-shadow: var(--md-sys-elevation-1);
}
.md-card-elevated:hover { box-shadow: var(--md-sys-elevation-2); }
.md-card-filled {
  background: var(--md-sys-color-surface-container); box-shadow: none;
}
.md-card-outlined {
  background: var(--md-sys-color-surface); border: 1px solid var(--md-sys-color-outline-variant);
}

/* ─── Chips ─── */
.md-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 16px;
  border-radius: var(--md-sys-shape-small);
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  white-space: nowrap; cursor: pointer; border: none;
  transition: all var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.md-chip .material-symbols-outlined { font-size: 18px; }
.md-chip-filter {
  background: var(--md-sys-color-surface-container); color: var(--md-sys-color-on-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
}
.md-chip-filter.active, .md-chip-filter:hover {
  background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container);
  border-color: transparent;
}
.md-chip-status {
  cursor: default; height: 28px; padding: 0 12px;
  font-size: var(--md-sys-typescale-label-medium-size);
}

/* ─── TextField ─── */
.md-textfield {
  position: relative; width: 100%;
}
.md-textfield input, .md-textfield textarea, .md-textfield select {
  width: 100%; height: 56px; padding: 16px 16px 16px 48px;
  border: 1px solid var(--md-sys-color-outline); border-radius: var(--md-sys-shape-extra-small);
  background: transparent; color: var(--md-sys-color-on-surface);
  font-family: var(--md-sys-typescale-font-family-text);
  font-size: var(--md-sys-typescale-body-large-size);
  outline: none;
  transition: border-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.md-textfield textarea { height: auto; min-height: 80px; resize: vertical; }
.md-textfield select { cursor: pointer; appearance: none; }
.md-textfield input:focus, .md-textfield textarea:focus, .md-textfield select:focus {
  border-color: var(--md-sys-color-primary); border-width: 2px; padding: 15px 15px 15px 47px;
}
.md-textfield .tf-icon {
  position: absolute; left: 12px; top: 16px; color: var(--md-sys-color-on-surface-variant); pointer-events: none;
}
.md-textfield label {
  position: absolute; left: 48px; top: -8px; padding: 0 4px;
  background: var(--md-sys-color-surface); color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-body-small-size); font-weight: 500;
}

/* ─── Dialog ─── */
.md-dialog-scrim {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,0.32);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-standard);
}
.md-dialog-scrim.open { opacity: 1; pointer-events: auto; }
.md-dialog {
  background: var(--md-sys-color-surface); border-radius: var(--md-sys-shape-extra-large);
  box-shadow: var(--md-sys-elevation-3); padding: 24px;
  max-width: 640px; width: 90vw; max-height: 85vh; overflow-y: auto;
  transform: scale(0.9); transition: transform var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized-decelerate);
}
.md-dialog-scrim.open .md-dialog { transform: scale(1); }
.md-dialog-title { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.md-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; padding-top: 16px; }

/* ─── Data Table ─── */
.md-table { width: 100%; border-collapse: collapse; }
.md-table th {
  text-align: left; padding: 12px 16px;
  background: var(--md-sys-color-surface-container);
  font-size: var(--md-sys-typescale-label-large-size);
  font-weight: var(--md-sys-typescale-label-large-weight);
  color: var(--md-sys-color-on-surface-variant);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  white-space: nowrap; cursor: pointer; user-select: none;
}
.md-table th:hover { color: var(--md-sys-color-on-surface); }
.md-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--md-sys-color-outline-variant);
  font-size: var(--md-sys-typescale-body-medium-size);
  vertical-align: middle;
}
.md-table tr:nth-child(even) { background: var(--md-sys-color-surface-container-low); }
.md-table tr:hover { background: rgba(0,109,91,0.04); }

/* ─── Tabs ─── */
.md-tabs {
  display: flex; border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.md-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 16px;
  background: none; border: none; cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  font-size: var(--md-sys-typescale-title-small-size);
  font-weight: var(--md-sys-typescale-title-small-weight);
  position: relative;
  transition: color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.md-tab:hover { background: rgba(0,109,91,0.08); }
.md-tab.active {
  color: var(--md-sys-color-primary);
}
.md-tab.active::after {
  content: ''; position: absolute; bottom: 0; left: 20%; right: 20%;
  height: 3px; background: var(--md-sys-color-primary);
  border-radius: 3px 3px 0 0;
}
.md-tab .material-symbols-outlined { font-size: 20px; }

/* ─── Switch ─── */
.md-switch {
  position: relative; width: 52px; height: 32px; cursor: pointer;
}
.md-switch input { display: none; }
.md-switch .track {
  width: 100%; height: 100%; border-radius: var(--md-sys-shape-full);
  background: var(--md-sys-color-surface-container-highest);
  border: 2px solid var(--md-sys-color-outline);
  transition: all var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}
.md-switch .thumb {
  position: absolute; top: 8px; left: 6px; width: 16px; height: 16px;
  border-radius: var(--md-sys-shape-full); background: var(--md-sys-color-outline);
  transition: all var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-emphasized);
}
.md-switch input:checked ~ .track {
  background: var(--md-sys-color-primary); border-color: var(--md-sys-color-primary);
}
.md-switch input:checked ~ .thumb {
  left: 28px; width: 24px; height: 24px; top: 4px;
  background: var(--md-sys-color-on-primary);
}

/* ─── Snackbar ─── */
.md-snackbar {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px);
  z-index: 1000;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; min-width: 320px; max-width: 560px;
  background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface);
  border-radius: var(--md-sys-shape-small); box-shadow: var(--md-sys-elevation-3);
  font-size: var(--md-sys-typescale-body-medium-size);
  opacity: 0; transition: all var(--md-sys-motion-duration-medium2) var(--md-sys-motion-easing-emphasized);
}
.md-snackbar.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.md-snackbar .action {
  margin-left: auto; color: var(--md-sys-color-inverse-primary);
  background: none; border: none; cursor: pointer;
  font-weight: 500; font-size: var(--md-sys-typescale-label-large-size);
}

/* ─── Badge ─── */
.md-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--md-sys-color-error); color: var(--md-sys-color-on-error);
  border-radius: var(--md-sys-shape-full);
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

/* ─── Divider ─── */
.md-divider {
  width: 100%; height: 1px;
  background: var(--md-sys-color-outline-variant);
  margin: 8px 0;
}

/* ─── Progress ─── */
.md-progress {
  width: 100%; height: 4px; background: var(--md-sys-color-surface-container-highest);
  border-radius: 2px; overflow: hidden;
}
.md-progress-bar {
  height: 100%; background: var(--md-sys-color-primary);
  border-radius: 2px; transition: width var(--md-sys-motion-duration-medium4) var(--md-sys-motion-easing-standard);
}

/* ─── Tooltip ─── */
[data-tooltip], [data-tooltip-bottom] {
  position: relative;
}
[data-tooltip]::after, [data-tooltip-bottom]::after {
  padding: 6px 12px; background: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  border-radius: var(--md-sys-shape-extra-small);
  font-size: var(--md-sys-typescale-body-small-size);
  white-space: nowrap; pointer-events: none; opacity: 0;
  transition: opacity var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
  z-index: 500;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
}
[data-tooltip-bottom]::after {
  content: attr(data-tooltip-bottom);
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
}
[data-tooltip]:hover::after, [data-tooltip-bottom]:hover::after { opacity: 1; }

/* ─── Skeleton Loading ─── */
.md-skeleton {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-small);
  position: relative; overflow: hidden;
}
.md-skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* ─── Stepper ─── */
.md-stepper {
  display: flex; align-items: center; gap: 0; padding: 16px 0;
}
.md-step {
  display: flex; align-items: center; gap: 8px; flex: 1;
}
.md-step-circle {
  width: 32px; height: 32px; border-radius: var(--md-sys-shape-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
  background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface-variant);
  flex-shrink: 0;
}
.md-step.completed .md-step-circle { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.md-step.active .md-step-circle { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.md-step-label { font-size: var(--md-sys-typescale-label-medium-size); font-weight: 500; color: var(--md-sys-color-on-surface-variant); }
.md-step.active .md-step-label { color: var(--md-sys-color-on-surface); }
.md-step-connector { flex: 1; height: 1px; background: var(--md-sys-color-outline-variant); margin: 0 8px; }
.md-step.completed + .md-step-connector, .md-step.completed ~ .md-step-connector { background: var(--md-sys-color-primary); }

/* ─── Empty State ─── */
.md-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; text-align: center; gap: 12px;
}
.md-empty .material-symbols-outlined { font-size: 64px; color: var(--md-sys-color-on-surface-variant); opacity: 0.38; }
