/* ==========================================================================
   Wall-Mounted Boiler Error Codes PWA - Stylesheet
   Modern, Mobile-First, Accessible, RTL Design System
   ========================================================================== */

:root {
  --primary: #1e293b;
  --primary-light: #334155;
  --primary-accent: #2563eb;
  --primary-accent-hover: #1d4ed8;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
  --accent-green: #10b981;
  --accent-blue: #3b82f6;

  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --badge-bg: #e2e8f0;
  --badge-text: #334155;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-main: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-alt: #334155;
    --border-color: #334155;
    --border-focus: #60a5fa;

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --badge-bg: #334155;
    --badge-text: #e2e8f0;
  }
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Tahoma, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  direction: rtl;
  text-align: right;
  font-size: 16px;
  line-height: 1.6;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  padding-bottom: 40px;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  width: 100%;
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-inverse);
  z-index: 100;
  box-shadow: var(--shadow-md);
  padding: 12px 16px;
}

.header-container {
  max-width: 650px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #ef4444, #f97316);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.header-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.header-counter {
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

/* Offline Banner */
.offline-banner {
  display: none;
  background-color: #d97706;
  color: white;
  text-align: center;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  width: 100%;
}

.offline-banner.active {
  display: block;
}

/* Main Container */
.main-container {
  width: 92%;
  max-width: 650px;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Search Box Area */
.search-wrapper {
  position: relative;
  width: 100%;
}

.search-input-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  right: 14px;
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  padding: 13px 44px 13px 40px;
  font-size: 0.98rem;
  font-family: inherit;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.clear-search-btn {
  position: absolute;
  left: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
}

.clear-search-btn:hover {
  background-color: var(--bg-surface-alt);
  color: var(--text-primary);
}

.clear-search-btn.visible {
  display: flex;
}

/* Filter Chips (Brands) */
.filter-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chips-scroll-container {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  -webkit-overflow-scrolling: touch;
}

.chips-scroll-container::-webkit-scrollbar {
  height: 4px;
}

.chips-scroll-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.chip-btn {
  white-space: nowrap;
  padding: 6px 13px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.chip-btn:hover {
  border-color: var(--primary-accent);
  color: var(--primary-accent);
}

.chip-btn.active {
  background-color: var(--primary-accent);
  color: #ffffff;
  border-color: var(--primary-accent);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

/* Results Status Bar */
.results-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.reset-filter-link {
  color: var(--primary-accent);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.reset-filter-link:hover {
  text-decoration: underline;
}

/* Error Card List */
.error-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.error-card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.error-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Severity Indicator Bar */
.error-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  height: 100%;
}

.error-card.severity-critical::before {
  background-color: var(--accent-red);
}

.error-card.severity-warning::before {
  background-color: var(--accent-amber);
}

.error-card.severity-info::before {
  background-color: var(--accent-blue);
}

/* Card Header */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-brand-model {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
}

.card-error-code {
  background-color: #fee2e2;
  color: #b91c1c;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #fca5a5;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .card-error-code {
    background-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.4);
  }
}

/* Card Body */
.card-section {
  margin-top: 8px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.section-label {
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.section-label.cause-label {
  color: #dc2626;
}

.section-label.solution-label {
  color: #059669;
}

@media (prefers-color-scheme: dark) {
  .section-label.cause-label {
    color: #f87171;
  }
  .section-label.solution-label {
    color: #34d399;
  }
}

.section-content {
  color: var(--text-secondary);
  white-space: pre-line;
  padding-right: 18px;
  font-size: 0.86rem;
}

/* Card Footer Actions */
.card-footer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.category-tag {
  font-size: 0.74rem;
  background-color: var(--badge-bg);
  color: var(--badge-text);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.copy-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition);
}

.copy-btn:hover {
  background-color: var(--bg-surface-alt);
  color: var(--primary-accent);
  border-color: var(--primary-accent);
}

.copy-btn.copied {
  background-color: #ecfdf5;
  color: #059669;
  border-color: #34d399;
}

/* Empty State */
.empty-state {
  display: none;
  text-align: center;
  padding: 40px 20px;
  background-color: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
}

.empty-state.visible {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-icon {
  font-size: 44px;
  margin-bottom: 12px;
  opacity: 0.7;
}

.empty-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 320px;
}

/* Skeleton Loading */
.skeleton-card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-line {
  height: 16px;
  background: linear-gradient(90deg, var(--bg-surface-alt) 25%, var(--border-color) 50%, var(--bg-surface-alt) 75%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s infinite;
  border-radius: 4px;
}

.skeleton-title { width: 50%; height: 20px; }
.skeleton-desc { width: 80%; }
.skeleton-sub { width: 95%; }

@keyframes skeletonPulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.95);
  color: #ffffff;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast-container.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* PWA Update Banner */
.update-toast {
  position: fixed;
  bottom: 20px;
  width: 90%;
  max-width: 450px;
  background-color: var(--primary);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: none;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
  animation: slideUp 0.3s ease;
}

.update-toast.visible {
  display: flex;
}

.update-btn {
  background-color: var(--primary-accent);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}

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

/* Search Match Highlight */
mark.search-highlight {
  background-color: #fef08a;
  color: #854d0e;
  padding: 0 2px;
  border-radius: 2px;
}

@media (prefers-color-scheme: dark) {
  mark.search-highlight {
    background-color: #854d0e;
    color: #fef08a;
  }
}
