/*
  app.css — shared UI: custom tooltips, loading overlay, ui-busy
  Ported from incident-status.firecrafting.net (PALACIOS_UPDATE_PLAN C.4, C.5)
*/

/* ═══════════════════════════════════════════════════
   CUSTOM TOOLTIPS [data-tooltip]
   ═══════════════════════════════════════════════════ */
[data-tooltip] {
  position: relative;
}
[data-tooltip]:not(.btn):not(.nav-link):not(.dropdown-item) {
  padding: 2px 0;
  margin: -2px 0;
}

.custom-tooltip {
  position: fixed;
  z-index: 1100;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.4;
  max-width: min(320px, calc(100vw - 2rem));
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.08);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
}
.custom-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ═══════════════════════════════════════════════════
   GLOBAL LOADING OVERLAY
   ═══════════════════════════════════════════════════ */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  backdrop-filter: blur(2px);
}
#loading-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.loading-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  min-width: 190px;
  text-align: center;
}

.loading-spinner {
  width: 38px;
  height: 38px;
  border: 3.5px solid color-mix(in srgb, var(--accent, #22c55e) 22%, transparent);
  border-top-color: var(--accent, #22c55e);
  border-radius: 50%;
  animation: app-spin 0.75s linear infinite;
  flex-shrink: 0;
}
@keyframes app-spin {
  to { transform: rotate(360deg); }
}

.loading-label {
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.88;
  letter-spacing: 0.01em;
  line-height: 1.3;
}
.loading-sublabel {
  font-size: 0.8rem;
  opacity: 0.5;
  margin-top: 0.15rem;
  line-height: 1.3;
}

/* Disabled state for buttons/inputs while loading */
body.ui-busy button,
body.ui-busy input[type="submit"],
body.ui-busy input[type="button"],
body.ui-busy select,
body.ui-busy textarea {
  pointer-events: none !important;
  opacity: 0.45 !important;
  cursor: not-allowed !important;
}
/* Keep the loading overlay itself interactive */
body.ui-busy #loading-overlay {
  pointer-events: all !important;
  opacity: 1 !important;
}

/* ═══════════════════════════════════════════════════
   C.6 MOBILE & PWA — touch targets, responsive tables/modals
   ═══════════════════════════════════════════════════ */
/* Touch targets ≥44px for primary interactive elements */
@media (pointer: coarse) {
  .btn,
  .navbar .nav-link,
  .dropdown-item,
  .form-control,
  .form-select,
  .language-selector select,
  .theme-tools button,
  .accent-option {
    min-height: 44px;
    min-width: 44px;
  }
  .btn { padding: 0.5rem 1rem; }
  .navbar .nav-link { padding: 0.5rem 0.75rem; display: inline-flex; align-items: center; }
  .language-selector select { padding: 0.5rem 0.75rem; }
}
/* Responsive tables: horizontal scroll on small viewports */
.table-responsive-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-responsive-wrapper table { margin-bottom: 0; }
/* Modals: max-height and scroll on small screens */
@media (max-width: 767px) {
  .modal-dialog { margin: 0.5rem; max-width: calc(100vw - 1rem); }
  .modal-content { max-height: calc(100vh - 1rem); overflow: auto; }
}
