:root {
  /* ALZAWIA brand palette — gold primary, navy secondary (alzawia.net) */
  --background: 40 25% 98%;
  --foreground: 210 29% 24%;
  --card: 0 0% 100%;
  --card-foreground: 210 29% 24%;
  --popover: 0 0% 100%;
  --popover-foreground: 210 29% 24%;
  /* #A4906F */
  --primary: 37 23% 54%;
  --primary-foreground: 0 0% 100%;
  /* Soft warm surfaces; brand navy available as --brand-navy */
  --secondary: 40 14% 94%;
  --secondary-foreground: 210 29% 24%;
  --muted: 40 12% 95%;
  --muted-foreground: 210 16% 42%;
  --accent: 37 28% 92%;
  --accent-foreground: 239 38% 30%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 100%;
  --border: 40 12% 88%;
  --input: 40 12% 88%;
  --ring: 37 23% 54%;
  /* #2F3068 */
  --brand-navy: 239 38% 30%;
  --radius: 0.5rem;

  /* Light elevation shadows */
  --shadow-xs: 0 1px 2px hsl(210 29% 24% / 0.04);
  --shadow-sm: 0 1px 3px hsl(210 29% 24% / 0.06), 0 1px 2px hsl(210 29% 24% / 0.04);
  --shadow-md: 0 4px 12px hsl(210 29% 24% / 0.06), 0 2px 4px hsl(210 29% 24% / 0.04);
  --shadow-lg: 0 8px 24px hsl(210 29% 24% / 0.07), 0 4px 8px hsl(210 29% 24% / 0.04);
  --shadow-border: 0 0 0 1px hsl(var(--border) / 0.65), var(--shadow-sm);
  --wa-dialog-z: 9999;
}

.dark {
  /* Chat / WhatsApp-style dark surfaces (#0b141a, #111b21, #202c33, #2a3942) */
  --background: 205 41% 7%;
  --foreground: 200 12% 92%;
  --card: 203 32% 10%;
  --card-foreground: 200 12% 92%;
  --popover: 203 32% 10%;
  --popover-foreground: 200 12% 92%;
  /* Brand gold — slightly brighter for dark contrast */
  --primary: 37 32% 62%;
  --primary-foreground: 0 0% 100%;
  --secondary: 202 23% 16%;
  --secondary-foreground: 200 12% 92%;
  --muted: 202 23% 16%;
  --muted-foreground: 202 12% 58%;
  --accent: 203 22% 21%;
  --accent-foreground: 37 32% 72%;
  --destructive: 0 62% 42%;
  --destructive-foreground: 200 12% 92%;
  --border: 203 22% 21%;
  --input: 203 22% 21%;
  --ring: 37 32% 62%;
  --brand-navy: 203 28% 28%;

  --shadow-xs: none;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-lg: none;
  --shadow-border: none;
  --borderColor: rgba(255, 255, 255, 0.1);
}

html {
  direction: rtl;
  color-scheme: light;
}

html.dark {
  color-scheme: dark;
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: 'Segoe UI', 'Tahoma', 'Geneva', 'Verdana', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Light theme: warm gold ambient wash (ALZAWIA) */
html:not(.dark) body {
  background-image: radial-gradient(
    ellipse 100% 60% at 50% -10%,
    hsl(37 35% 90% / 0.55),
    transparent 55%
  );
}

/* Light theme: soft shadows on bordered surfaces */
html:not(.dark) .bg-card.border,
html:not(.dark) aside.bg-card,
html:not(.dark) section.bg-card {
  border-color: hsl(var(--border) / 0.7) !important;
  box-shadow: var(--shadow-sm);
}

html:not(.dark) .rounded-2xl.border,
html:not(.dark) .rounded-xl.border {
  box-shadow: var(--shadow-md);
}

html:not(.dark) header.border-b,
html:not(.dark) .border-b {
  border-bottom-color: hsl(var(--border) / 0.65) !important;
}

html:not(.dark) header.sticky,
html:not(.dark) header.shrink-0 {
  box-shadow: var(--shadow-xs);
}

html:not(.dark) input,
html:not(.dark) textarea,
html:not(.dark) select {
  border-color: hsl(var(--border) / 0.75) !important;
  box-shadow: var(--shadow-xs);
  background-color: hsl(0 0% 100%);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

html:not(.dark) input:focus,
html:not(.dark) textarea:focus,
html:not(.dark) select:focus {
  outline: none;
  border-color: hsl(var(--ring) / 0.45) !important;
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12), var(--shadow-xs);
}

html:not(.dark) button.border,
html:not(.dark) .border.rounded-lg {
  box-shadow: var(--shadow-xs);
}

html:not(.dark) .divide-y > :not([hidden]) ~ :not([hidden]) {
  border-color: hsl(var(--border) / 0.55);
}

html:not(.dark) .hover\:bg-muted:hover {
  box-shadow: inset 0 0 0 1px hsl(var(--border) / 0.4);
}

/* Dark theme: chat-style surfaces (inputs, cards, sidebar) */
.dark body {
  background-color: hsl(var(--background));
  background-image: none;
}

.dark aside#sidebar.bg-card,
.dark .bg-card {
  background-color: hsl(var(--card));
}

.dark input,
.dark textarea,
.dark select {
  background-color: hsl(var(--input));
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: hsl(var(--foreground));
}

.dark input:focus,
.dark textarea:focus,
.dark select:focus {
  outline: none;
  border-color: hsl(var(--ring) / 0.55) !important;
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}

.dark .hover\:bg-muted:hover {
  background-color: hsl(var(--muted));
}

.dark header.border-b,
.dark .border-b {
  border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}

.dark .border,
.dark .border-t,
.dark .border-b,
.dark .border-l,
.dark .border-r,
.dark .border-s,
.dark .border-e,
.dark .border-x,
.dark .border-y,
.dark .divide-y > :not([hidden]) ~ :not([hidden]),
.dark .border-border,
.dark aside#sidebar,
.dark .bg-card.border,
.dark section.border,
.dark .rounded-2xl.border,
.dark .rounded-xl.border,
.dark .rounded-lg.border,
.dark input,
.dark textarea,
.dark select {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

.dark ::-webkit-scrollbar-track {
  background: hsl(var(--background));
}

.dark ::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.28);
}

/* Token utility classes (to keep the existing design classes working) */
.bg-background {
  background-color: hsl(var(--background));
}

.text-foreground {
  color: hsl(var(--foreground));
}

.bg-card {
  background-color: hsl(var(--card));
}

.text-card-foreground {
  color: hsl(var(--card-foreground));
}

.bg-muted {
  background-color: hsl(var(--muted));
}

.text-muted-foreground {
  color: hsl(var(--muted-foreground));
}

.bg-primary {
  background-color: hsl(var(--primary));
}

.text-primary {
  color: hsl(var(--primary));
}

.text-primary-foreground {
  color: hsl(var(--primary-foreground));
}

.bg-secondary {
  background-color: hsl(var(--secondary));
}

.border-border {
  border-color: hsl(var(--border));
}

.dark .border-border {
  border-color: rgba(255, 255, 255, 0.1);
}

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

.shadow-elevated {
  box-shadow: var(--shadow-md);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: hsl(var(--muted));
}

::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.5);
}

html:not(.dark) ::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.22);
}

/* Animations from original app */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}

.animate-slide-in {
  animation: slideIn 0.3s ease-out forwards;
}

/* Status indicators */
.status-online {
  background-color: #22c55e;
  box-shadow: 0 0 0 2px hsl(var(--background));
}

.status-offline {
  background-color: #ef4444;
  box-shadow: 0 0 0 2px hsl(var(--background));
}

.status-warning {
  background-color: #f59e0b;
  box-shadow: 0 0 0 2px hsl(var(--background));
}

/* Themed dialogs (waAlert / waConfirm / waPrompt) */
.wa-dialog-root {
  position: fixed;
  inset: 0;
  z-index: var(--wa-dialog-z, 9999);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.wa-dialog-root--open {
  pointer-events: auto;
  opacity: 1;
}

.wa-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: hsl(222 47% 11% / 0.45);
  backdrop-filter: blur(4px);
}

.dark .wa-dialog-backdrop {
  background: hsl(222 20% 4% / 0.65);
}

.wa-dialog-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 26rem;
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border) / 0.75);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.2s ease;
}

.dark .wa-dialog-panel {
  border-color: rgba(255, 255, 255, 0.1);
}

.wa-dialog-root--open .wa-dialog-panel {
  transform: translateY(0) scale(1);
}

.wa-dialog-header {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  margin-bottom: 0.75rem;
}

.wa-dialog-icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wa-dialog-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.wa-dialog-icon--info {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}

.wa-dialog-icon--success {
  background: hsl(142 70% 38% / 0.12);
  color: hsl(142 70% 38%);
}

.wa-dialog-icon--warning {
  background: hsl(38 92% 50% / 0.14);
  color: hsl(32 95% 44%);
}

.wa-dialog-icon--error {
  background: hsl(var(--destructive) / 0.12);
  color: hsl(var(--destructive));
}

.wa-dialog-icon--confirm {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}

.wa-dialog-title-wrap {
  flex: 1;
  min-width: 0;
  padding-top: 0.125rem;
}

.wa-dialog-title {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
}

.wa-dialog-message {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: hsl(var(--muted-foreground));
  white-space: pre-wrap;
  margin: 0 0 1rem;
}

.wa-dialog-message--indented {
  margin-right: 3.375rem;
}

.wa-dialog-field {
  margin-bottom: 1rem;
}

.wa-dialog-field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: hsl(var(--foreground));
}

.wa-dialog-input,
.wa-dialog-textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 0.9375rem;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dark .wa-dialog-input,
.dark .wa-dialog-textarea {
  border-color: rgba(255, 255, 255, 0.1);
}

.wa-dialog-input:focus,
.wa-dialog-textarea:focus {
  border-color: hsl(var(--ring) / 0.45);
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12), var(--shadow-xs);
}

.wa-dialog-textarea {
  min-height: 5rem;
  resize: vertical;
}

.wa-dialog-actions {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
}

.wa-dialog-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 5.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.wa-dialog-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.25);
}

.wa-dialog-btn--primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.wa-dialog-btn--primary:hover {
  opacity: 0.92;
}

.wa-dialog-btn--destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.wa-dialog-btn--destructive:hover {
  opacity: 0.92;
}

.wa-dialog-btn--ghost {
  background: transparent;
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}

.dark .wa-dialog-btn--ghost {
  border-color: rgba(255, 255, 255, 0.1);
}

.wa-dialog-btn--ghost:hover {
  background: hsl(var(--muted));
}

html.wa-dialog-open,
html.wa-dialog-open body {
  overflow: hidden;
}

.sidebar-group-label {
  letter-spacing: 0.04em;
}

/* Compact sidebar density */
#sidebar {
  width: 14.5rem; /* slightly narrower than w-64 */
}

#sidebar.w-64 {
  width: 14.5rem;
}

/* Collapsed rail — must beat the base #sidebar width rule */
#sidebar.w-20 {
  width: 4.5rem;
}

#sidebar > .p-4 {
  padding: 0.75rem 0.85rem;
}

#sidebar > .p-4 .w-10.h-10 {
  width: 2rem;
  height: 2rem;
}

#sidebar > .p-4 .w-10.h-10 i,
#sidebar > .p-4 .w-10.h-10 svg {
  width: 1rem;
  height: 1rem;
}

#sidebar #sidebarTitle {
  font-size: 0.95rem;
  line-height: 1.2;
}

#sidebar #sidebarNav {
  padding: 0.5rem 0.55rem;
}

#sidebar > .p-3.border-t {
  padding: 0.55rem 0.55rem;
}

#sidebar > .p-3.border-t button {
  padding: 0.4rem 0.55rem;
  gap: 0.5rem;
  border-radius: 0.375rem;
}

#sidebar > .p-3.border-t button .w-5,
#sidebar > .p-3.border-t button svg.w-5 {
  width: 1rem;
  height: 1rem;
}

#sidebar > .p-3.border-t .sidebar-label,
#sidebar > .p-3.border-t #themeLabel {
  font-size: 0.8125rem;
}

.sidebar-nav-link {
  min-height: 2rem;
}

.sidebar-nav-link i,
.sidebar-nav-link svg {
  width: 1rem;
  height: 1rem;
}

/* Collapsed: centered icon rail */
#sidebar.w-20 > .p-4 {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 0.35rem;
}

#sidebar.w-20 > .p-4 > .flex.items-center {
  justify-content: center;
  gap: 0;
}

#sidebar.w-20 > .p-4 .w-10.h-10 {
  width: 2.15rem;
  height: 2.15rem;
}

#sidebar.w-20 > .p-4 .w-10.h-10 i,
#sidebar.w-20 > .p-4 .w-10.h-10 svg {
  width: 1.1rem;
  height: 1.1rem;
}

#sidebar.w-20 #sidebarToggle {
  padding: 0.35rem;
}

#sidebar.w-20 #sidebarToggle i,
#sidebar.w-20 #sidebarToggle svg {
  width: 0.95rem;
  height: 0.95rem;
}

#sidebar.w-20 #sidebarNav {
  padding: 0.4rem 0.35rem;
}

#sidebar.w-20 .sidebar-nav-link {
  justify-content: center;
  padding: 0.55rem 0.35rem;
  gap: 0;
  min-height: 2.35rem;
}

#sidebar.w-20 .sidebar-nav-link i,
#sidebar.w-20 .sidebar-nav-link svg {
  width: 1.15rem;
  height: 1.15rem;
}

#sidebar.w-20 .sidebar-group-divider {
  margin-inline: 0.35rem;
}

#sidebar.w-20 > .p-3.border-t {
  padding: 0.45rem 0.35rem;
}

#sidebar.w-20 > .p-3.border-t button {
  justify-content: center;
  padding: 0.55rem 0.35rem;
  gap: 0;
}

#sidebar.w-20 > .p-3.border-t button .w-5,
#sidebar.w-20 > .p-3.border-t button svg.w-5,
#sidebar.w-20 > .p-3.border-t button i,
#sidebar.w-20 > .p-3.border-t button svg {
  width: 1.15rem;
  height: 1.15rem;
}

/* App sidebar: fixed full viewport height on desktop */
@media (min-width: 1024px) {
  #sidebar {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    z-index: 40;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  #sidebar #sidebarNav {
    min-height: 0;
  }

  /* Reserve space so main content is not under the fixed sidebar */
  .flex:has(> #sidebar.w-64),
  .flex:has(> #sidebar:not(.w-20)) {
    padding-inline-start: 14.5rem;
  }

  .flex:has(> #sidebar.w-20) {
    padding-inline-start: 4.5rem;
  }
}

/* Floating service alerts (complaint / booking / housekeeping) */
#waServiceAlertsHost {
  position: fixed !important;
  inset-inline-end: 1rem;
  bottom: 1rem;
  z-index: 2147483000 !important;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.65rem;
  width: min(22rem, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
  pointer-events: none;
  margin: 0;
  padding: 0;
}

.wa-service-alert {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  border-radius: 0.85rem;
  border: 1px solid hsl(var(--border));
  background: #ffffff;
  color: #1f2937;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transform: translateY(0);
  opacity: 1;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.dark .wa-service-alert {
  background: #1a2332;
  color: #e8eef5;
  border-color: rgba(255, 255, 255, 0.12);
}

.wa-service-alert.is-in {
  transform: translateY(0);
  opacity: 1;
}

.wa-service-alert.is-out {
  transform: translateY(8px);
  opacity: 0;
}

.wa-service-alert__icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wa-service-alert__icon i,
.wa-service-alert__icon svg {
  width: 1.1rem;
  height: 1.1rem;
}

.wa-service-alert--complaint .wa-service-alert__icon {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
}

.wa-service-alert--booking .wa-service-alert__icon {
  background: rgba(164, 144, 111, 0.2);
  color: #c4b08a;
}

.wa-service-alert--housekeeping .wa-service-alert__icon {
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
}

.wa-service-alert__text {
  min-width: 0;
  flex: 1;
}

.wa-service-alert__title {
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.3;
}

.wa-service-alert__body {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: hsl(var(--muted-foreground));
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wa-service-alert__close {
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--muted-foreground));
  background: transparent;
  border: none;
  cursor: pointer;
}

.wa-service-alert__close:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

.wa-service-alert__close i,
.wa-service-alert__close svg {
  width: 0.9rem;
  height: 0.9rem;
}

/* Sidebar nav badges (new complaint / booking / cleaning) */
.wa-sidebar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.35rem;
  border-radius: 9999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 2px hsl(var(--card));
}

.sidebar-nav-link.bg-primary .wa-sidebar-badge {
  box-shadow: 0 0 0 2px hsl(var(--primary));
}

.wa-sidebar-badge--dot {
  min-width: 0.5rem;
  width: 0.5rem;
  height: 0.5rem;
  padding: 0;
  position: absolute;
  top: 0.4rem;
  inset-inline-end: 0.45rem;
}

#sidebar.w-20 .wa-sidebar-badge:not(.wa-sidebar-badge--dot) {
  display: none !important;
}