# -*- coding: utf-8 -*-
"""Carousel: arrows beside track (never overlay cards) + text wrap fix."""
import pathlib

p = pathlib.Path(r"C:\alrent\resources\view\web\assets\css\alrent-design.css")
t = p.read_text(encoding="utf-8", errors="replace")

block = """

/* ===== CATEGORY CAROUSEL v3 — arrows beside track, never overlay cards ===== */
.category-carousel {
  position: relative !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  margin: 12px 0 8px !important;
  padding: 0 !important;
}

.category-carousel-track {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  width: auto !important;
  display: flex !important;
  gap: 12px !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px 14px !important;
  margin: 0 !important;
  scrollbar-width: none;
  align-items: stretch;
}

.category-carousel-track .home-widget-categories-item {
  flex: 0 0 auto !important;
  width: 176px !important;
  min-width: 176px !important;
  max-width: 176px !important;
  height: 100px !important;
  min-height: 100px !important;
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 12px !important;
  background-color: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 14px !important;
  overflow: hidden !important;
  position: relative !important;
  margin: 0 !important;
  scroll-snap-align: start;
}

/* arrows: static flow items beside the track */
.category-carousel-nav,
.category-carousel-prev,
.category-carousel-next {
  position: static !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
  z-index: 1 !important;
  flex: 0 0 auto !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  border-radius: 50% !important;
  border: 1px solid #e5e7eb !important;
  background: #ffffff !important;
  color: #0f172a !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.10) !important;
  padding: 0 !important;
}

.category-carousel-nav:hover:not(:disabled) {
  background: #0f172a !important;
  color: #ffffff !important;
  border-color: #0f172a !important;
  transform: none !important;
}
.category-carousel-nav:active:not(:disabled) {
  transform: scale(0.94) !important;
}
.category-carousel-nav:disabled {
  opacity: 0.35 !important;
  cursor: default !important;
}

/* text wrapping inside cards */
.home-widget-categories-item div {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  max-width: none !important;
  width: 0 !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 1.3 !important;
  color: #111827 !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  hyphens: auto;
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 3;
  overflow: hidden !important;
  text-overflow: ellipsis;
}

.home-widget-categories-item.long-name div {
  font-size: 12px !important;
}
.home-widget-categories-item.very-long-name div {
  font-size: 11px !important;
  -webkit-line-clamp: 4;
}

.home-widget-categories-item img {
  position: relative !important;
  right: auto !important;
  bottom: auto !important;
  width: 52px !important;
  height: 52px !important;
  min-width: 52px !important;
  min-height: 52px !important;
  object-fit: contain !important;
  flex-shrink: 0 !important;
  z-index: 0 !important;
}

@media (max-width: 768px) {
  .category-carousel-nav {
    display: none !important;
  }
  .category-carousel-track {
    padding: 4px 2px 14px !important;
  }
  .category-carousel-track .home-widget-categories-item {
    width: 148px !important;
    min-width: 148px !important;
    max-width: 148px !important;
  }
  .home-widget-categories-item div {
    font-size: 12px !important;
    max-width: none !important;
    width: 0 !important;
  }
  .home-widget-categories-item img {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
  }
}
"""

if "CATEGORY CAROUSEL v3" not in t:
    p.write_text(t + block, encoding="utf-8")
    print("appended v3 block")
else:
    print("v3 already present")

# verify
t2 = p.read_text(encoding="utf-8", errors="replace")
print("v3 present:", "CATEGORY CAROUSEL v3" in t2)
print("position: static for nav:", "position: static !important" in t2)
print("file size:", len(t2))
