/*
 * modern.css — Responsive design system overlay
 * AUDIT-MODERNIZED: 2026-04-18
 * Loaded after style.css; enhances (does not replace) existing UI.
 */

:root {
  --md-primary: #2563eb;
  --md-primary-hover: #1d4ed8;
  --md-success: #16a34a;
  --md-warning: #ea580c;
  --md-danger:  #dc2626;
  --md-sp-1: .25rem; --md-sp-2: .5rem;  --md-sp-3: .75rem;
  --md-sp-4: 1rem;   --md-sp-6: 1.5rem; --md-sp-8: 2rem;
  --md-radius-sm: 6px; --md-radius-md: 10px; --md-radius-lg: 16px;
  --md-shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --md-shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --md-ease: cubic-bezier(.4,0,.2,1);
  --md-dur: 200ms;
}

/* --- Base responsive safety nets --- */
html { -webkit-text-size-adjust: 100%; }
img, video, iframe, table { max-width: 100%; }
:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 2px; }

/* --- Touch targets on mobile --- */
@media (max-width: 767px) {
  button, .btn, a.btn, input[type="submit"], input[type="button"] {
    min-height: 44px;
    padding-inline: clamp(.75rem, 3vw, 1rem);
  }
  input, select, textarea { font-size: 16px; /* prevent iOS zoom */ }
}

/* --- Responsive tables → card stack on mobile --- */
@media (max-width: 640px) {
  .table-responsive,
  .data-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table.stack-on-mobile thead { display: none; }
  table.stack-on-mobile, table.stack-on-mobile tbody,
  table.stack-on-mobile tr, table.stack-on-mobile td { display: block; width: 100%; }
  table.stack-on-mobile tr {
    margin-bottom: var(--md-sp-4);
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: var(--md-radius-md);
    padding: var(--md-sp-3);
    background: var(--bg-card, var(--surface, #fff));
    box-shadow: var(--md-shadow-sm);
  }
  table.stack-on-mobile td {
    border: 0;
    padding: var(--md-sp-2) 0;
    display: flex;
    justify-content: space-between;
    gap: var(--md-sp-3);
  }
  table.stack-on-mobile td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary, #64748b);
  }
}

/* --- Mobile navigation ergonomics --- */
@media (max-width: 767px) {
  .top-bar {
    flex-wrap: wrap;
    gap: var(--md-sp-2);
    padding: var(--md-sp-2) var(--md-sp-3) !important;
  }
  .top-bar .global-search,
  .top-bar .breadcrumb { display: none; }
  .user-details { display: none !important; }
  .main-content { padding: var(--md-sp-3) !important; }
}

/* --- Cards / surfaces --- */
.md-card {
  background: var(--bg-card, var(--surface, #fff));
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: var(--md-radius-md);
  padding: var(--md-sp-6);
  box-shadow: var(--md-shadow-sm);
  transition: box-shadow var(--md-dur) var(--md-ease), transform var(--md-dur) var(--md-ease);
}
.md-card:hover { box-shadow: var(--md-shadow-md); }

/* --- Button polish (non-invasive, only if `.btn` exists) --- */
.btn {
  transition: background var(--md-dur) var(--md-ease),
              transform var(--md-dur) var(--md-ease),
              box-shadow var(--md-dur) var(--md-ease);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--md-shadow-sm); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* --- Forms --- */
input.md-input, select.md-select, textarea.md-textarea {
  width: 100%;
  padding: var(--md-sp-3) var(--md-sp-4);
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: var(--md-radius-sm);
  background: var(--bg, #fff);
  color: var(--text, #0f172a);
  transition: border-color var(--md-dur) var(--md-ease), box-shadow var(--md-dur) var(--md-ease);
}
input.md-input:focus, select.md-select:focus, textarea.md-textarea:focus {
  outline: none;
  border-color: var(--md-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

/* --- Toast notifications --- */
.md-toast-container {
  position: fixed; top: 1rem; right: 1rem;
  display: flex; flex-direction: column; gap: .5rem;
  z-index: 10000; max-width: calc(100vw - 2rem); pointer-events: none;
}
.md-toast {
  pointer-events: auto;
  padding: .75rem 1rem;
  border-radius: var(--md-radius-md);
  background: var(--bg-card, #fff);
  border-left: 4px solid var(--md-primary);
  box-shadow: var(--md-shadow-md);
  font-size: .9rem;
  min-width: 240px; max-width: 380px;
  animation: md-toast-in .3s var(--md-ease);
}
.md-toast.success { border-left-color: var(--md-success); }
.md-toast.warning { border-left-color: var(--md-warning); }
.md-toast.error   { border-left-color: var(--md-danger); }
.md-toast.leaving { animation: md-toast-out .25s var(--md-ease) forwards; }
@keyframes md-toast-in  { from { opacity:0; transform:translateX(20px);} to {opacity:1; transform:none;} }
@keyframes md-toast-out { to   { opacity:0; transform:translateX(20px);} }

/* --- Skeleton shimmer --- */
.md-skeleton {
  background: linear-gradient(90deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%);
  background-size: 200% 100%;
  animation: md-shimmer 1.2s infinite;
  border-radius: var(--md-radius-sm);
  color: transparent;
}
@keyframes md-shimmer { 0%{background-position:200% 0;} 100%{background-position:-200% 0;} }

/* --- Empty state --- */
.md-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--md-sp-3); padding: var(--md-sp-8);
  color: var(--text-secondary, #64748b); text-align: center;
}
.md-empty .icon { font-size: 2.5rem; opacity: .45; }

/* --- Utility classes --- */
.u-flex { display: flex; }
.u-flex-col { flex-direction: column; }
.u-items-center { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-gap-2 { gap: var(--md-sp-2); } .u-gap-3 { gap: var(--md-sp-3); } .u-gap-4 { gap: var(--md-sp-4); }
.u-hidden { display: none !important; }
@media (max-width: 767px) { .u-hide-mobile { display: none !important; } }
@media (min-width: 768px) { .u-hide-desktop { display: none !important; } }

/* --- Motion-safe --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* --- Dark mode micro-tweaks --- */
@media (prefers-color-scheme: dark) {
  .md-skeleton { background: linear-gradient(90deg,#1e293b 0%,#334155 50%,#1e293b 100%); }
}
