/* Crystal Logistics skin for the Invoice Ninja React app.
 * Injected by nginx (sub_filter) into every HTML page, so no Invoice Ninja file
 * is modified and image upgrades keep it. The app styles many elements inline,
 * hence !important. Selectors target the login/auth screens' structure as of
 * 5.13.x — if an upgrade changes the markup, re-check these.
 * Brand: orange #D73F22, green #006A44 (brand/BRAND.md).
 */
:root {
  --cl-orange: #D73F22;
  --cl-orange-dark: #B5321A;
  --cl-green: #006A44;
  --cl-green-dark: #004F33;
  --cl-ink: #2A303D;
  --cl-muted: #6B7280;
  --cl-page: #F3F5F4;
}

/* ---------- Auth screens (login, password reset, register) ---------- */
/* The auth layout is the only top-level .min-h-screen centred column. */
.App > .min-h-screen.flex.flex-col.items-center.justify-center {
  background:
    linear-gradient(165deg, var(--cl-green) 0%, var(--cl-green-dark) 100%) top / 100% 46% no-repeat,
    var(--cl-page) !important;
  position: relative;
}

/* thin orange rule where the green band ends */
.App > .min-h-screen.flex.flex-col.items-center.justify-center::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 46%;
  height: 4px;
  background: var(--cl-orange);
}

/* Logo: swap Invoice Ninja's for Crystal's, on a white lockup panel
 * (brand manual: full-colour logo always on white). */
.App > .min-h-screen img[alt="Invoice Ninja Logo"] {
  content: url("/crystal/crystal-logo.png");
  height: 64px !important;
  width: auto;
}
.App > .min-h-screen > .flex.justify-center:first-child > a {
  background: #fff;
  padding: 14px 22px;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
  display: inline-block;
}

/* Card */
.App > .min-h-screen .max-w-md.rounded {
  position: relative;
  z-index: 1;
  border: 0 !important;
  border-top: 5px solid var(--cl-orange) !important;
  border-radius: 10px !important;
  box-shadow: 0 10px 40px rgba(0, 40, 26, .18) !important;
}
.App > .min-h-screen .max-w-md h2 {
  color: var(--cl-green) !important;
  font-weight: 700;
  letter-spacing: -.01em;
}
.App > .min-h-screen .max-w-md h2::after {
  content: "Crystal Logistics invoicing";
  display: block;
  font-size: .8rem;
  font-weight: 400;
  color: var(--cl-muted);
  margin-top: 2px;
}

/* Inputs */
.App > .min-h-screen .max-w-md input {
  border-color: #D1D5DB !important;
}
.App > .min-h-screen .max-w-md input:focus {
  border-color: var(--cl-green) !important;
  box-shadow: 0 0 0 3px rgba(0, 106, 68, .15) !important;
}

/* Primary button */
.App > .min-h-screen .max-w-md button[type="submit"] {
  background-color: var(--cl-orange) !important;
  border-color: var(--cl-orange) !important;
  color: #fff !important;
  font-weight: 600;
  transition: background-color .15s;
}
.App > .min-h-screen .max-w-md button[type="submit"]:hover:not(:disabled) {
  background-color: var(--cl-orange-dark) !important;
}

/* Links on auth screens (forgot password etc.) */
.App > .min-h-screen .max-w-md a,
.App > .min-h-screen .max-w-md + * a {
  color: var(--cl-green) !important;
}

/* Version line under the card */
.App > .min-h-screen p.mt-4.text-xs {
  position: relative;
  z-index: 1;
  color: var(--cl-muted);
}
.App > .min-h-screen p.mt-4.text-xs::after {
  content: " · crystal-logistics-company.com";
}

/* ---------- Inside the app: the sidebar ----------
 * The app's per-user colour theme (tools/setup_theme.py) only knows flat
 * colours per item. Here the whole panel becomes a deep-green glass sheet and
 * the active item a glossy orange "jewel" with a gilded left edge and a slow
 * shimmer. Selectors (5.13.x markup):
 *   panel   = the div wrapping nav[data-cy="navigationBar"]
 *   item    = nav > div > div   (active: .text-white, inactive: .text-gray-300)
 */
:root {
  --cl-glass-edge: rgba(255, 255, 255, .16);
  --cl-glass-fill: rgba(255, 255, 255, .07);
}

/* panel: layered gradients = green glass with a light sheen top-left and a
 * faint warm (orange) glow rising from the bottom */
div:has(> div > nav[data-cy="navigationBar"]),
div:has(> nav[data-cy="navigationBar"]) {
  background:
    radial-gradient(130% 55% at 0% 0%, rgba(255, 255, 255, .20), rgba(255, 255, 255, 0) 60%),
    radial-gradient(120% 45% at 50% 105%, rgba(215, 63, 34, .28), rgba(215, 63, 34, 0) 65%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .022) 0 2px, rgba(255, 255, 255, 0) 2px 9px),
    linear-gradient(180deg, #0B8259 0%, #006A44 38%, #00553A 72%, #003F2A 100%) !important;
  border-right: 1px solid rgba(255, 255, 255, .14) !important;
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25), 6px 0 24px -12px rgba(0, 40, 26, .55);
}

/* company switcher (top-left): Crystal's orange icon instead of the round,
 * bordered company-logo thumbnail; glass divider under it */
img[alt="Company logo"] {
  content: url("/crystal/crystal-icon-solid.png");
  border: 0 !important;
  border-radius: 0 !important;
  width: 2.1rem !important;
  object-fit: contain !important;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .35));
}
button[data-cy="companyDropdown"] span { color: #fff !important; font-weight: 600; letter-spacing: .01em; }
button[data-cy="companyDropdown"] > div:hover { background: var(--cl-glass-fill) !important; }
div:has(> button[data-cy="companyDropdown"]) {
  border-color: var(--cl-glass-edge) !important;
}

/* all items: white text and icons */
nav[data-cy="navigationBar"] a,
nav[data-cy="navigationBar"] svg {
  color: #fff !important;
}

/* inactive items: clear glass — transparent until hovered */
nav[data-cy="navigationBar"] > div > div.text-gray-300 {
  background: transparent !important;
  border-left-color: transparent !important;
  transition: background-color .18s ease, box-shadow .18s ease;
}
nav[data-cy="navigationBar"] > div > div.text-gray-300 a { opacity: .9; }
nav[data-cy="navigationBar"] > div > div.text-gray-300:hover {
  background: var(--cl-glass-fill) !important;
  box-shadow: inset 0 0 0 1px var(--cl-glass-edge), inset 0 1px 0 rgba(255, 255, 255, .12);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
nav[data-cy="navigationBar"] > div > div.text-gray-300:hover a { opacity: 1; }

/* active item: glossy orange jewel */
nav[data-cy="navigationBar"] > div > div.text-white {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #F2714C 0%, #E04A2A 48%, #D73F22 52%, #B8331A 100%) !important;
  border-left: 4px solid transparent !important;
  border-image: linear-gradient(180deg, #FFF4D6 0%, #FFD27A 35%, #FFFFFF 50%, #F5B54A 70%, #FFF1C9 100%) 1 !important;
  border-radius: 0 8px 8px 0 !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .55),
    inset 0 -1px 0 rgba(0, 0, 0, .18),
    0 8px 20px -8px rgba(215, 63, 34, .85),
    0 0 0 1px rgba(255, 255, 255, .10);
}
/* glass highlight on the top half */
nav[data-cy="navigationBar"] > div > div.text-white::before {
  content: "";
  position: absolute;
  inset: 0 0 50% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .32), rgba(255, 255, 255, .06));
  pointer-events: none;
}
/* slow diagonal shimmer sweeping across the active item */
nav[data-cy="navigationBar"] > div > div.text-white::after {
  content: "";
  position: absolute;
  top: -50%;
  bottom: -50%;
  width: 38%;
  left: -60%;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .42) 50%, rgba(255, 255, 255, 0) 100%);
  transform: skewX(-18deg);
  animation: cl-shimmer 5.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes cl-shimmer {
  0%, 62% { left: -60%; }
  100% { left: 130%; }
}
nav[data-cy="navigationBar"] > div > div.text-white a > div { text-shadow: 0 1px 1px rgba(110, 25, 8, .45); }
@media (prefers-reduced-motion: reduce) {
  nav[data-cy="navigationBar"] > div > div.text-white::after { animation: none; display: none; }
}

/* Sidebar footer icons, in order: 1 Slack community, 2 Contact us,
 * 3 Support/help, 4 About, 5 Dark mode, 6 Collapse sidebar.
 * Hide 1-3 — they point to Invoice Ninja's own support channels, not
 * Crystal's. Remove this rule to bring them back. */
nav.border-t.justify-around > div.cursor-pointer:nth-child(-n+3) {
  display: none !important;
}
nav.border-t.justify-around {
  border-color: var(--cl-glass-edge) !important;
  justify-content: space-evenly !important;
}

/* Phone width: keep the card off the edges */
@media (max-width: 480px) {
  .App > .min-h-screen .max-w-md { margin: 0 16px; width: auto; }
  .App > .min-h-screen img[alt="Invoice Ninja Logo"] { height: 48px !important; }
}
