/* CorePlexML SaaS Polish Layer
   Elevates the UI from internal-tool to SaaS-grade.
   Load AFTER ui-proposal.css.
*/

/* ============================================================================
   1. CARD HOVER EFFECTS — signals interactivity
   ============================================================================ */
.entity-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: default;
}

.entity-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(2, 6, 23, 0.12);
  border-color: var(--color-primary-500);
}

[data-theme="dark"] .entity-card:hover {
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  border-color: var(--color-primary-600);
}

/* Stats cards also get a subtle hover */
.stats-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stats-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(2, 6, 23, 0.1);
}

[data-theme="dark"] .stats-card:hover {
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
}

/* ============================================================================
   2. HIDE EMPTY DESCRIPTIONS — "No description available" is noise
   ============================================================================ */
.entity-card .card-desc:empty,
.entity-card .card-desc--empty {
  display: none !important;
}

/* ============================================================================
   3. ACTION ROW — more subtle, less cluttered
   ============================================================================ */
.action-row {
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.entity-card:hover .action-row {
  opacity: 1;
}

/* Action buttons smaller and tighter */
.action-row .btn-action {
  padding: 5px 12px;
  font-size: 0.82rem;
  border-radius: 10px;
}

/* Delete button red only on hover */
.action-row .btn-action .action-icon--red {
  color: var(--color-text-tertiary);
  transition: color 0.15s ease;
}

.action-row .btn-action:hover .action-icon--red {
  color: var(--danger-color);
}

/* ============================================================================
   4. FOOTER — minimal SaaS footer, not fixed
   ============================================================================ */
footer.footer.saas-footer {
  position: relative !important;
  background-color: transparent !important;
  border-top: 1px solid var(--color-border) !important;
  margin-top: 2rem;
  padding: 12px 0;
  font-size: 0.78rem;
  color: var(--color-text-tertiary) !important;
}

footer.footer.saas-footer a {
  color: var(--color-text-tertiary) !important;
}

footer.footer.saas-footer a:hover {
  color: var(--color-text-secondary) !important;
}

[data-theme="dark"] footer.footer.saas-footer {
  background-color: transparent !important;
}

/* ============================================================================
   5. PAGE HEADER — tighter vertical spacing
   ============================================================================ */
.page-header {
  padding: 14px 20px;
  margin-bottom: 18px;
}

.page-header div.page-title h1 {
  font-size: 1.4rem;
}

.page-subtitle {
  font-size: 0.88rem;
}

/* ============================================================================
   6. RELATIVE TIME BADGE — for recent items
   ============================================================================ */
.time-relative {
  color: var(--color-text-tertiary);
  font-size: 0.85rem;
}

.time-relative[title] {
  cursor: help;
  border-bottom: 1px dotted var(--color-border);
}

/* ============================================================================
   7. EMPTY STATE — for pages with no data
   ============================================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}

.empty-state__icon {
  font-size: 3rem;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state__title {
  font-size: 1.1rem;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.empty-state__desc {
  font-size: 0.9rem;
  color: var(--color-text-tertiary);
  max-width: 400px;
  margin-bottom: 20px;
}

.empty-state__cta {
  margin-top: 4px;
}

/* ============================================================================
   8. KPI COUNTER ANIMATION — subtle load effect
   ============================================================================ */
@keyframes countUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stats-card .counter,
.stat-card__value {
  animation: countUp 0.4s ease-out both;
}

.stats-card:nth-child(2) .counter,
.stat-card:nth-child(2) .stat-card__value { animation-delay: 0.05s; }
.stats-card:nth-child(3) .counter,
.stat-card:nth-child(3) .stat-card__value { animation-delay: 0.1s; }
.stats-card:nth-child(4) .counter,
.stat-card:nth-child(4) .stat-card__value { animation-delay: 0.15s; }
.stats-card:nth-child(5) .counter,
.stat-card:nth-child(5) .stat-card__value { animation-delay: 0.2s; }
.stats-card:nth-child(6) .counter,
.stat-card:nth-child(6) .stat-card__value { animation-delay: 0.25s; }
.stats-card:nth-child(7) .counter,
.stat-card:nth-child(7) .stat-card__value { animation-delay: 0.3s; }
.stats-card:nth-child(8) .counter,
.stat-card:nth-child(8) .stat-card__value { animation-delay: 0.35s; }

/* ============================================================================
   9. TABLE IMPROVEMENTS — cleaner SaaS tables
   ============================================================================ */
.table {
  font-size: 0.9rem;
}

.table th {
  font-size: 0.8rem;
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-tertiary);
  border-bottom-width: 2px;
}

.table td {
  vertical-align: middle;
}

/* UUID columns — monospace and muted */
.table .cell-uuid {
  font-family: var(--font-family-mono);
  font-size: 0.78rem;
  color: var(--color-text-tertiary);
}

/* ============================================================================
   10. SCROLLBAR — slim SaaS style
   ============================================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border-dark);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--color-border);
}

/* ============================================================================
   11. FILTER BAR — more polished look
   ============================================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  margin-bottom: 18px;
}

.filter-bar .btn {
  font-size: 0.85rem;
}

.filter-bar .form-control {
  font-size: 0.85rem;
  max-width: 220px;
}

/* ============================================================================
   12. SIDEBAR SECTION DIVIDERS
   ============================================================================ */
.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 8px 16px;
}

.sidebar-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.3);
  padding: 12px 16px 4px;
  font-weight: var(--font-weight-medium);
}

/* ============================================================================
   13. LOADING SKELETON — for async content
   ============================================================================ */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-background-secondary) 25%,
    var(--color-background-tertiary) 50%,
    var(--color-background-secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 80%;
}

.skeleton-title {
  height: 20px;
  margin-bottom: 12px;
  width: 60%;
}

.skeleton-card {
  height: 180px;
  border-radius: 16px;
}

/* ============================================================================
   14. TOOLTIP OVERRIDE — cleaner tooltips
   ============================================================================ */
.tooltip-inner {
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 8px;
  max-width: 280px;
}

/* ============================================================================
   15. BREADCRUMB — contextual navigation
   ============================================================================ */
.breadcrumb-saas {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--color-text-tertiary);
  margin-bottom: 4px;
}

.breadcrumb-saas a {
  color: var(--color-text-tertiary);
  text-decoration: none;
}

.breadcrumb-saas a:hover {
  color: var(--color-primary-600);
}

.breadcrumb-saas .separator {
  color: var(--color-text-muted);
}

/* ============================================================================
   16. NOTIFICATION DOT — sidebar badge
   ============================================================================ */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: var(--font-weight-semibold);
  background: var(--danger-color);
  color: #fff;
  margin-left: auto;
}

/* ============================================================================
   17. GETTING STARTED PANEL — cleaner onboarding
   ============================================================================ */
#gettingStartedPanel {
  border-radius: 16px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.06);
}

[data-theme="dark"] #gettingStartedPanel {
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
}

/* ============================================================================
   18. FOCUS RING — accessible, branded
   ============================================================================ */
:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
  border-radius: 4px;
}

.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.25);
}

/* ============================================================================
   19. COMMAND PALETTE (Ctrl+K) — global search overlay
   ============================================================================ */
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  padding-top: 15vh;
}

.cmd-palette {
  width: 560px;
  max-width: 95vw;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  max-height: 460px;
  display: flex;
  flex-direction: column;
}

[data-theme="dark"] .cmd-palette {
  background: var(--color-surface, #1e1e2e);
  border-color: var(--color-border, #374151);
}

.cmd-palette-input-wrap {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
  gap: 10px;
}

.cmd-palette-icon {
  color: var(--color-text-muted, #94a3b8);
  font-size: 1rem;
}

.cmd-palette-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  color: var(--color-text-primary, #1e293b);
  font-family: inherit;
}

.cmd-palette-input::placeholder {
  color: var(--color-text-muted, #94a3b8);
}

.cmd-palette-kbd {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--color-background-secondary, #f1f5f9);
  border: 1px solid var(--color-border, #e2e8f0);
  color: var(--color-text-tertiary, #64748b);
  font-family: var(--font-family-mono, monospace);
}

.cmd-palette-results {
  overflow-y: auto;
  max-height: 360px;
  padding: 8px;
}

.cmd-palette-empty {
  padding: 24px 16px;
  text-align: center;
}

.cmd-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--color-text-secondary, #475569);
  background: var(--color-background-secondary, #f1f5f9);
  text-decoration: none;
  transition: all 0.15s;
}

.cmd-shortcut:hover {
  background: var(--color-primary-50, #eff6ff);
  color: var(--color-primary-600, #4f7cff);
}

.cmd-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text-primary, #1e293b);
  transition: background 0.1s;
}

.cmd-result:hover,
.cmd-result.active {
  background: var(--color-primary-50, #eff6ff);
  color: var(--color-primary-700, #3b5bdb);
}

[data-theme="dark"] .cmd-result:hover,
[data-theme="dark"] .cmd-result.active {
  background: rgba(79, 124, 255, 0.15);
}

.cmd-result-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-background-secondary, #f1f5f9);
  color: var(--color-text-tertiary, #64748b);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.cmd-result-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.cmd-result-type {
  font-size: 0.75rem;
  color: var(--color-text-muted, #94a3b8);
  text-transform: capitalize;
}

.cmd-result-enter {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--color-text-muted, #94a3b8);
  opacity: 0;
  transition: opacity 0.1s;
}

.cmd-result:hover .cmd-result-enter,
.cmd-result.active .cmd-result-enter {
  opacity: 1;
}

/* ============================================================================
   20. TOAST NOTIFICATIONS — lightweight, non-blocking
   ============================================================================ */
.saas-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 280px;
  max-width: 400px;
  animation: toastIn 0.3s ease-out;
  margin-top: 8px;
}

[data-theme="dark"] .saas-toast {
  background: var(--color-surface, #1e1e2e);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.saas-toast--success { border-left: 3px solid #10b981; }
.saas-toast--error { border-left: 3px solid #ef4444; }
.saas-toast--warning { border-left: 3px solid #f59e0b; }
.saas-toast--info { border-left: 3px solid #3b82f6; }

.saas-toast-icon {
  font-size: 1rem;
  margin-top: 2px;
}

.saas-toast--success .saas-toast-icon { color: #10b981; }
.saas-toast--error .saas-toast-icon { color: #ef4444; }
.saas-toast--warning .saas-toast-icon { color: #f59e0b; }
.saas-toast--info .saas-toast-icon { color: #3b82f6; }

.saas-toast-body {
  flex: 1;
}

.saas-toast-title {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.saas-toast-message {
  font-size: 0.82rem;
  color: var(--color-text-secondary, #475569);
}

.saas-toast-close {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-text-muted, #94a3b8);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

.saas-toast-close:hover {
  color: var(--color-text-primary, #1e293b);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}

/* ============================================================================
   21. KEYBOARD SHORTCUT HINT — shown in sidebar/navbar
   ============================================================================ */
.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.kbd-hint kbd {
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.4);
  font-family: var(--font-family-mono, monospace);
  line-height: 1.4;
}

/* ============================================================================
   22. USER AVATAR — initials circle
   ============================================================================ */
.user-avatar-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary-500, #4f7cff), var(--color-primary-700, #3b5bdb));
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

/* ============================================================================
   23. HELP WIDGET — floating bottom-right
   ============================================================================ */
.help-widget-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1050;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-primary-600, #4f7cff);
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(79, 124, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.help-widget-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(79, 124, 255, 0.5);
}

.help-widget-panel {
  position: fixed;
  bottom: 80px;
  right: 24px;
  z-index: 1050;
  width: 280px;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

[data-theme="dark"] .help-widget-panel {
  background: var(--color-surface, #1e1e2e);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.help-widget-panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.help-widget-panel-body {
  padding: 8px;
}

.help-widget-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--color-text-primary, #1e293b);
  font-size: 0.85rem;
  transition: background 0.1s;
  cursor: pointer;
}

.help-widget-item:hover {
  background: var(--color-background-secondary, #f1f5f9);
  color: var(--color-primary-600, #4f7cff);
}

.help-widget-item i {
  width: 20px;
  text-align: center;
  color: var(--color-text-tertiary, #64748b);
}

/* ============================================================================
   24. QUICK ACTION CARDS — dashboard shortcuts
   ============================================================================ */
.quick-action-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}

.quick-action-card:hover {
  transform: translateY(-1px);
  border-color: var(--color-primary-500, #4f7cff);
  box-shadow: 0 4px 12px rgba(79, 124, 255, 0.1);
}

.quick-action-card .card-body {
  color: var(--color-text-primary, #1e293b);
}

.quick-action-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ============================================================================
   25. ACTIVITY FEED — recent events timeline
   ============================================================================ */
.activity-feed .list-group-item {
  background: transparent;
  transition: background 0.1s;
}

.activity-feed .list-group-item:hover {
  background: var(--color-background-secondary, #f8fafc);
}

/* ============================================================================
   26. BREADCRUMBS — hierarchical navigation
   ============================================================================ */
.saas-breadcrumb {
  padding: 0.5rem 1.5rem;
  font-size: 0.8rem;
}
.saas-breadcrumb .breadcrumb {
  margin-bottom: 0;
  background: transparent;
  padding: 0;
}
.saas-breadcrumb .breadcrumb-item a {
  color: var(--accent-primary, #667eea);
  text-decoration: none;
}
.saas-breadcrumb .breadcrumb-item a:hover {
  text-decoration: underline;
}
.saas-breadcrumb .breadcrumb-item.active {
  color: var(--color-text-muted, #94a3b8);
}
.saas-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
  content: "\f054";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.55rem;
  vertical-align: middle;
  color: var(--color-text-muted, #94a3b8);
}

/* ============================================================================
   27. DANGER ZONE — account deletion and destructive actions
   ============================================================================ */
[data-theme="dark"] .profile-card[style*="border: 1px solid #dc3545"] .profile-card-header {
  background: rgba(220, 53, 69, 0.12) !important;
  border-bottom-color: rgba(220, 53, 69, 0.3) !important;
}

/* ============================================================================
   28. BACK TO TOP BUTTON — appears on scroll
   ============================================================================ */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-primary, #334155);
  background: var(--bg-card, #1e293b);
  color: var(--color-text-secondary, #94a3b8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, transform 0.2s;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}
.back-to-top:hover {
  transform: translateY(-3px);
  color: var(--accent-primary, #667eea);
  border-color: var(--accent-primary, #667eea);
}

/* ============================================================================
   29. SMOOTH SCROLL — global smooth scrolling
   ============================================================================ */
html { scroll-behavior: smooth; }

/* ============================================================================
   30. TABLE ENHANCEMENTS — hover highlight and sortable headers
   ============================================================================ */
.table-saas thead th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.table-saas thead th:hover {
  color: var(--accent-primary, #667eea);
}
.table-saas thead th .sort-icon {
  font-size: 0.65rem;
  margin-left: 0.25rem;
  opacity: 0.3;
}
.table-saas thead th.sorted .sort-icon {
  opacity: 1;
  color: var(--accent-primary, #667eea);
}
