/* Tawkeel Design Tokens & Bootstrap Overrides */

:root {
  --primary: #005126;
  --primary-container: #006c35;
  --primary-fixed: #9cf6b0;
  --primary-fixed-dim: #80d996;
  --on-primary: #ffffff;
  --on-primary-fixed: #00210c;
  --on-primary-fixed-variant: #005227;
  --secondary: #506356;
  --secondary-container: #d2e8d7;
  --secondary-fixed: #d2e8d7;
  --secondary-fixed-dim: #b7ccbc;
  --on-secondary: #ffffff;
  --on-secondary-container: #56695b;
  --on-secondary-fixed: #0d1f15;
  --on-secondary-fixed-variant: #384b3f;
  --tertiary: #735c00;
  --tertiary-container: #cca72f;
  --tertiary-fixed: #ffe088;
  --tertiary-fixed-dim: #e9c349;
  --on-tertiary: #ffffff;
  --on-tertiary-container: #4e3d00;
  --on-tertiary-fixed: #241a00;
  --on-tertiary-fixed-variant: #574500;
  --surface: #f8faf9;
  --surface-container: #eceeed;
  --surface-container-low: #f2f4f3;
  --surface-container-lowest: #ffffff;
  --surface-container-high: #e6e9e8;
  --surface-container-highest: #e1e3e2;
  --surface-variant: #e1e3e2;
  --surface-tint: #036d36;
  --surface-bright: #f8faf9;
  --surface-dim: #d8dad9;
  --on-surface: #191c1c;
  --on-surface-variant: #3f4940;
  --on-background: #191c1c;
  --background: #f8faf9;
  --outline: #6f7a6f;
  --outline-variant: #becabd;
  --inverse-surface: #2e3131;
  --inverse-primary: #80d996;
  --inverse-on-surface: #eff1f0;
  --error: #ba1a1a;
  --error-container: #ffdad6;
  --on-error: #ffffff;
  --on-error-container: #93000a;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  font-family: 'Cairo', sans-serif;
  background: var(--surface);
  color: var(--on-surface);
  margin: 0;
  padding: 0;
  min-height: max(884px, 100dvh);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .font-headline {
  font-family: 'Cairo', sans-serif;
}

.font-label {
  font-family: 'Cairo', sans-serif;
  font-weight: 500;
}

/* Mobile-first container */
.app-container {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
}

/* Screen management */
.app-screen {
  display: none;
}
.app-screen.active {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

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

/* Silk Gradient */
.silk-gradient {
  background: linear-gradient(135deg, #005126 0%, #006c35 100%);
}

/* Ambient Shadow */
.ambient-shadow {
  box-shadow: 0 20px 40px rgba(0, 82, 39, 0.06);
}

/* Small shadow */
.shadow-sm-green {
  box-shadow: 0 4px 20px rgba(0, 81, 38, 0.03);
}

/* Glass Navigation */
.glass-nav {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.glass-header {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Color utility classes */
.bg-primary { background-color: var(--primary) !important; }
.bg-primary-container { background-color: var(--primary-container) !important; }
.bg-primary-fixed { background-color: var(--primary-fixed) !important; }
.bg-primary-fixed-dim { background-color: var(--primary-fixed-dim) !important; }
.bg-secondary { background-color: var(--secondary) !important; }
.bg-secondary-container { background-color: var(--secondary-container) !important; }
.bg-tertiary { background-color: var(--tertiary) !important; }
.bg-tertiary-container { background-color: var(--tertiary-container) !important; }
.bg-tertiary-fixed { background-color: var(--tertiary-fixed) !important; }
.bg-surface { background-color: var(--surface) !important; }
.bg-surface-container { background-color: var(--surface-container) !important; }
.bg-surface-container-low { background-color: var(--surface-container-low) !important; }
.bg-surface-container-lowest { background-color: var(--surface-container-lowest) !important; }
.bg-surface-container-high { background-color: var(--surface-container-high) !important; }
.bg-surface-container-highest { background-color: var(--surface-container-highest) !important; }
.bg-surface-variant { background-color: var(--surface-variant) !important; }
.bg-error { background-color: var(--error) !important; }
.bg-error-container { background-color: var(--error-container) !important; }
.bg-emerald-50 { background-color: rgba(0, 81, 38, 0.05) !important; }
.bg-emerald-100 { background-color: rgba(0, 81, 38, 0.1) !important; }
.bg-amber-50 { background-color: rgba(255, 183, 0, 0.05) !important; }
.bg-white { background-color: #ffffff !important; }

.text-primary { color: var(--primary) !important; }
.text-on-primary { color: var(--on-primary) !important; }
.text-on-surface { color: var(--on-surface) !important; }
.text-on-surface-variant { color: var(--on-surface-variant) !important; }
.text-on-secondary { color: var(--on-secondary) !important; }
.text-on-secondary-container { color: var(--on-secondary-container) !important; }
.text-on-tertiary { color: var(--on-tertiary) !important; }
.text-on-tertiary-container { color: var(--on-tertiary-container) !important; }
.text-on-tertiary-fixed { color: var(--on-tertiary-fixed) !important; }
.text-outline { color: var(--outline) !important; }
.text-outline-variant { color: var(--outline-variant) !important; }
.text-error { color: var(--error) !important; }
.text-error-container { color: var(--on-error-container) !important; }
.text-secondary { color: var(--secondary) !important; }
.text-tertiary { color: var(--tertiary) !important; }
.text-white { color: #ffffff !important; }
.text-emerald-50 { color: rgba(0, 81, 38, 0.05) !important; }
.text-emerald-100 { color: rgba(0, 81, 38, 0.1) !important; }
.text-emerald-200 { color: rgba(0, 81, 38, 0.2) !important; }
.text-emerald-600 { color: #00a854 !important; }
.text-emerald-700 { color: #008f48 !important; }
.text-emerald-800 { color: #006c35 !important; }
.text-emerald-900 { color: #005126 !important; }
.text-slate-400 { color: #9ca3af !important; }
.text-slate-500 { color: #6b7280 !important; }
.text-zinc-400 { color: #a1a1aa !important; }
.text-zinc-500 { color: #71717a !important; }
.text-amber-600 { color: #d97706 !important; }
.text-amber-700 { color: #b45309 !important; }
.text-red-600 { color: #dc2626 !important; }

.border-primary { border-color: var(--primary) !important; }
.border-outline-variant { border-color: var(--outline-variant) !important; }
.border-surface-container { border-color: var(--surface-container) !important; }
.border-surface-container-lowest { border-color: var(--surface-container-lowest) !important; }
.border-emerald-50 { border-color: rgba(0, 81, 38, 0.05) !important; }
.border-emerald-100 { border-color: rgba(0, 81, 38, 0.1) !important; }
.border-secondary-container { border-color: var(--secondary-container) !important; }
.border-secondary-fixed { border-color: var(--secondary-fixed) !important; }
.border-white { border-color: #ffffff !important; }

.ring-primary { --tw-ring-color: var(--primary) !important; }

/* Border radius utilities */
.rounded-xl { border-radius: 0.75rem !important; }
.rounded-2xl { border-radius: 1rem !important; }
.rounded-3xl { border-radius: 1.5rem !important; }
.rounded-full { border-radius: 9999px !important; }
.rounded-lg { border-radius: 0.5rem !important; }
.rounded-md { border-radius: 0.375rem !important; }
.rounded { border-radius: 0.25rem !important; }
.rounded-t-2xl { border-radius: 1rem 1rem 0 0 !important; }
.rounded-t-3xl { border-radius: 1.5rem 1.5rem 0 0 !important; }
.rounded-t-xl { border-radius: 0.75rem 0.75rem 0 0 !important; }

/* Font size utilities */
.fs-display { font-size: 2.25rem; font-weight: 800; }
.fs-title { font-size: 1.875rem; font-weight: 800; }
.fs-headline-sm { font-size: 1.5rem; font-weight: 700; }
.fs-body-lg { font-size: 1.125rem; }
.fs-body { font-size: 1rem; }
.fs-sm { font-size: 0.875rem; }
.fs-xs { font-size: 0.75rem; }
.fs-xxs { font-size: 0.625rem; }

/* Font weight */
.fw-black { font-weight: 900; }
.fw-extrabold { font-weight: 800; }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.fw-medium { font-weight: 500; }
.fw-normal { font-weight: 400; }

/* Spacing */
.pt-24 { padding-top: 6rem; }
.pt-20 { padding-top: 5rem; }
.pb-32 { padding-bottom: 8rem; }
.pb-24 { padding-bottom: 6rem; }
.px-4 { padding-left: 0.8rem !important; padding-right: 0.8rem !important; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }

.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mb-10 { margin-bottom: 2.5rem; }
.mb-12 { margin-bottom: 3rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }
.mt-12 { margin-top: 3rem; }

.space-y-1 > * + * { margin-top: 0.25rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }
.space-y-8 > * + * { margin-top: 2rem; }
.space-y-12 > * + * { margin-top: 3rem; }

/* Flex utilities */
.d-flex { display: flex !important; }
.flex-column { flex-direction: column !important; }
.flex-row-reverse { flex-direction: row-reverse !important; }
.flex-wrap { flex-wrap: wrap !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-around { justify-content: space-around !important; }
.justify-content-end { justify-content: flex-end !important; }
.justify-content-start { justify-content: flex-start !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }

/* Grid */
.row { display: flex; flex-wrap: wrap; margin: -0.5rem; }
.row > * { padding: 0.5rem; }

/* Position */
.position-fixed { position: fixed !important; }
.position-sticky { position: sticky !important; }
.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.z-50 { z-index: 1050 !important; }
.z-40 { z-index: 1040 !important; }
.top-0 { top: 0 !important; }
.bottom-0 { bottom: 0 !important; }
.left-0 { left: 0 !important; }
.right-0 { right: 0 !important; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }

/* Width */
.w-100 { width: 100% !important; }
.w-auto { width: auto !important; }
.w-8 { width: 2rem !important; }
.w-10 { width: 2.5rem !important; }
.w-12 { width: 3rem !important; }
.w-14 { width: 3.5rem !important; }
.w-20 { width: 5rem !important; }
.w-24 { width: 6rem !important; }
.w-32 { width: 8rem !important; }

/* Height */
.h-auto { height: auto !important; }
.h-8 { height: 2rem !important; }
.h-10 { height: 2.5rem !important; }
.h-12 { height: 3rem !important; }
.h-14 { height: 3.5rem !important; }
.h-16 { height: 4rem !important; }
.h-20 { height: 5rem !important; }
.h-24 { height: 6rem !important; }
.h-32 { height: 8rem !important; }
.h-44 { height: 11rem !important; }
.h-64 { height: 16rem !important; }
.min-vh-100 { min-height: 100vh !important; }

/* Overflow */
.overflow-hidden { overflow: hidden !important; }
.overflow-x-hidden { overflow-x: hidden !important; }

/* Text */
.text-center { text-align: center !important; }
.text-start { text-align: right !important; }
.text-end { text-align: left !important; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-decoration-none { text-decoration: none !important; }
.tracking-tight { letter-spacing: -0.025em; }
.tracking-wide { letter-spacing: 0.025em; }
.tracking-widest { letter-spacing: 0.1em; }
.line-height-1 { line-height: 1; }
.line-height-relaxed { line-height: 1.625; }

/* Display */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline-block { display: inline-block !important; }

/* Border */
.border-0 { border: 0 !important; }
.border { border: 1px solid var(--outline-variant) !important; }
.border-top { border-top: 1px solid rgba(0, 81, 38, 0.05) !important; }
.border-start-4 { border-right: 4px solid !important; }
.border-end-4 { border-left: 4px solid !important; }

/* Cursor */
.cursor-pointer { cursor: pointer !important; }

/* Global button pointer — Bootstrap doesn't set cursor:pointer on buttons */
button,
.btn-active {
  cursor: pointer !important;
}

/* Pointer events */
.pointer-events-none { pointer-events: none !important; }

/* Transition */
.transition-all { transition: all 0.2s ease !important; }
.transition-colors { transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease !important; }
.transition-transform { transition: transform 0.15s ease !important; }
.transition-shadow { transition: box-shadow 0.3s ease !important; }

/* Active scale */
.btn-active:active { transform: scale(0.95) !important; }

/* Screen content padding for fixed bars */
.screen-content {
  padding-top: 72px;
  padding-bottom: 80px;
}

/* Top App Bar */
.top-app-bar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  z-index: 1050;
  background: rgba(248, 250, 249, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 1px 3px rgba(0, 82, 39, 0.06);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  z-index: 1050;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 -8px 24px rgba(0, 82, 39, 0.06);
  border-top: 1px solid rgba(0, 81, 38, 0.05);
  border-radius: 1rem 1rem 0 0;
}

/* Shared bottom nav visibility toggle */
#shared-bottom-nav {
  display: none;
}
#shared-bottom-nav.visible {
  display: block;
}

/* Nav item */
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.75rem;
  color: #9ca3af;
  text-decoration: none;
  transition: all 0.15s ease;
  border-radius: 0.5rem;
  min-width: 44px;
  min-height: 44px;
}
.nav-item:hover {
  color: #008f48;
}
.nav-item:active {
  transform: scale(0.9);
}
.nav-item.active {
  color: var(--primary);
  background: rgba(0, 81, 38, 0.05);
  font-weight: 700;
}

/* Icon styling */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  display: inline-block;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  word-wrap: normal;
  white-space: nowrap;
  direction: ltr;
  vertical-align: middle;
}
.material-symbols-outlined.filled {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Input styles */
.form-control-custom {
  width: 100%;
  background: var(--surface-container-low);
  border: none;
  border-radius: 0.75rem;
  padding: 1rem 1rem 1rem 5rem;
  font-size: 1rem;
  font-family: 'Cairo', sans-serif;
  color: var(--on-surface);
  transition: all 0.2s ease;
}
.form-control-custom:focus {
  outline: none;
  background: var(--surface-container-lowest);
  box-shadow: 0 0 0 2px rgba(0, 81, 38, 0.2);
}
.form-control-custom::placeholder {
  color: var(--on-surface-variant);
  opacity: 0.6;
}

/* Button styles */
.btn-primary-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, #005126 0%, #006c35 100%);
  color: #ffffff;
  border: none;
  border-radius: 0.75rem;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 81, 38, 0.2);
}
.btn-primary-custom:hover { opacity: 0.95; }
.btn-primary-custom:active { transform: scale(0.98); }

.btn-secondary-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
  border: none;
  border-radius: 0.5rem;
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-secondary-custom:hover { background: var(--surface-variant); }
.btn-secondary-custom:active { transform: scale(0.95); }

/* Card styles */
.card-custom {
  background: var(--surface-container-lowest);
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: 0 20px 40px rgba(0, 82, 39, 0.06);
}

.card-tonal {
  background: var(--surface-container-low);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

/* Status badge */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 700;
}
.badge-active {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}
.badge-error {
  background: var(--error-container);
  color: var(--on-error-container);
}
.badge-success {
  background: rgba(0, 81, 38, 0.05);
  color: #008f48;
}
.badge-pending {
  background: var(--surface-container);
  color: var(--on-surface-variant);
}
.badge-warning {
  background: rgba(255, 183, 0, 0.05);
  color: #b45309;
}

/* Pulse animation */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.animate-pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

/* Image utilities */
.object-cover { object-fit: cover !important; }
.object-contain { object-fit: contain !important; }

/* Ring */
.ring {
  box-shadow: 0 0 0 2px var(--primary-fixed);
}
.ring-2 {
  box-shadow: 0 0 0 2px currentColor;
}

/* Screen transitions */
.screen-slide-in {
  animation: slideIn 0.2s ease-out;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 430px) {
  .app-container {
    max-width: 100%;
  }
  .top-app-bar, .bottom-nav {
    max-width: 100%;
  }
}

/* Splash Screen Redesign */
.splash-bg {
  background: linear-gradient(160deg, #003d1b 0%, #005126 50%, #006c35 100%) !important;
}

.splash-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 22rem;
  margin: 0 auto;
  padding: 1.125rem 2rem;
  background: linear-gradient(135deg, #005126 0%, #006c35 100%);
  color: #ffffff;
  border: none;
  border-radius: 1rem;
  font-weight: 700;
  font-size: 1.125rem;
  font-family: 'Cairo', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 8px 24px rgba(0, 81, 38, 0.3), 0 2px 8px rgba(0, 81, 38, 0.15);
  text-decoration: none;
}
.splash-cta:hover {
  box-shadow: 0 12px 32px rgba(0, 81, 38, 0.4), 0 4px 12px rgba(0, 81, 38, 0.2);
  transform: translateY(-2px);
  opacity: 0.95;
}
.splash-cta:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 4px 12px rgba(0, 81, 38, 0.2);
}

@keyframes logoPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(156, 246, 176, 0.4);
  }
  50% {
    transform: scale(1.03);
    box-shadow: 0 0 0 16px rgba(156, 246, 176, 0);
  }
}

.splash-logo-ring {
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%) rotate(45deg); }
  100% { transform: translateX(200%) rotate(45deg); }
}

.splash-shimmer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}
.splash-shimmer::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 40%,
    rgba(255, 255, 255, 0.03) 50%,
    transparent 60%
  );
  animation: shimmer 8s ease-in-out infinite;
}

/* Arabic geometric pattern */
.geometric-pattern {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='white' stroke-width='0.5'%3E%3Cpath d='M40 0L80 40L40 80L0 40Z'/%3E%3Cpath d='M40 10L70 40L40 70L10 40Z'/%3E%3Cpath d='M40 20L60 40L40 60L20 40Z'/%3E%3Ccircle cx='40' cy='40' r='8'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 80px 80px;
}

/* ==================== CHAT SYSTEM — COMPLETE REDESIGN ==================== */

/* Chat Window — Full Viewport Overlay */
#screen-chat-window.app-screen.active {
  display: flex !important;
}

.chat-window-screen {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  flex-direction: column;
  z-index: 1060;
  background: var(--surface);
}

/* Chat header */
.chat-header {
  flex-shrink: 0;
  width: 100%;
  background: rgba(248, 250, 249, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 1px 3px rgba(0, 82, 39, 0.06);
  z-index: 10;
}

/* Chat background pattern (WhatsApp-style) */
.chat-bg-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.03;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23005126' stroke-width='0.5'%3E%3Cpath d='M30 0L60 30L30 60L0 30Z'/%3E%3Ccircle cx='30' cy='30' r='5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 60px 60px;
}

/* Chat messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  padding: 1rem;
  min-height: 0;
  position: relative;
}

/* Message bubbles — Rounded Modern */
.chat-bubble {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 0.875rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: bubbleIn 0.2s ease-out;
  position: relative;
}

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

/* Receiver bubble (other person, appears on right in RTL) */
.chat-bubble-receiver {
  background: var(--surface-container-lowest);
  color: var(--on-surface);
  border-radius: 0.875rem 0.125rem 0.875rem 0.875rem;
  margin-left: auto;
  margin-right: 0;
  box-shadow: 0 1px 2px rgba(0, 82, 39, 0.04);
}

/* Sender bubble (me, appears on left in RTL) */
.chat-bubble-sender {
  background: linear-gradient(135deg, #005126, #006c35);
  color: #fff;
  border-radius: 0.125rem 0.875rem 0.875rem 0.875rem;
  margin-right: auto;
  margin-left: 0;
  box-shadow: 0 1px 2px rgba(0, 82, 39, 0.04);
}

/* Bubble message text */
.chat-bubble p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Bubble footer (timestamp + status) */
.chat-bubble-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  margin-top: 0.375rem;
}

.chat-bubble-receiver .chat-bubble-footer {
  justify-content: flex-start;
}

.chat-bubble-time {
  font-size: 0.625rem;
  opacity: 0.6;
}

.chat-bubble-status {
  font-size: 0.75rem;
  opacity: 0.7;
}

.chat-bubble-sender .chat-bubble-time,
.chat-bubble-sender .chat-bubble-status {
  opacity: 0.7;
}

.chat-bubble-status.read {
  color: #53bdeb;
  opacity: 1;
}

/* Chat message wrapper */
.chat-message-row {
  display: flex;
  margin-bottom: 0.25rem;
}

.chat-message-row:last-child {
  margin-bottom: 0;
}

/* Date divider */
.chat-date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1.5rem 0;
  position: sticky;
  top: 0;
  z-index: 5;
}

.chat-date-divider span {
  background: var(--surface-container-low);
  color: var(--on-surface-variant);
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  max-width: 80%;
}

.typing-dots {
  display: flex;
  gap: 3px;
  background: var(--surface-container-lowest);
  padding: 0.625rem 0.875rem;
  border-radius: 0.875rem 0.125rem 0.875rem 0.875rem;
  box-shadow: 0 1px 2px rgba(0, 82, 39, 0.04);
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.4;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.chat-typing-label {
  font-size: 0.625rem;
  color: var(--on-surface-variant);
}

/* Quick replies */
.chat-quick-replies {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  scrollbar-width: none;
}

.chat-quick-replies::-webkit-scrollbar { display: none; }

.quick-reply-btn {
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  border: 1px solid var(--outline-variant);
  background: var(--surface-container-lowest);
  color: var(--on-surface);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'Cairo', sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quick-reply-btn:hover {
  background: var(--surface-container-low);
  border-color: var(--primary);
  color: var(--primary);
}

.quick-reply-btn:active {
  transform: scale(0.95);
}

/* Voice message */
.voice-message {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 12rem;
}

.voice-play-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 1.5rem;
  flex: 1;
}

.voice-bar {
  width: 3px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.5;
}

.voice-duration {
  font-size: 0.625rem;
  opacity: 0.7;
  flex-shrink: 0;
}

/* File attachment */
.file-attachment {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
}

.chat-bubble-receiver .file-attachment {
  background: var(--surface-container-low);
}

.file-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-icon.pdf {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.file-icon.image {
  background: rgba(0, 128, 0, 0.1);
  color: #008f48;
}

.file-icon.doc {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 0.625rem;
  opacity: 0.6;
}

/* Image preview */
.image-preview {
  border-radius: 0.5rem;
  overflow: hidden;
  margin: 0.5rem 0;
  cursor: pointer;
}

.image-preview img {
  width: 100%;
  max-width: 12rem;
  display: block;
  border-radius: 0.5rem;
}

/* Chat input bar */
.chat-input-bar {
  flex-shrink: 0;
  width: 100%;
  z-index: 10;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 0.625rem 0.75rem;
  padding-bottom: max(0.625rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--surface-container);
}

.chat-input-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface-container-low);
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  min-height: 2.5rem;
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  font-family: 'Cairo', sans-serif;
  color: var(--on-surface);
  outline: none;
  padding: 0.375rem 0;
}

.chat-input::placeholder {
  color: var(--on-surface-variant);
  opacity: 0.6;
}

.chat-input-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.chat-attach-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.chat-attach-btn:hover {
  background: var(--surface-container);
}

.chat-voice-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-send-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #005126, #006c35);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* ==================== CHAT LIST RICH CARDS ==================== */

/* Chat list search bar */
.chat-search {
  position: relative;
}

.chat-search-input {
  width: 100%;
  background: var(--surface-container-low);
  border: none;
  border-radius: 9999px;
  padding: 0.75rem 3rem 0.75rem 1rem;
  font-size: 0.875rem;
  font-family: 'Cairo', sans-serif;
  color: var(--on-surface);
}

.chat-search-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 81, 38, 0.15);
}

.chat-search-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--outline);
  font-size: 1.25rem;
}

/* Chat list filter tabs */
.chat-filter-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.25rem 0;
  margin-bottom: 0.75rem;
  scrollbar-width: none;
}

.chat-filter-tabs::-webkit-scrollbar { display: none; }

.chat-filter-tab {
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  border: 1px solid var(--outline-variant);
  background: var(--surface-container-lowest);
  color: var(--on-surface-variant);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'Cairo', sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-filter-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.chat-filter-tab:hover:not(.active) {
  background: var(--surface-container-low);
}

/* Chat card (rich) */
.chat-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem;
  border-radius: 0.75rem;
  margin-bottom: 0.375rem;
  background: var(--surface-container-lowest);
  transition: all 0.15s ease;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.chat-card:hover {
  background: var(--surface-container-low);
}

.chat-card:active {
  transform: scale(0.98);
}

/* Active/online chat card */
.chat-card-active {
  background: rgba(0, 108, 53, 0.08);
}

/* Unread chat card */
.chat-card-unread .chat-card-name {
  font-weight: 800;
}

.chat-card-unread .chat-card-preview {
  font-weight: 600;
  color: var(--on-surface);
}

/* Chat card avatar */
.chat-card-avatar {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
}

.chat-card-avatar img,
.chat-card-avatar .avatar-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

/* Online indicator */
.chat-online-dot {
  position: absolute;
  bottom: 0.125rem;
  left: 0.125rem;
  width: 0.75rem;
  height: 0.75rem;
  background: #00c853;
  border-radius: 50%;
  border: 2px solid var(--surface-container-lowest);
}

.chat-card-active .chat-online-dot {
  border-color: rgba(0, 108, 53, 0.08);
}

@keyframes onlinePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 200, 83, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(0, 200, 83, 0); }
}

.chat-online-dot.pulse {
  animation: onlinePulse 2s ease-in-out infinite;
}

/* Chat card content */
.chat-card-content {
  flex: 1;
  min-width: 0;
}

.chat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.chat-card-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--on-surface);
}

.chat-card-time {
  font-size: 0.625rem;
  color: var(--on-surface-variant);
  flex-shrink: 0;
}

.chat-card-active .chat-card-time {
  color: var(--primary);
  font-weight: 700;
}

.chat-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-card-preview {
  font-size: 0.75rem;
  color: var(--on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-card-badge {
  min-width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

.chat-card-badge-primary {
  background: var(--primary);
}

.chat-card-badge-error {
  background: var(--error);
}

/* Chat card status icons */
.chat-card-status {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

.chat-card-status .material-symbols-outlined {
  font-size: 1rem;
}

.chat-card-status.read {
  color: var(--primary);
}

.chat-card-status.sent {
  color: var(--on-surface-variant);
}

/* Service type badge on chat card */
.chat-card-service {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
  background: rgba(0, 81, 38, 0.05);
  color: var(--primary);
  margin-top: 0.25rem;
}

/* Verified badge */
.chat-card-verified {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
}

.chat-card-verified .material-symbols-outlined {
  font-size: 0.875rem;
  color: var(--primary);
}

/* Unread indicator bar */
.chat-card-unread-bar {
  width: 0.25rem;
  height: 0.25rem;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 0.5rem;
}

/* Archive button */
.chat-archive-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem;
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'Cairo', sans-serif;
  cursor: pointer;
  border-radius: 0.75rem;
  transition: all 0.2s ease;
}

.chat-archive-btn:hover {
  background: rgba(0, 81, 38, 0.05);
}

/* Empty state */
.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
}

.chat-empty-icon {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background: var(--surface-container-low);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.chat-empty-icon .material-symbols-outlined {
  font-size: 2rem;
  color: var(--on-surface-variant);
}

.chat-empty-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--on-surface);
  margin-bottom: 0.5rem;
}

.chat-empty-text {
  font-size: 0.75rem;
  color: var(--on-surface-variant);
  line-height: 1.5;
}


@media (min-width: 431px) {
  body {
    background: #e8ecea;
  }
  .top-app-bar, .bottom-nav {
    border-left: 1px solid rgba(0, 81, 38, 0.05);
    border-right: 1px solid rgba(0, 81, 38, 0.05);
  }
  .bottom-nav {
    box-shadow: 0 -8px 24px rgba(0, 82, 39, 0.06);
  }
  .chat-window-screen {
    border-left: 1px solid rgba(0, 81, 38, 0.05);
    border-right: 1px solid rgba(0, 81, 38, 0.05);
  }
}

/* ==================== PAGE TRANSITION LOADER ==================== */

#page-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 249, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

#page-loader.active {
  display: flex;
}

.loader-ring {
  position: relative;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  border: 3px solid var(--surface-container);
  border-top-color: var(--primary);
  border-right-color: var(--primary-container);
  animation: silkSpin 0.75s linear infinite;
  box-shadow: 0 0 24px rgba(0, 81, 38, 0.12),
              inset 0 0 16px rgba(0, 81, 38, 0.04);
}

.loader-ring::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: rgba(0, 81, 38, 0.18);
  animation: silkSpin 1.1s linear infinite reverse;
}

@keyframes silkSpin {
  to { transform: rotate(360deg); }
}

.loader-label {
  margin-top: 1rem;
  font-family: 'Cairo', sans-serif;
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.025em;
}
