@import "tailwindcss";
@import "../../node_modules/tw-animate-css/dist/tw-animate.css";

:root {
  --background: #f0f2f5;
  --foreground: #111b21;

  /* CRM brand palette (light) — buttons/accent use the same WhatsCRM green
     as the dark theme (#35d477) with dark foreground text. */
  --color-primary: #35d477;
  --color-primary-dark: #2daf64;
  --color-primary-soft: #dcf8c6;
  --color-bg: #f0f2f5;
  --color-surface: #ffffff;
  --color-border: #d1d7db;
  --color-text: #111b21;
  --color-muted: #667781;
  --color-success: #35d477;
  --color-success-light: #dcf8c6;
  --color-success-dark: #2daf64;
  --color-warning: #f59e0b;
  --color-warning-light: #fef3c7;
  --color-warning-dark: #d97706;
  --color-danger: #dc2626;
  --color-danger-light: #fee2e2;
  --color-danger-dark: #b91c1c;
  --color-info: #2563eb;
  --color-info-light: #dbeafe;
  --color-info-dark: #1d4ed8;

  /* shadcn-compat tokens consumed by components/ui (button, dialog, sheet). */
  --color-primary-foreground: #04130a;
  --color-secondary: #eef1f2;
  --color-secondary-foreground: #111b21;
  --color-destructive: #dc2626;
  --color-ring: #35d477;
  --color-input: #d1d7db;

  /* Chat accent (WhatsApp green). --color-accent is the green used for action
     buttons, online/badge indicators and focus rings; --color-accent-text is the
     text color that sits ON a solid accent background; --color-accent-muted is
     accent used as readable text on a light/dark surface (badges, links). */
  --color-accent: #35d477;
  --color-accent-text: #04130a;
  --color-accent-muted: #1e8e58;

  /* Chat/message-list background: deliberately a step darker than --color-surface
     so white inbound bubbles and green outbound bubbles stand out clearly. */
  --color-chat-bg: #efeae2;
  --color-incoming-bubble: #ffffff;
  --color-outgoing-bubble: #d9fdd3;
  /* Outbound bubbles are light green in light mode, so their text must be
     dark there (white only works against the dark-mode green bubble). */
  --color-outgoing-text: #111b21;

  /* Chart categorical series (validated palette, see dataviz skill references/palette.md) */
  --chart-series-1: #2a78d6; /* blue */
  --chart-series-2: #eb6834; /* orange */
  --chart-series-3: #1baf7a; /* aqua */
  --chart-series-4: #eda100; /* yellow */
  --chart-series-5: #e34948; /* red */
  --chart-series-6: #4a3aa7; /* violet */
}

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --font-sans: var(--font-geist-sans);
  --font-mono: var(--font-geist-mono);

  /* Expose CRM palette as Tailwind utilities: bg-primary, text-danger, border-border, etc. */
  --color-primary: var(--color-primary);
  --color-primary-dark: var(--color-primary-dark);
  --color-primary-soft: var(--color-primary-soft);
  --color-bg: var(--color-bg);
  --color-surface: var(--color-surface);
  --color-border: var(--color-border);
  --color-text: var(--color-text);
  --color-muted: var(--color-muted);
  --color-popover: var(--color-surface);
  --color-popover-foreground: var(--color-text);
  --color-success: var(--color-success);
  --color-warning: var(--color-warning);
  --color-danger: var(--color-danger);
  --color-info: var(--color-info);
  --color-accent: var(--color-accent);
  --color-accent-text: var(--color-accent-text);
  --color-accent-muted: var(--color-accent-muted);
  --color-chat-bg: var(--color-chat-bg);
  --color-incoming-bubble: var(--color-incoming-bubble);
  --color-outgoing-bubble: var(--color-outgoing-bubble);
  --color-outgoing-text: var(--color-outgoing-text);

  /* shadcn-compat exposure */
  --color-primary-foreground: var(--color-primary-foreground);
  --color-secondary: var(--color-secondary);
  --color-secondary-foreground: var(--color-secondary-foreground);
  --color-destructive: var(--color-destructive);
  --color-ring: var(--color-ring);
  --color-input: var(--color-input);
}

/* Elevation + motion scale. Tailwind 4 turns these into utilities:
   shadow-card, shadow-card-hover, shadow-pop, shadow-topnav, ease-out-soft,
   animate-rise. `backwards` fill keeps the pre-delay state during stagger
   delays and releases the transform after play so hover lifts still work. */
@theme {
  --shadow-card: 0 1px 2px rgb(17 27 33 / 0.04), 0 4px 14px -2px rgb(17 27 33 / 0.07);
  --shadow-card-hover: 0 2px 4px rgb(17 27 33 / 0.05), 0 14px 28px -8px rgb(17 27 33 / 0.14);
  --shadow-pop: 0 4px 8px -2px rgb(17 27 33 / 0.08), 0 20px 48px -12px rgb(17 27 33 / 0.22);
  --shadow-topnav: 0 8px 20px -14px rgb(17 27 33 / 0.38);
  --ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --animate-rise: rise 260ms cubic-bezier(0.22, 1, 0.36, 1) backwards;

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

.dark {
  --background: #0b0d0e;
  --foreground: #f4f6f5;

  /* CRM brand palette (dark) — matches the auth shell: charcoal surfaces,
     muted neutrals, and the WhatsCRM green for actions/accent. */
  --color-primary: #35d477;
  --color-primary-dark: #2daf64;
  --color-primary-soft: #171a1b;
  --color-bg: #0b0d0e;
  --color-surface: #121516;
  --color-border: #2b3031;
  --color-text: #f4f6f5;
  --color-muted: #a4acab;
  --color-success: #35d477;
  --color-warning: #d9a441;
  --color-danger: #ff7d8f;
  --color-info: #5cc8d7;

  /* shadcn-compat tokens (dark step) */
  --color-primary-foreground: #04130a;
  --color-secondary: #1e2223;
  --color-secondary-foreground: #f4f6f5;
  --color-destructive: #ff7d8f;
  --color-ring: #35d477;
  --color-input: #0e1112;

  /* Chat accent (WhatsApp green) */
  --color-accent: #35d477;
  --color-accent-text: #04130a;
  --color-accent-muted: #6fdc9c;

  /* Chat/message-list background: a step darker than the surface so inbound
     and outbound bubbles stand out clearly. */
  --color-chat-bg: #0e1112;
  --color-incoming-bubble: #171a1b;
  --color-outgoing-bubble: #1a5c44;
  --color-outgoing-text: #f4f6f5;

  /* Chart categorical series (dark-mode step, see dataviz skill references/palette.md) */
  --chart-series-1: #3987e5;
  --chart-series-2: #d95926;
  --chart-series-3: #199e70;
  --chart-series-4: #c98500;
  --chart-series-5: #e66767;
  --chart-series-6: #9085e9;
}

/* Auth shell: neutral charcoal operations console with restrained status color. */
:root {
  --auth-bg: #0b0d0e;
  --auth-panel: #0e1112;
  --auth-surface: #121516;
  --auth-elevated: #171a1b;
  --auth-input: #0e1112;
  --auth-border: #2b3031;
  --auth-border-strong: #42494a;
  --auth-text: #f4f6f5;
  --auth-muted: #a4acab;
  --auth-subtle: #7f8987;
  --auth-green: #35d477;
  --auth-green-hover: #4ade80;
  --auth-cyan: #5cc8d7;
  --auth-amber: #d9a441;
  --auth-danger: #ff7d8f;
}

@theme inline {
  --color-auth-bg: var(--auth-bg);
  --color-auth-panel: var(--auth-panel);
  --color-auth-surface: var(--auth-surface);
  --color-auth-elevated: var(--auth-elevated);
  --color-auth-input: var(--auth-input);
  --color-auth-border: var(--auth-border);
  --color-auth-border-strong: var(--auth-border-strong);
  --color-auth-text: var(--auth-text);
  --color-auth-muted: var(--auth-muted);
  --color-auth-subtle: var(--auth-subtle);
  --color-auth-green: var(--auth-green);
  --color-auth-green-hover: var(--auth-green-hover);
  --color-auth-cyan: var(--auth-cyan);
  --color-auth-amber: var(--auth-amber);
  --color-auth-danger: var(--auth-danger);
}

html,
body,
#__next {
  min-height: 100%;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-geist-sans), Arial, Helvetica, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Ambient wash behind dashboard content: soft teal/green radial accents that
   sit on top of the flat app background (light and dark steps). */
.ambient-dash {
  background-image:
    radial-gradient(1100px 380px at 18% -8%, rgb(7 94 84 / 0.055), transparent 62%),
    radial-gradient(900px 320px at 88% -14%, rgb(37 211 102 / 0.05), transparent 58%);
  background-repeat: no-repeat;
}

.dark .ambient-dash {
  background-image:
    radial-gradient(1100px 380px at 18% -8%, rgb(37 211 102 / 0.07), transparent 62%),
    radial-gradient(900px 320px at 88% -14%, rgb(11 110 79 / 0.08), transparent 58%);
}

/* Sidebar surface: subtle vertical depth gradient instead of a flat fill. */
.sidebar-surface {
  background-image: linear-gradient(
    180deg,
    var(--color-surface) 0%,
    color-mix(in srgb, var(--color-bg) 42%, var(--color-surface)) 100%
  );
}

/* Light mode WhatsApp wallpaper */
.message-list-bg {
  background-color: var(--color-chat-bg);
  background-image: url("data:image/svg+xml,%3Csvg width='400' height='400' viewBox='0 0 400 400' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M40 30c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 12c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z' fill='%23000000' fill-opacity='0.04'/%3E%3Cpath d='M130 45h24v4h-24zM130 53h16v4h-16z' fill='%23000000' fill-opacity='0.04'/%3E%3Cpath d='M230 35c-6.6 0-12 5.4-12 12s5.4 12 12 12 12-5.4 12-12-5.4-12-12-12zm0 20c-4.4 0-8-3.6-8-8s3.6-8 8-8 8 3.6 8 8-3.6 8-8 8z' fill='%23000000' fill-opacity='0.04'/%3E%3Cpath d='M330 45l-10 10 10 10 10-10-10-10z' fill='%23000000' fill-opacity='0.04'/%3E%3Cpath d='M65 130c0-8.8 7.2-16 16-16s16 7.2 16 16c0 5.4-2.7 10.2-6.9 13.1l.9 6.9-6.3-3.2c-1.2.4-2.4.6-3.7.6-8.8 0-16-7.2-16-16zm28 0c0-6.6-5.4-12-12-12s-12 5.4-12 12 5.4 12 12 12c1.1 0 2.2-.2 3.2-.5l3.5 1.8-.5-3.8c2.3-2.1 3.8-5.1 3.8-8.5z' fill='%23000000' fill-opacity='0.04'/%3E%3Cpath d='M175 120l14 24h-28z' fill='%23000000' fill-opacity='0.04'/%3E%3Cpath d='M285 125c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm-16 28h32v4h-32z' fill='%23000000' fill-opacity='0.04'/%3E%3Cpath d='M45 230h18v18H45z' fill='%23000000' fill-opacity='0.04'/%3E%3Cpath d='M145 220c-8 0-14 6-14 14s6 14 14 14 14-6 14-14-6-14-14-14zm0 24c-5.5 0-10-4.5-10-10s4.5-10 10-10 10 4.5 10 10-4.5 10-10 10z' fill='%23000000' fill-opacity='0.04'/%3E%3Cpath d='M245 210l12 18-18 6z' fill='%23000000' fill-opacity='0.04'/%3E%3Cpath d='M345 220c-6.6 0-12 5.4-12 12s5.4 12 12 12 12-5.4 12-12-5.4-12-12-12z' fill='%23000000' fill-opacity='0.04'/%3E%3Cpath d='M75 320c0-6.6 5.4-12 12-12s12 5.4 12 12-5.4 12-12 12-12-5.4-12-12z' fill='%23000000' fill-opacity='0.04'/%3E%3Cpath d='M185 310h22v22h-22z' fill='%23000000' fill-opacity='0.04'/%3E%3Cpath d='M295 315l-14 14 14 14 14-14-14-14z' fill='%23000000' fill-opacity='0.04'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* Dark mode WhatsApp wallpaper */
.dark .message-list-bg {
  background-color: var(--color-chat-bg);
  background-image: url("data:image/svg+xml,%3Csvg width='400' height='400' viewBox='0 0 400 400' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M40 30c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 12c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z' fill='%23ffffff' fill-opacity='0.035'/%3E%3Cpath d='M130 45h24v4h-24zM130 53h16v4h-16z' fill='%23ffffff' fill-opacity='0.035'/%3E%3Cpath d='M230 35c-6.6 0-12 5.4-12 12s5.4 12 12 12 12-5.4 12-12-5.4-12-12-12zm0 20c-4.4 0-8-3.6-8-8s3.6-8 8-8 8 3.6 8 8-3.6 8-8 8z' fill='%23ffffff' fill-opacity='0.035'/%3E%3Cpath d='M330 45l-10 10 10 10 10-10-10-10z' fill='%23ffffff' fill-opacity='0.035'/%3E%3Cpath d='M65 130c0-8.8 7.2-16 16-16s16 7.2 16 16c0 5.4-2.7 10.2-6.9 13.1l.9 6.9-6.3-3.2c-1.2.4-2.4.6-3.7.6-8.8 0-16-7.2-16-16zm28 0c0-6.6-5.4-12-12-12s-12 5.4-12 12 5.4 12 12 12c1.1 0 2.2-.2 3.2-.5l3.5 1.8-.5-3.8c2.3-2.1 3.8-5.1 3.8-8.5z' fill='%23ffffff' fill-opacity='0.035'/%3E%3Cpath d='M175 120l14 24h-28z' fill='%23ffffff' fill-opacity='0.035'/%3E%3Cpath d='M285 125c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm-16 28h32v4h-32z' fill='%23ffffff' fill-opacity='0.035'/%3E%3Cpath d='M45 230h18v18H45z' fill='%23ffffff' fill-opacity='0.035'/%3E%3Cpath d='M145 220c-8 0-14 6-14 14s6 14 14 14 14-6 14-14-6-14-14-14zm0 24c-5.5 0-10-4.5-10-10s4.5-10 10-10 10 4.5 10 10-4.5 10-10 10z' fill='%23ffffff' fill-opacity='0.035'/%3E%3Cpath d='M245 210l12 18-18 6z' fill='%23ffffff' fill-opacity='0.035'/%3E%3Cpath d='M345 220c-6.6 0-12 5.4-12 12s5.4 12 12 12 12-5.4 12-12-5.4-12-12-12z' fill='%23ffffff' fill-opacity='0.035'/%3E%3Cpath d='M75 320c0-6.6 5.4-12 12-12s12 5.4 12 12-5.4 12-12 12-12-5.4-12-12z' fill='%23ffffff' fill-opacity='0.035'/%3E%3Cpath d='M185 310h22v22h-22z' fill='%23ffffff' fill-opacity='0.035'/%3E%3Cpath d='M295 315l-14 14 14 14 14-14-14-14z' fill='%23ffffff' fill-opacity='0.035'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* Print/PDF export: hide the app chrome (sidebar, topnav, interactive-only
   controls) and let the report content fill the page. Pages only add the
   print: utilities, so this only affects printing the reports/analytics
   pages. */
@media print {
  aside,
  header.topnav-print-hide {
    display: none !important;
  }

  main {
    overflow: visible !important;
    padding: 0 !important;
  }

  body {
    background: #fff !important;
  }

  /* Charts and tables print with their screen colors intact. */
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Respect the user's reduced-motion preference: cut all animation/transition
   duration to effectively zero instead of disabling styles altogether, so
   layout doesn't jump but nothing "moves" for users who opt out of motion. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
