
/*
  MedSave Frontend Forms / Modals / Tables Final UI Polish Pass
  Scope: safe, additive CSS only. Keeps existing Bootstrap/Vanilla JS architecture.
*/
:root {
  --ms-polish-radius-xs: 8px;
  --ms-polish-radius-sm: 10px;
  --ms-polish-radius-md: 14px;
  --ms-polish-radius-lg: 18px;
  --ms-polish-shadow-soft: 0 12px 34px rgba(15, 23, 42, 0.08);
  --ms-polish-shadow-card: 0 10px 26px rgba(15, 23, 42, 0.07);
  --ms-polish-border: rgba(124, 58, 237, 0.14);
  --ms-polish-border-neutral: rgba(148, 163, 184, 0.22);
  --ms-polish-surface: #ffffff;
  --ms-polish-surface-soft: #f8fafc;
  --ms-polish-surface-tint: #faf5ff;
  --ms-polish-text: #172033;
  --ms-polish-muted: #64748b;
  --ms-polish-primary: #7d1895;
  --ms-polish-primary-soft: rgba(125, 24, 149, 0.10);
  --ms-polish-danger-soft: rgba(220, 38, 38, 0.10);
  --ms-polish-success-soft: rgba(22, 163, 74, 0.10);
  --ms-polish-warning-soft: rgba(245, 158, 11, 0.12);
}

html.ms-forms-polished body {
  text-rendering: optimizeLegibility;
}

/* Form controls */
.ms-form-polished .form-control,
.ms-form-polished .form-select,
.ms-form-polished textarea,
.ms-form-polished input[type="text"],
.ms-form-polished input[type="email"],
.ms-form-polished input[type="number"],
.ms-form-polished input[type="password"],
.ms-form-polished input[type="search"],
.ms-form-polished input[type="date"],
.ms-form-polished input[type="datetime-local"],
body .form-control,
body .form-select {
  border-color: rgba(148, 163, 184, 0.38);
  border-radius: 12px;
  min-height: 40px;
  box-shadow: none;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}

body .form-control:focus,
body .form-select:focus,
body textarea:focus,
body input:focus {
  border-color: rgba(125, 24, 149, 0.65);
  box-shadow: 0 0 0 4px rgba(125, 24, 149, 0.12);
  outline: none;
}

body .form-label,
body label.form-label,
body .field-label {
  color: #334155;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: .35rem;
}

body .form-text,
body .help-text,
body .text-muted {
  color: var(--ms-polish-muted) !important;
}

.ms-field-row,
.form-row,
.form-grid {
  gap: 1rem;
}

.ms-required-mark,
.required-mark,
label.required::after {
  content: " *";
  color: #dc2626;
  font-weight: 800;
}

/* Buttons */
body .btn {
  border-radius: 11px;
  font-weight: 700;
  letter-spacing: -0.01em;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}

body .btn-primary {
  background: linear-gradient(135deg, #7d1895, #9d3eb5);
  border-color: transparent;
  box-shadow: 0 10px 20px rgba(125, 24, 149, 0.18);
}

body .btn-primary:hover,
body .btn-primary:focus {
  background: linear-gradient(135deg, #6f1585, #8f34a7);
  border-color: transparent;
}

body .btn-outline-primary {
  color: var(--ms-polish-primary);
  border-color: rgba(125, 24, 149, 0.35);
}

body .btn-outline-primary:hover,
body .btn-outline-primary:focus {
  background: var(--ms-polish-primary);
  border-color: var(--ms-polish-primary);
  color: #fff;
}

body .btn-light,
body .btn-outline-secondary {
  border-color: rgba(148, 163, 184, 0.32);
}

body .btn:disabled,
body .btn.disabled {
  cursor: not-allowed;
  opacity: .65;
}

/* Cards / panels */
body .card,
body .panel,
body .settings-card,
body .summary-card,
body .modal-card,
body .table-panel,
body .content-card {
  border-color: rgba(148, 163, 184, 0.18);
  border-radius: var(--ms-polish-radius-lg);
  box-shadow: var(--ms-polish-shadow-card);
}

body .card-header,
body .panel-header,
body .section-header {
  background: linear-gradient(180deg, rgba(250, 245, 255, .72), rgba(255,255,255,.92));
  border-bottom-color: rgba(148, 163, 184, 0.16);
}

/* Tables */
.ms-table-polished,
body .table {
  --bs-table-bg: transparent;
  vertical-align: middle;
}

.ms-table-polished thead th,
body .table thead th {
  background: #f8fafc;
  color: #475569;
  font-size: .78rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  font-weight: 800;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  white-space: nowrap;
}

.ms-table-polished tbody td,
body .table tbody td {
  border-color: rgba(148, 163, 184, 0.14);
}

body .table-hover tbody tr:hover,
.ms-table-polished tbody tr:hover {
  background: rgba(125, 24, 149, 0.035);
}

.table-responsive,
.ms-table-scroll {
  border-radius: 16px;
  scrollbar-width: thin;
}

.table-responsive::-webkit-scrollbar,
.ms-table-scroll::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}
.table-responsive::-webkit-scrollbar-thumb,
.ms-table-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.55);
  border-radius: 999px;
}

/* Modals */
body .modal-content {
  border: 0;
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.28);
  overflow: hidden;
}

body .modal-header {
  background: linear-gradient(135deg, #faf5ff, #ffffff);
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  padding: 1rem 1.15rem;
}

body .modal-title {
  color: #172033;
  font-weight: 800;
  letter-spacing: -0.02em;
}

body .modal-footer {
  background: #f8fafc;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  gap: .5rem;
}

body .modal-body {
  padding: 1.15rem;
}

/* Badges / chips */
body .badge,
.ms-chip,
.chip,
.status-badge,
.priority-badge {
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: -0.01em;
  padding: .38rem .62rem;
}

.ms-chip-soft {
  background: var(--ms-polish-primary-soft);
  color: var(--ms-polish-primary);
  border: 1px solid rgba(125, 24, 149, 0.18);
}

/* Loading / empty / error states */
.ms-state-card,
.empty-state,
.error-state,
.loading-state {
  border: 1px dashed rgba(148, 163, 184, 0.32);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  padding: 1.25rem;
  text-align: center;
}

.ms-state-card-title,
.empty-state h3,
.error-state h3 {
  color: #172033;
  font-weight: 800;
  margin-bottom: .35rem;
}

.ms-state-card-text,
.empty-state p,
.error-state p {
  color: var(--ms-polish-muted);
  margin-bottom: 0;
}

.ms-skeleton {
  position: relative;
  overflow: hidden;
  background: #e2e8f0;
  border-radius: 12px;
  min-height: 1rem;
}

.ms-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: msSkeleton 1.4s infinite;
}

@keyframes msSkeleton {
  100% { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .ms-skeleton::after,
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Toolbar/action groups */
.ms-action-bar,
.action-bar,
.toolbar,
.filter-bar,
.bulk-actions-bar {
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

/* Mobile */
@media (max-width: 768px) {
  body .modal-dialog {
    margin: .5rem;
  }
  body .modal-content {
    border-radius: 18px;
  }
  body .modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  body .modal-footer .btn {
    width: 100%;
  }
  body .btn,
  body .form-control,
  body .form-select {
    min-height: 44px;
  }
  .table-responsive {
    margin-inline: -.5rem;
    border-radius: 0;
  }
  .ms-action-bar,
  .action-bar,
  .toolbar,
  .filter-bar,
  .bulk-actions-bar {
    gap: .55rem;
    padding: .75rem;
  }
}
