/* ============================================================
 * v56b Polish layer — global UX improvements
 *
 * Targets:
 *   - Focus-visible rings (a11y)
 *   - Smooth scroll
 *   - Better text rendering
 *   - Consistent button/link states
 *   - Better selection color
 *   - Loading skeletons (utility class)
 *   - Subtle pulse animation for "live" badges
 *
 * Loaded LAST so it overrides where needed.
 * ============================================================ */

/* ---- Global text rendering ---- */
html { scroll-behavior: smooth; }
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ---- Selection color ---- */
::selection { background: rgba(255, 204, 0, 0.3); color: #fff; }

/* ---- Scrollbar (subtle, brand-aware) ---- */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 204, 0, 0.4); }

/* ---- Focus-visible rings (a11y win) ---- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid rgba(255, 204, 0, 0.7);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid rgba(255, 204, 0, 0.85);
  outline-offset: 2px;
}
.btn:focus-visible {
  outline: 2px solid rgba(255, 204, 0, 0.85);
  outline-offset: 3px;
  box-shadow: 0 8px 24px rgba(255, 204, 0, 0.35);
}

/* ---- Form fields polish ---- */
input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
input:not([type="checkbox"]):not([type="radio"]):focus,
textarea:focus,
select:focus {
  border-color: rgba(255, 204, 0, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 204, 0, 0.12);
}

/* ---- Empty state polish (dashboard panels) ---- */
.empty {
  animation: fade-up 0.4s ease backwards;
}
.empty .ic {
  background: linear-gradient(135deg, rgba(255, 204, 0, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 204, 0, 0.12);
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- KPI card polish ---- */
.kpi {
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 204, 0, 0.4), transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.kpi:hover::before { opacity: 1; }

/* ---- Status badges — subtle pulse for "live" ---- */
.status-live,
.status-pending {
  position: relative;
}
.status-live::after,
.status-pending::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
  animation: pulse-dot 1.6s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 0.4; transform: translateY(-50%) scale(0.9); }
  50%      { opacity: 1;   transform: translateY(-50%) scale(1.2); }
}

/* ---- Buttons: more refined hover ---- */
.btn {
  position: relative;
  overflow: hidden;
}
.btn-primary {
  background-image: linear-gradient(135deg, #ffcc00 0%, #ffd633 50%, #ffcc00 100%);
  background-size: 200% 100%;
  background-position: 0 0;
  transition: background-position 0.4s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.btn-primary:hover {
  background-position: 100% 0;
  box-shadow: 0 12px 32px rgba(255, 204, 0, 0.35);
}
.btn-ghost:hover {
  background: rgba(255, 204, 0, 0.06);
  border-color: rgba(255, 204, 0, 0.4);
  color: var(--brand);
}

/* ---- Links — consistent hover ---- */
a:not(.btn):not(.brand-mark):not([class*="card"]):not([class*="tile"]):hover {
  text-decoration: none;
}

/* ---- Tables: row hover ---- */
.tbl tbody tr {
  transition: background 0.12s ease;
}
.tbl tbody tr:hover {
  background: rgba(255, 204, 0, 0.025);
}

/* ---- Panel hover lift (subtle) ---- */
.panel {
  transition: border-color 0.15s ease, box-shadow 0.2s ease;
}

/* ---- Loading skeleton utility ---- */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
  color: transparent;
  pointer-events: none;
  user-select: none;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Welcome banner polish ---- */
.welcome-banner {
  position: relative;
  overflow: hidden;
}
.welcome-banner::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -10%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255, 204, 0, 0.08), transparent 70%);
  pointer-events: none;
}

/* ---- Mobile sidebar — better backdrop ---- */
@media (max-width: 900px) {
  .app-side[data-app-side].open ~ .app-main::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 80;
    animation: fade-in 0.2s ease;
  }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---- Mobile typography ---- */
@media (max-width: 540px) {
  .kpi .val { font-size: 1.4rem; }
  .panel-head { padding: 14px 16px; }
  .panel-body { padding: 16px; }
}

/* ---- Print friendly ---- */
@media print {
  .app-side, .app-topbar, .btn, button { display: none !important; }
  .app-main { padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
}

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

/* ---- Hide elements visually but keep for screen readers ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
