/* ==========================================================================
   Wall-Mounted Boiler Error Codes PWA - Stylesheet
   Modern, Mobile-First, Accessible, RTL Design System
   Features: Voice Search, Bookmarks, Rich Diagnostics & Feedback Modal
   ========================================================================== */

: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;
  --accent-gold: #eab308;
  --accent-whatsapp: #25d366;

  --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: 20px;
}

/* 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: 10px 16px;
}

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

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

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

.header-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.header-subtitle {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-action-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  font-size: 15px;
}

.header-action-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.header-action-btn.active {
  background-color: var(--accent-gold);
  border-color: #ca8a04;
  color: #713f12;
}

.header-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: #ef4444;
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  border-radius: var(--radius-full);
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #1e293b;
}

.header-counter {
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 9px;
  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: 680px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 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 72px;
  font-size: 0.95rem;
  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);
}

/* Voice Search Button */
.voice-search-btn {
  position: absolute;
  left: 36px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

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

.voice-search-btn.listening {
  color: #ef4444;
  background-color: #fee2e2;
  animation: pulseMic 1.2s infinite;
}

@keyframes pulseMic {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.clear-search-btn {
  position: absolute;
  left: 8px;
  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;
}

/* Voice Active Indicator */
.voice-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  margin-top: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  animation: fadeIn 0.2s ease;
}

.voice-indicator.active {
  display: flex;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  background-color: #ef4444;
  border-radius: 50%;
  animation: dotPulse 1s infinite alternate;
}

@keyframes dotPulse {
  from { opacity: 0.4; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.2); }
}

/* 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);
}

.chip-btn.chip-favorites.active {
  background-color: #d97706;
  border-color: #b45309;
}

/* 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);
}

.meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-tag-badge {
  background-color: var(--primary-accent);
  color: white;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
}

.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.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.star-card-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 19px;
  color: #94a3b8;
  padding: 2px 4px;
  transition: var(--transition);
  border-radius: var(--radius-sm);
  line-height: 1;
}

.star-card-btn:hover {
  transform: scale(1.18);
  color: var(--accent-gold);
}

.star-card-btn.active {
  color: var(--accent-gold);
  text-shadow: 0 0 4px rgba(234, 179, 8, 0.4);
}

.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);
  font-size: 0.86rem;
}

/* Structured Step-by-Step Troubleshooting Checklist */
.solution-steps {
  list-style: none;
  padding-right: 0;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.solution-step-item {
  position: relative;
  padding-right: 24px;
  line-height: 1.6;
}

.solution-step-item::before {
  content: '▸';
  position: absolute;
  right: 6px;
  color: #059669;
  font-weight: bold;
}

/* Optional Component Badge Chips */
.component-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.component-chip {
  font-size: 0.72rem;
  background-color: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* 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: 36px 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;
  margin-bottom: 14px;
}

.empty-action-btn {
  background-color: var(--primary-accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  transition: var(--transition);
}

.empty-action-btn:hover {
  background-color: var(--primary-accent-hover);
}

/* Footer Links */
.app-footer {
  margin-top: 30px;
  text-align: center;
  padding: 16px 0;
  border-top: 1px solid var(--border-color);
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.footer-link-btn {
  background: none;
  border: none;
  color: var(--primary-accent);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.footer-link-btn:hover {
  text-decoration: underline;
}

.admin-link-btn {
  color: var(--text-muted);
}

.footer-sep {
  color: var(--border-color);
}

.footer-copy {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Feedback Modal Backdrop & Card */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-backdrop.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background-color: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  animation: slideUpModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpModal {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.flex-1 { flex: 1; }

.form-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

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

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.btn-primary {
  background-color: var(--primary-accent);
  color: white;
}

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

.btn-whatsapp {
  background-color: var(--accent-whatsapp);
  color: white;
}

.btn-whatsapp:hover {
  background-color: #20ba5a;
}

/* 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: 1100;
  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; }
}

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;
  }
}
