/* Top Filters Grid */
.top-filters {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin: 6px 0 10px;
  flex-shrink: 0;
  z-index: 50;
  position: relative;
  overflow: visible;
  width: 100%;
}

.top-filters.cols-4 {
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 4px;
}

/* Filter wrapper */
.filter {
  position: relative;
  overflow: visible;
  min-width: 0;
  width: 100%;
}

.select-wrap {
  position: relative;
  overflow: visible;
  min-width: 0;
  width: 100%;
}

/* Filter Display Buttons - КОМПАКТНЫЙ РАЗМЕР */
.filter-display,
.select-display {
  width: 100%;
  height: 34px;
  min-height: 34px;
  padding: 0 4px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  box-sizing: border-box;
  outline: none;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: border 0.15s, background 0.15s;
  overflow: hidden;
  white-space: nowrap;
}

/* Date Filter Container */
#dateFilter,
#cDateFilter {
  position: relative;
  overflow: visible;
  width: 100%;
  height: 34px;
  min-height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  box-sizing: border-box;
  display: flex;       /* Чтобы выровнять элементы внутри */
  align-items: center;
  justify-content: center;
}

/* Уменьшаем шрифт для режима 4-х колонок */
.top-filters.cols-4 .filter-display,
.top-filters.cols-4 .select-display,
.top-filters.cols-4 .date-display {
  font-size: 11px;
  padding: 0 2px;
  font-weight: 500;
  letter-spacing: -0.3px;
}

.date-display {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* Пропускает клики сквозь текст */
  font-size: 13px;
  letter-spacing: 0.4px;
  color: inherit;
  z-index: 1;
}

.top-filters.cols-4 .date-display {
  font-size: 11px;
}

/* Сам input даты - невидимый, но кликабельный */
input[type="date"].filter-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 0;
  cursor: pointer;
  z-index: 10; /* Должен быть выше текста */
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  padding: 0;
}

/* Хак для Webkit (iOS), чтобы кликалось по всей площади */
input[type="date"].filter-input::-webkit-calendar-picker-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Крестик очистки даты (появляется только если дата выбрана) */
.date-clear-btn {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 30px;
  z-index: 20; /* Выше инпута */
  display: none; /* Скрыт по умолчанию */
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #4ECDC4;
  cursor: pointer;
  background: transparent;
}

/* Decoration (Полоска снизу) */
.filter::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: auto;
  transform: translateX(-50%);
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  pointer-events: none;
  z-index: 2;
}

/* OVERRIDE for contractors filters: decoration at BOTTOM */
/* Removed as filters are now at the bottom by default layout */
/*
#contrFilters .filter::after {
  top: auto;
  bottom: -6px;
}
*/

.select-wrap::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: auto;
  transform: translateX(-50%);
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  pointer-events: none;
  z-index: 2;
}

.filter.dropdown.active::after,
.select-wrap.active::after {
  background: rgba(78, 205, 196, 0.8);
}

.select-arrow,
.filter-arrow {
  display: none;
}

/* Dropdown Menus */
.filter-menu,
.select-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  top: auto;
  border-radius: 12px;
  background: rgba(30, 30, 30, 0.95);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
  max-height: 260px;
  overflow-y: auto;
  list-style: none;
  padding: 8px;
  margin: 0;
  display: none;
  z-index: 9999;
  text-align: center;
  box-sizing: border-box;
  min-width: 100%;
  width: max-content;
}

/* OVERRIDE for contractors filters: menu opens DOWNWARDS */
/* Removed as filters are now at the bottom by default layout */
/* 
#contrFilters .filter-menu {
  bottom: auto;
  top: calc(100% + 8px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.65);
} 
*/

#favMenu {
  left: 0;
  right: auto;
  width: min(240px, calc(100vw - 32px));
  min-width: auto;
}

.filter-menu.show,
.select-menu.show {
  display: block;
}

#contrMenu { left: 0; right: 0; width: 100%; }
#pavMenu { left: 0; right: auto; width: max-content; min-width: 100%; max-width: 200px; }
#placeMenu { left: 0; right: auto; width: max-content; min-width: 100%; max-width: 200px; }
#cPavMenu { left: 0; right: auto; width: max-content; min-width: 100%; max-width: 180px; }
#cPlaceMenu { left: 0; right: auto; width: max-content; min-width: 100%; max-width: 180px; }
#cContrMenu { left: auto; right: 0; width: max-content; min-width: 100%; max-width: 180px; }

/* Option styling */
.filter-option,
.select-option,
.fav-option {
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #ccc;
  display: flex;
  align-items: center;
  justify-content: center; /* Center content */
  gap: 8px;
  font-weight: 500;
  margin-bottom: 2px;
  white-space: nowrap;
  border: 1px solid transparent;
  font-size: 13px;
}

.filter-option:hover,
.select-option:hover,
.fav-option:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* Active/Selected state */
.filter-option.active-opt,
.select-option.active-opt,
.fav-option.selected {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  border-color: rgba(255, 255, 255, 0.12);
}

.fav-option.selected .fav-icon {
  color: #ffd700; /* Gold star */
  filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.5));
}

.ticker-track {
  display: flex;
  white-space: nowrap;
  animation: ticker linear infinite;
  animation-duration: var(--ticker-duration);
  gap: var(--ticker-gap);
}

@keyframes ticker {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(-50% - (var(--ticker-gap) / 2))); }
}

/* Custom Calendar Widget */
.custom-calendar {
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: min(280px, calc(100vw - 32px));
  background: rgba(22, 22, 28, 0.98);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  z-index: 10000;
  display: none;
  padding: 16px;
  box-sizing: border-box;
  color: #e8e8ec;
  margin-top: 10px;
}

.custom-calendar.show {
  display: block;
}

/* Positioning Override for Contractors Calendar - REMOVED to allow default centering */
/*
#ws-contractors .custom-calendar {
  left: auto;
  right: -20px;
  transform: none;
}
*/

/* Override animation transform for contractors calendar - REMOVED */
/*
#ws-contractors .custom-calendar.show {
  animation: calFadeInRight 0.2s ease-out;
}
*/

@keyframes calFadeInRight {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.cal-title {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

.cal-nav-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 14px;
}
.cal-nav-btn:hover { background: rgba(255, 255, 255, 0.1); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}

.cal-day-name {
  font-size: 11px;
  color: #888;
  margin-bottom: 6px;
  font-weight: 600;
}

.cal-day {
  height: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.cal-day:hover {
  background: rgba(255, 255, 255, 0.1);
}

.cal-day.selected {
  background: #4ECDC4;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(78, 205, 196, 0.4);
}

.cal-day.today {
  border: 1px solid #4ECDC4;
  color: #4ECDC4;
}
.cal-day.today.selected {
  color: #fff;
  border: none;
}

.cal-day.empty {
  pointer-events: none;
}

/* EVENTS (Top) - Dropdowns Open DOWN */
#ws-events .filter-menu {
  top: calc(100% + 8px);
  bottom: auto;
}

/* CONTRACTORS (Bottom) - Dropdowns Open UP and Centered */
#ws-contractors .filter-menu {
  bottom: calc(100% + 12px);
  top: auto;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  max-width: 90vw; /* Prevent overflow */
}

/* Ensure Contractor Calendar opens DOWN (it is at the top) */
#ws-contractors .custom-calendar {
  top: calc(100% + 12px);
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
}