/*!
 * szlangini App Bridge v1.0.0
 * Maps common app-level CSS variables to szlangini design tokens
 * Import AFTER szlangini.css — gives all apps consistent values
 */

/* ═══════════════════════════════════════════════════════
   STANDARD APP VARIABLE ALIASES
   Apps use --bg, --accent, --text etc.
   This maps them all to the canonical --sz-* tokens.
   ═══════════════════════════════════════════════════════ */

:root {
  /* Background */
  --bg: var(--sz-bg-secondary);
  --card-bg: var(--sz-bg-primary);
  --card-background: var(--sz-bg-primary);
  --surface: var(--sz-bg-primary);

  /* Text */
  --text: var(--sz-text-primary);
  --text-primary: var(--sz-text-primary);
  --text-secondary: var(--sz-text-secondary);
  --text-muted: var(--sz-text-muted);
  --heading-color: var(--sz-text-primary);

  /* Accent */
  --accent: var(--sz-accent-blue);
  --accent-hover: #3b7ce8;
  --accent-light: rgba(79, 143, 247, 0.08);
  --accent-bg: rgba(79, 143, 247, 0.06);

  /* Borders */
  --border: var(--sz-border-default);
  --borders: var(--sz-border-default);
  --card-border: var(--sz-border-muted);
  --border-light: var(--sz-border-muted);

  /* Shadows */
  --shadow: var(--sz-shadow-sm);
  --shadow-sm: var(--sz-shadow-xs);
  --shadow-md: var(--sz-shadow-md);
  --shadow-lg: var(--sz-shadow-lg);

  /* Semantic Colors */
  --success: var(--sz-accent-green);
  --danger: var(--sz-accent-red);
  --warning: var(--sz-accent-orange);
  --info: var(--sz-accent-blue);
  --purple: var(--sz-accent-purple);

  /* Radius (consistent across all apps) */
  --radius: var(--sz-radius-md);
  --radius-sm: var(--sz-radius-sm);
  --radius-lg: var(--sz-radius-lg);
  --radius-pill: var(--sz-radius-pill);

  /* Typography (enforce consistency) */
  --font: var(--sz-font-family);
  --font-mono: var(--sz-font-mono);

  /* Transitions */
  --transition: var(--sz-transition-fast);
  --transition-normal: var(--sz-transition-normal);
}

/* ═══════════════════════════════════════════════════════
   APP SHELL RESET
   Ensures consistent base styling across all apps
   ═══════════════════════════════════════════════════════ */

body {
  font-family: var(--sz-font-family);
  background: var(--sz-bg-secondary);
  color: var(--sz-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════════════════
   CONSISTENT TOP BAR / HEADER
   ═══════════════════════════════════════════════════════ */

.top-bar, .app-header, .navbar {
  background: var(--sz-bg-primary);
  border-bottom: 1px solid var(--sz-border-muted);
  backdrop-filter: blur(12px);
}

/* ═══════════════════════════════════════════════════════
   CONSISTENT CARDS
   ═══════════════════════════════════════════════════════ */

.card {
  background: var(--sz-bg-primary);
  border: 1px solid var(--sz-border-muted);
  border-radius: var(--sz-radius-md);
  box-shadow: var(--sz-shadow-xs);
  transition: box-shadow var(--sz-transition-normal), border-color var(--sz-transition-normal);
}

.card:hover {
  box-shadow: var(--sz-shadow-sm);
}

/* ═══════════════════════════════════════════════════════
   CONSISTENT BUTTONS
   ═══════════════════════════════════════════════════════ */

.btn, button.primary, .btn-primary {
  font-family: var(--sz-font-family);
  font-weight: 500;
  border-radius: var(--sz-radius-sm);
  transition: all var(--sz-transition-fast);
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════
   CONSISTENT FORM ELEMENTS
   ═══════════════════════════════════════════════════════ */

input, select, textarea {
  font-family: var(--sz-font-family);
  border-radius: var(--sz-radius-sm);
  border: 1px solid var(--sz-border-default);
  transition: border-color var(--sz-transition-fast), box-shadow var(--sz-transition-fast);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sz-accent-blue);
  box-shadow: 0 0 0 3px rgba(79, 143, 247, 0.1);
}

/* ═══════════════════════════════════════════════════════
   BOTTOM NAVIGATION (Mobile)
   Consistent pattern for all apps with bottom nav
   ═══════════════════════════════════════════════════════ */

.bottom-nav, .bottom-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--sz-bg-primary);
  border-top: 1px solid var(--sz-border-muted);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Ensure content doesn't hide behind bottom nav */
body.has-bottom-nav {
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

/* ═══════════════════════════════════════════════════════
   MODAL OVERLAY (consistent across apps)
   ═══════════════════════════════════════════════════════ */

.modal-overlay, .overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content, .modal-panel {
  background: var(--sz-bg-primary);
  border-radius: var(--sz-radius-lg);
  box-shadow: var(--sz-shadow-xl);
  max-width: min(500px, 90vw);
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideUp 0.2s ease;
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════
   SCROLLBAR (consistent)
   ═══════════════════════════════════════════════════════ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--sz-border-default); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--sz-text-muted); }

/* ═══════════════════════════════════════════════════════
   RESPONSIVE HELPERS
   ═══════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  
  /* Ensure minimum touch targets on mobile (WCAG 2.5.5) */
  /* Only apply to primary action buttons, NOT small inline icons */
  .btn, [role="button"],
  select, input[type="checkbox"], input[type="radio"] {
    min-height: 44px;
  }
  
  /* Touch-friendly list items — only full-row clickables */
  li[onclick] {
    min-height: 44px;
  }
  
  /* Common interactive elements */
  a.sz-btn, button.sz-btn { min-height: 44px; }
  .sz-btn--icon { width: 44px; height: 44px; }
  .sz-btn--icon.sz-btn--sm { width: 44px; height: 44px; }
  .sz-tabs__button { min-height: 44px; padding: 12px 16px; }
  .sz-modal__close { min-width: 44px; min-height: 44px; }
  .sz-input, .sz-select, .sz-textarea { min-height: 44px; }
  
  /* Small inline buttons (±, ×, icon buttons) keep their natural size */
  /* They already have sufficient touch area via padding */
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}

/* ═══════════════════════════════════════════════════════
   PROGRESS BAR COLORS (semantic, consistent across apps)
   green = success/complete, blue = in-progress, orange = warning,
   red = danger/over-limit, purple = decorative/XP
   ═══════════════════════════════════════════════════════ */

.progress-bar, .sz-progress__bar, [class*="progress-fill"], [class*="bar-fill"] {
  transition: width 0.3s ease;
}

/* Semantic progress bar color classes */
.progress--success, .sz-progress__bar--success {
  background: var(--sz-accent-green) !important;
}
.progress--info, .sz-progress__bar--info {
  background: var(--sz-accent-blue) !important;
}
.progress--warning, .sz-progress__bar--warning {
  background: var(--sz-accent-orange) !important;
}
.progress--danger, .sz-progress__bar--danger {
  background: var(--sz-accent-red) !important;
}
.progress--decorative, .sz-progress__bar--decorative {
  background: var(--sz-accent-purple) !important;
}
/* Gradient decorative (for XP/RPG bars) */
.progress--xp {
  background: linear-gradient(90deg, var(--sz-accent-blue), var(--sz-accent-purple)) !important;
}

/* Track backgrounds (consistent) */
.progress-track, .sz-progress, [class*="bar-track"], [class*="progress-bg"] {
  background: var(--sz-bg-tertiary);
  border-radius: var(--sz-radius-full);
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════
   CARD STYLES (enforced consistency for all apps)
   Canonical: border=muted, shadow=xs, radius=md, padding=20px
   ═══════════════════════════════════════════════════════ */

.card, .sz-card, [class*="widget-card"], [class*="service-card"] {
  background: var(--sz-bg-primary);
  border: 1px solid var(--sz-border-muted);
  border-radius: var(--sz-radius-md);
  box-shadow: var(--sz-shadow-xs);
  transition: box-shadow var(--sz-transition-normal), border-color var(--sz-transition-normal);
}

.card:hover, .sz-card:hover {
  box-shadow: var(--sz-shadow-sm);
}

/* ═══════════════════════════════════════════════════════
   TYPOGRAPHY HIERARCHY (consistent across all apps)
   h1=32px/700, h2=24px/600, h3=20px/600, h4=16px/600
   ═══════════════════════════════════════════════════════ */

h1, .h1, .page-title {
  font-size: var(--sz-font-size-3xl);
  font-weight: 700;
  line-height: var(--sz-line-height-tight);
  color: var(--sz-text-primary);
}

h2, .h2, .section-title, .card-title-large {
  font-size: var(--sz-font-size-2xl);
  font-weight: 600;
  line-height: var(--sz-line-height-tight);
  color: var(--sz-text-primary);
}

h3, .h3, .card-title, .widget-title {
  font-size: var(--sz-font-size-xl);
  font-weight: 600;
  line-height: var(--sz-line-height-tight);
  color: var(--sz-text-primary);
}

h4, .h4, .subsection-title {
  font-size: var(--sz-font-size-lg);
  font-weight: 600;
  line-height: var(--sz-line-height-normal);
  color: var(--sz-text-primary);
}

/* ═══════════════════════════════════════════════════════
   EMPTY STATES (consistent)
   ═══════════════════════════════════════════════════════ */

.empty-state {
  text-align: center;
  padding: var(--sz-space-12) var(--sz-space-4);
  color: var(--sz-text-muted);
}

.empty-state .icon, .empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--sz-space-4);
  opacity: 0.5;
}
