/*
 * Twenty CRM v1.17.0 — Custom Theme (HubSpot-inspired)
 * Injected via Docker volume mount
 *
 * Strategy: Override Emotion CSS-in-JS styles by targeting:
 * 1. Build-specific Emotion classes (stable within v1.17.0)
 * 2. data-testid attributes + descendant wildcards
 * 3. Structural selectors (.table-row, [data-virtualized-id])
 *
 * Emotion class mapping (v1.17.0 build):
 *   .s1e51d2w  = StyledCell (table cell: border, color, background)
 *   .s1efidhj  = StyledOuterContainer (cell outer: padding-left 8px)
 *   .sx4wx53   = StyledInnerContainer (cell inner: flex, overflow)
 *   .s1a0c8w6  = StyledOverflowingText (text: ellipsis, font-size inherit)
 *   .s1w973iz  = StyledBaseContainer (inline cell: height 32px)
 *   .sspy0d0   = StyledChip (chip: colors, padding, border-radius)
 *   .s1dcywfc  = StyledTag (tag: background, color, font-size)
 *   .sxy7bdy   = StyledContainer (field: height 20px, flex)
 *   .skj0go6   = StyledAvatar (avatar: border-radius, size)
 *   .s1wwm0md  = StyledVirtualizedRowContainer (row: height 33, absolute)
 */

/* === DEBUG BADGE === */
body::before {
  content: "THEME v3" !important;
  position: fixed !important;
  bottom: 8px !important;
  right: 8px !important;
  background: #0059dc !important;
  color: white !important;
  padding: 4px 10px !important;
  border-radius: 4px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  z-index: 99999 !important;
  pointer-events: none !important;
  opacity: 0.85 !important;
}

/* ============================================
   1. GLOBAL — Font smoothing & base
   ============================================ */
#root,
#root * {
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
}

/* ============================================
   2. TABLE CELLS — Bigger text, more padding
   Emotion puts color via var(--s1e51d2w-1)
   on .s1e51d2w. We override properties directly.
   ============================================ */

/* Cell outer container — increase left padding */
.s1efidhj {
  padding-left: 12px !important;
}

/* Cell text — force larger font size (overrides inherit chain) */
.s1a0c8w6 {
  font-size: 0.95rem !important;
}

/* Multi-line text */
.s1w3fbr1 {
  font-size: 0.95rem !important;
}

/* Inline cell base container — slightly taller feel via padding */
.s1w973iz {
  font-size: 0.95rem !important;
}

/* ============================================
   3. TABLE ROWS — Hover & zebra stripes
   ============================================ */

/* Row hover via .table-row (stable className) */
.table-row:hover > td,
.table-row:hover > .s1e51d2w {
  background: rgba(0, 89, 220, 0.045) !important;
}

/* Also via data-testid */
[data-testid^="row-id-"]:hover .s1e51d2w {
  background: rgba(0, 89, 220, 0.045) !important;
}

/* Zebra stripes on virtualized rows */
[data-virtualized-id]:nth-child(even) .s1e51d2w {
  background: rgba(0, 89, 220, 0.02) !important;
}

[data-virtualized-id]:nth-child(even):hover .s1e51d2w {
  background: rgba(0, 89, 220, 0.045) !important;
}

/* Active row — stronger highlight */
[data-active="true"] .s1e51d2w {
  background: rgba(0, 89, 220, 0.08) !important;
}

/* Focused row — left blue accent bar */
[data-focused="true"] .s1e51d2w:first-child {
  box-shadow: inset 3px 0 0 0 #0059dc !important;
}

/* ============================================
   4. COLUMN HEADERS — Uppercase, HubSpot-style
   ============================================ */

/* Column header cells */
#record-table-column-checkbox ~ td,
.s1e51d2w[style*="text-align"] {
  text-transform: uppercase !important;
  font-size: 0.72rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.5px !important;
}

/* Target thead-like header structure */
[data-testid^="row-id-"] ~ div .s1e51d2w:first-child,
.table-row .s1e51d2w {
  transition: background-color 0.1s ease !important;
}

/* ============================================
   5. TOP BAR — Larger, bolder page title
   ============================================ */
[data-testid="top-bar-title"],
[data-testid="top-bar-title"] * {
  font-size: 1.35rem !important;
  font-weight: 700 !important;
  letter-spacing: -0.3px !important;
}

/* ============================================
   6. CHIPS — Rounder, better spaced
   Emotion class .sspy0d0 with inline vars
   ============================================ */
[data-testid="chip"],
[data-testid="chip"] * {
  font-size: 0.82rem !important;
  font-weight: 500 !important;
}

.sspy0d0 {
  border-radius: 4px !important;
  font-weight: 500 !important;
}

/* ============================================
   7. TAGS — Slightly larger
   Emotion class .s1dcywfc
   ============================================ */
.s1dcywfc {
  border-radius: 4px !important;
  font-weight: 500 !important;
  padding: 2px 8px !important;
}

/* ============================================
   8. AVATAR — Subtle shadow on hover
   ============================================ */
.skj0go6 {
  transition: box-shadow 0.12s ease !important;
}

/* ============================================
   9. SIDEBAR NAVIGATION
   ============================================ */
#root nav a,
#root nav button {
  border-radius: 6px !important;
  transition: background-color 0.12s ease !important;
}

#root nav a:hover,
#root nav button:hover {
  background-color: rgba(0, 89, 220, 0.06) !important;
}

/* ============================================
   10. RECORD DETAIL — Better spacing
   ============================================ */
[data-testid="record-detail-records-list-item"] {
  padding: 10px 16px !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
  transition: background-color 0.12s ease !important;
}

[data-testid="record-detail-records-list-item"]:hover {
  background-color: rgba(0, 89, 220, 0.035) !important;
}

/* ============================================
   11. MODALS & OVERLAYS
   ============================================ */
[data-testid="modal-backdrop"] {
  backdrop-filter: blur(4px) !important;
  background-color: rgba(0, 0, 0, 0.4) !important;
}

[data-testid="command-menu"] {
  border-radius: 12px !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15),
              0 0 0 1px rgba(0, 0, 0, 0.06) !important;
}

/* ============================================
   12. INPUTS — Focus ring
   ============================================ */
#root input:focus,
#root textarea:focus {
  box-shadow: 0 0 0 3px rgba(0, 89, 220, 0.12) !important;
}

#root input,
#root textarea {
  border-radius: 6px !important;
  transition: border-color 0.12s ease, box-shadow 0.12s ease !important;
}

/* ============================================
   13. SCROLLBAR — Slimmer
   ============================================ */
#root ::-webkit-scrollbar {
  width: 6px !important;
  height: 6px !important;
}

#root ::-webkit-scrollbar-track {
  background: transparent !important;
}

#root ::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.12) !important;
  border-radius: 3px !important;
}

#root ::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.22) !important;
}

/* ============================================
   14. WORKSPACE DROPDOWN
   ============================================ */
[data-testid="workspace-dropdown"],
[data-testid="workspace-dropdown"] * {
  font-weight: 600 !important;
}

/* ============================================
   15. KANBAN BOARD CARDS
   ============================================ */
[data-testid="record-board-card"] {
  border-radius: 8px !important;
  transition: box-shadow 0.12s ease, transform 0.12s ease !important;
}

[data-testid="record-board-card"]:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
  transform: translateY(-1px) !important;
}

/* ============================================
   16. SECTION TITLES — Uppercase HubSpot-style
   ============================================ */
.section-title-container {
  font-size: 0.68rem !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.6px !important;
  color: #516f90 !important;
}

/* ============================================
   17. LINKS inside cells — HubSpot blue
   ============================================ */
.s1dd08x {
  color: #0059dc !important;
}

.s1dd08x:hover {
  color: #004bb5 !important;
}

/* Pill links */
.srl6h1l:hover {
  opacity: 0.85 !important;
}

/* ============================================
   18. TOOLTIP
   ============================================ */
[data-testid="tooltip"] {
  border-radius: 6px !important;
}

/* ============================================
   DARK MODE
   ============================================ */
@media (prefers-color-scheme: dark) {
  /* Row hover */
  .table-row:hover > td,
  .table-row:hover > .s1e51d2w,
  [data-testid^="row-id-"]:hover .s1e51d2w {
    background: rgba(255, 255, 255, 0.045) !important;
  }

  /* Zebra */
  [data-virtualized-id]:nth-child(even) .s1e51d2w {
    background: rgba(255, 255, 255, 0.02) !important;
  }

  [data-virtualized-id]:nth-child(even):hover .s1e51d2w {
    background: rgba(255, 255, 255, 0.045) !important;
  }

  /* Active row */
  [data-active="true"] .s1e51d2w {
    background: rgba(100, 160, 255, 0.1) !important;
  }

  /* Focused row */
  [data-focused="true"] .s1e51d2w:first-child {
    box-shadow: inset 3px 0 0 0 #4d9eff !important;
  }

  /* Record detail */
  [data-testid="record-detail-records-list-item"] {
    border-bottom-color: rgba(255, 255, 255, 0.06) !important;
  }

  [data-testid="record-detail-records-list-item"]:hover {
    background-color: rgba(255, 255, 255, 0.035) !important;
  }

  /* Nav hover */
  #root nav a:hover,
  #root nav button:hover {
    background-color: rgba(255, 255, 255, 0.06) !important;
  }

  /* Scrollbar */
  #root ::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.12) !important;
  }

  #root ::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.22) !important;
  }

  /* Modal */
  [data-testid="modal-backdrop"] {
    background-color: rgba(0, 0, 0, 0.6) !important;
  }

  /* Section titles */
  .section-title-container {
    color: #8fabc7 !important;
  }

  /* Links */
  .s1dd08x {
    color: #4d9eff !important;
  }

  .s1dd08x:hover {
    color: #7ab8ff !important;
  }
}
