:root {
  /* BSRU Suriya Purple & Medical Theme */
  --primary: #6b21a8;
  --primary-hover: #581c87;
  --primary-dark: #3b0764;
  --primary-light: #f3e8ff;
  --primary-glow: rgba(107, 33, 168, 0.15);
  
  --secondary: #7e22ce;
  --secondary-light: #faf5ff;
  
  --accent-red: #dc2626;
  --accent-red-light: #fee2e2;
  
  --accent-green: #059669;
  --accent-green-light: #d1fae5;
  
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 24px -4px rgba(88, 28, 135, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  --font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b0f19;
  --surface: #171e2e;
  --surface-alt: #101626;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --border: #283347;
  --primary: #c084fc;
  --primary-hover: #d8b4fe;
  --primary-dark: #a855f7;
  --primary-light: rgba(192, 132, 252, 0.18);
  --primary-glow: rgba(192, 132, 252, 0.25);
  --secondary: #d8b4fe;
  --secondary-light: rgba(216, 180, 254, 0.15);
  --accent-red: #f87171;
  --accent-red-light: rgba(248, 113, 113, 0.2);
  --accent-green: #34d399;
  --accent-green-light: rgba(52, 211, 153, 0.2);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* Modern Minimal Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.3);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #c084fc;
}

html {
  scroll-behavior: smooth;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  touch-action: manipulation;
}

/* Header & Navbar */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s ease, border-color 0.3s ease;
}

[data-theme="dark"] .site-header {
  background: rgba(23, 30, 46, 0.88);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-logo-img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(88, 28, 135, 0.2);
  border: 2px solid #ffffff;
  flex-shrink: 0;
  background: #ffffff;
}

[data-theme="dark"] .brand-logo-img {
  border-color: var(--primary);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-main);
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-admin {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: inherit;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-admin:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* Hero Section */
.hero {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2.25rem 1.25rem 1.75rem;
  text-align: center;
}

.hero-logo-wrap {
  display: inline-flex;
  margin-bottom: 1.25rem;
  position: relative;
}

.hero-logo-img {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-full);
  object-fit: cover;
  box-shadow: var(--shadow-lg);
  border: 3px solid var(--surface);
  background: #ffffff;
}

[data-theme="dark"] .hero-logo-img {
  border-color: var(--primary);
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.95rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

[data-theme="dark"] .hero-badge {
  color: #c084fc;
}

.hero-title {
  font-size: clamp(1.65rem, 4vw, 2.4rem);
  font-weight: 800;
  margin-bottom: 0.75rem;
  line-height: 1.3;
  background: linear-gradient(135deg, #581c87, #9333ea);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="dark"] .hero-title {
  background: linear-gradient(135deg, #c084fc, #e879f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  max-width: 700px;
  margin: 0 auto;
  color: var(--text-muted);
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  line-height: 1.6;
}

/* Main Content */
.main-content {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
  width: 100%;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.75rem;
}

/* App Card */
.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
}

.app-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-icon {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
  background: var(--surface-alt);
  box-shadow: var(--shadow-sm);
}

.card-header-info {
  flex: 1;
}

.card-badge-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.badge-tag {
  font-size: 0.725rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
}

.badge-tag.badge-new {
  background: #fef08a;
  color: #854d0e;
}

.badge-tag.badge-active {
  background: var(--accent-green-light);
  color: var(--accent-green);
}

.version-pill {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.35;
}

.card-desc {
  color: var(--text-muted);
  font-size: 0.925rem;
  margin-bottom: 1.5rem;
  flex: 1;
  line-height: 1.6;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
  margin-top: auto;
}

.card-actions .btn-launch {
  grid-column: span 2;
  font-size: 1rem;
  padding: 0.8rem 1rem;
}

.btn {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 12px rgba(107, 33, 168, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), var(--primary-dark));
  box-shadow: 0 6px 16px rgba(107, 33, 168, 0.35);
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-success {
  background: var(--accent-green);
  color: #ffffff;
  border: none;
}

.btn-success:hover {
  background: #047857;
}

/* Quick Installation Helper Section */
.quick-install-banner {
  margin-top: 3.5rem;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

[data-theme="dark"] .quick-install-banner {
  background: linear-gradient(135deg, #171e2e, #0f1422);
}

.banner-content h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

.banner-content p {
  font-size: 0.925rem;
  color: var(--text-muted);
}

.platform-badges {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.platform-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

/* Modal / Drawer */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background: var(--surface);
  width: 100%;
  max-width: 720px;
  height: 85vh;
  max-height: 85vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

/* High Contrast Information Banners & Cards */
.device-info-banner {
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.25rem;
}

[data-theme="dark"] .device-info-banner {
  background: rgba(192, 132, 252, 0.12);
  border-color: rgba(192, 132, 252, 0.35);
}

.device-info-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.device-info-badge {
  color: var(--primary);
  font-weight: 700;
}

[data-theme="dark"] .device-info-badge {
  color: #f0abfc;
}

.device-info-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.instruction-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
}

.instruction-title {
  font-size: 0.975rem;
  font-weight: 700;
  margin-bottom: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.instruction-text {
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.6;
}

.faq-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.faq-q {
  font-weight: 700;
  font-size: 0.925rem;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}

.faq-a {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.modal-backdrop.active .modal-container {
  transform: translateY(0) scale(1);
}

@keyframes modalShake {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.02); }
  50% { transform: scale(0.99); }
  75% { transform: scale(1.01); }
}

.modal-container.shake {
  animation: modalShake 0.28s ease-in-out;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-alt);
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-icon {
  font-size: 1.75rem;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.modal-close:hover {
  background: var(--border);
  color: var(--text-main);
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.modal-tabs::-webkit-scrollbar {
  display: none;
}

.modal-tab-btn {
  flex: 0 0 auto;
  padding: 0.55rem 0.95rem;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.modal-tab-btn:hover {
  color: var(--text-main);
  border-color: var(--border);
}

.modal-tab-btn.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 3px 8px rgba(107, 33, 168, 0.3);
  border-color: transparent;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Guide Steps */
.guide-step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.step-content h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text-main);
}

.step-content p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Changelog Items */
.changelog-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--surface-alt);
}

.changelog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.changelog-version {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.changelog-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.changelog-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
}

[data-theme="dark"] .changelog-section-title {
  color: #c084fc;
}

.changelog-list {
  padding-left: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.accomplishment-box {
  background: var(--accent-green-light);
  border-left: 4px solid var(--accent-green);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--text-main);
  margin-top: 0.5rem;
}

/* Admin Form Controls */
.form-group {
  margin-bottom: 1.15rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
  resize: vertical;
  min-height: 95px;
  line-height: 1.55;
  overflow-y: auto;
}

.form-help {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* User Pill Multi-Selector */
.user-pill-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.425rem 0.8rem;
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-pill input[type="checkbox"] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.user-pill:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.user-pill:has(input:checked) {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #ffffff;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(107, 33, 168, 0.25);
}

.admin-action-row {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--primary);
  color: #ffffff;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Footer */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 2.25rem 1.25rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.site-footer p {
  margin-bottom: 0.35rem;
}

/* Universal Cross-Device Responsiveness */
@media (max-width: 640px) {
  .header-container {
    padding: 0.65rem 1rem;
  }
  .brand-title {
    font-size: 0.95rem;
  }
  .hero {
    padding: 1.5rem 1rem;
  }
  .hero-logo-img {
    width: 80px;
    height: 80px;
  }
  .app-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .card-actions {
    grid-template-columns: 1fr;
  }
  .modal-tabs {
    padding: 0.5rem 0.75rem;
    gap: 0.4rem;
    justify-content: flex-start;
  }
  .modal-tab-btn {
    flex: 0 0 auto;
    font-size: 0.8125rem;
    padding: 0.45rem 0.85rem;
    flex-direction: row;
    gap: 0.35rem;
  }
  .modal-container {
    height: 85vh !important;
    max-height: 85vh !important;
    border-radius: var(--radius-lg);
  }
  /* Prevent iOS Safari input focus auto-zooming */
  .form-input, .form-select, .form-textarea {
    font-size: 16px !important;
  }
}
