/* calendar.css – Kalendář instalací wattery FVE */

/* ─── LAYOUT ──────────────────────────────────────────────────────────────── */

.cal-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.cal-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.cal-month-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--c-text);
  margin: 0;
  flex: 1;
  text-align: center;
}

.cal-today-btn {
  margin-left: 4px;
}

/* Přepínač počtu měsíců (1M / 3M / 6M) */
.cal-view-btns {
  display: flex;
  gap: 4px;
  margin-left: 4px;
}

.cal-view-btn {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 7px;
  min-width: 36px;
}

.cal-add-btn {
  margin-left: auto;
}

/* ─── VÍCEMĚSÍČNÍ GRID ───────────────────────────────────────────────────── */

.cal-months-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Blok jednoho měsíce */
.cal-month-block {
  width: 100%;
}

.cal-month-block-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 8px;
  padding: 0 2px;
  letter-spacing: 0.01em;
}

/* Tlačítko ‹ › */
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--c-border);
  background: var(--c-card);
  color: var(--c-text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.btn-icon:hover {
  background: var(--c-hover);
}

/* ─── MŘÍŽKA ─────────────────────────────────────────────────────────────── */

.cal-grid-wrap {
  background: var(--c-card);
  /* výraznější vnější rámeček: tmavší než --c-border (mix s --c-text-muted) */
  border: 1px solid color-mix(in srgb, var(--c-border) 40%, var(--c-text-muted));
  border-radius: 12px;
  overflow: hidden;
  /* CSS proměnná pro mřížku — používaná na všech vnitřních linkách */
  --cal-grid-line: color-mix(in srgb, var(--c-border) 40%, var(--c-text-muted));
}

.cal-grid {
  width: 100%;
}

.cal-header-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--cal-grid-line);
  background: color-mix(in srgb, var(--c-bg) 60%, transparent);
}

.cal-col-header {
  text-align: center;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-right: 1px solid var(--cal-grid-line);
}
.cal-col-header:last-child {
  border-right: none;
}

.cal-week-row {
  position: relative;
  border-bottom: 1px solid var(--cal-grid-line);
  display: flex;            /* aby cal-week-days vyplnilo celý řádek */
  flex-direction: column;
}
.cal-week-row:last-child {
  border-bottom: none;
}

.cal-week-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: 1fr;  /* jediný řádek vyplní výšku — cells se roztáhnou */
  position: relative;
  z-index: 1;
  flex: 1 0 auto;           /* roste do plné výšky .cal-week-row */
}

/* Denní buňka */
.cal-cell {
  min-height: 28px;
  border-right: 1px solid var(--cal-grid-line);
  padding: 4px 6px 0;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.cal-cell:last-child {
  border-right: none;
}
.cal-cell:hover {
  background: var(--c-hover);
}
.cal-cell-empty {
  background: var(--c-bg);
  cursor: default;
}
.cal-cell-empty:hover {
  background: var(--c-bg);
}
.cal-cell-weekend {
  background: var(--c-bg);
}
.cal-cell-today {
  background: color-mix(in srgb, var(--c-primary) 8%, transparent);
}
.cal-cell-today:hover {
  background: color-mix(in srgb, var(--c-primary) 14%, transparent);
}

.cal-cell-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-height: 22px;
}

.cal-day-num {
  font-size: 12px;
  color: var(--c-text-muted);
  font-weight: 500;
  user-select: none;
  line-height: 22px;
}
.cal-today-num {
  background: var(--c-primary);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

.cal-revize-badge {
  font-size: 10px;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  padding: 1px 4px;
  line-height: 14px;
  cursor: pointer;
}

/* Events area — absolutní overlay nad cells.
   Cells teď vyplňují celý řádek (díky flex+grid stretch), takže jejich
   border-right se táhne přes celou výšku. Events se kreslí navrch. */
.cal-week-events {
  position: absolute;
  top: 28px;          /* hned pod day-num řádkem (cell top má min-height 22 + padding 4 = 26, +2 padding) */
  left: 0;
  right: 0;
  pointer-events: none;
}

/* ─── UDÁLOSTI ───────────────────────────────────────────────────────────── */

.cal-event {
  position: absolute;
  height: 20px;
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.93;
  transition: opacity 0.15s, transform 0.1s;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.cal-event:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  z-index: 3;
}

.cal-event-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 3px;
}

.cal-event-icon {
  font-size: 12px;
  flex-shrink: 0;
  line-height: 1;
  margin-right: 1px;
}

/* ─── MODAL ──────────────────────────────────────────────────────────────── */

.cal-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.cal-modal-box {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 14px;
  width: 100%;
  max-width: 500px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}

/* Dark mode override */
@media (prefers-color-scheme: dark) {
  .cal-modal-box {
    background: #1e2128;
    border-color: #374151;
  }
}

/* Pokud app používá CSS proměnnou pro tmavý/světlý mód */
[data-theme="dark"] .cal-modal-box,
.dark .cal-modal-box {
  background: #1e2128;
  border-color: #374151;
}

.cal-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-text, #111827);
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 1;
  border-radius: 14px 14px 0 0;
}

.cal-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--c-text-muted, #6b7280);
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s;
}
.cal-modal-close:hover {
  background: rgba(0,0,0,0.06);
}

#cal-event-form {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cal-form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cal-form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.cal-form-row-2col > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cal-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cal-hint {
  font-size: 11px;
  color: var(--c-text-muted, #9ca3af);
  margin-top: 2px;
}

.cal-modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 4px;
  border-top: 1px solid #e5e7eb;
  margin-top: 4px;
}

/* ─── TLAČÍTKA TYPU UDÁLOSTI ─────────────────────────────────────────────── */

.cal-type-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cal-type-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: 8px;
  border: 2px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1.2;
}
.cal-type-btn:hover {
  border-color: #9ca3af;
  background: #f3f4f6;
}
.cal-type-btn.active {
  border-color: var(--c-primary, #3b82f6);
  background: color-mix(in srgb, var(--c-primary, #3b82f6) 10%, #fff);
  color: var(--c-primary, #3b82f6);
}
.cal-type-btn[data-type="navsteva"].active  { border-color: #3b82f6; background: #eff6ff; color: #1d4ed8; }
.cal-type-btn[data-type="instalace"].active { border-color: #f59e0b; background: #fffbeb; color: #b45309; }
.cal-type-btn[data-type="revize"].active    { border-color: #10b981; background: #f0fdf4; color: #065f46; }
.cal-type-btn[data-type="jine"].active      { border-color: #8b5cf6; background: #faf5ff; color: #6d28d9; }

.cal-type-icon {
  font-size: 15px;
  line-height: 1;
}

/* ─── BARVY ──────────────────────────────────────────────────────────────── */

.cal-color-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.cal-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, outline 0.15s;
  flex-shrink: 0;
}
.cal-color-swatch:hover {
  transform: scale(1.15);
}

/* ─── VYHLEDÁVAČ REALIZACÍ ───────────────────────────────────────────────── */

.cal-rid-wrap {
  position: relative;
}

.cal-rid-search-input {
  width: 100%;
}

.cal-rid-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.14);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
}

.cal-rid-option {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--c-text, #111827);
  transition: background 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-rid-option:hover {
  background: #f3f4f6;
}
.cal-rid-none {
  color: var(--c-text-muted, #9ca3af);
  font-style: italic;
  cursor: default;
}
.cal-rid-none-opt {
  border-bottom: 1px solid #e5e7eb;
  color: var(--c-text-muted, #9ca3af);
  font-size: 12px;
}
.cal-rid-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 2px 0;
}

.cal-rid-selected {
  margin-top: 4px;
}

.cal-rid-badge {
  display: inline-block;
  background: color-mix(in srgb, var(--c-primary, #3b82f6) 12%, #fff);
  color: var(--c-primary, #1d4ed8);
  border: 1px solid color-mix(in srgb, var(--c-primary, #3b82f6) 30%, transparent);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
}

/* ─── QUICK-ADD POPOVER ─────────────────────────────────────────────────── */

.cal-quick-popover {
  position: fixed;
  z-index: 1100;
  background: var(--c-card, #fff);
  border: 1px solid var(--c-border, #d1d5db);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.22);
  padding: 14px 16px 12px;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cal-qp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-muted, #6b7280);
}

.cal-qp-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-text-muted, #9ca3af);
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}

.cal-qp-types {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.cal-qp-type-btn {
  border: 1px solid var(--c-border, #e5e7eb);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.12s;
}

.cal-qp-title {
  width: 100%;
  box-sizing: border-box;
}

.cal-qp-actions {
  display: flex;
  gap: 8px;
}

.cal-qp-submit, .cal-qp-more {
  flex: 1;
  font-size: 13px;
  padding: 6px 10px;
}

/* ─── DRAG RESIZE GRIP ────────────────────────────────────────────────────── */

.cal-event-resize-grip {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
  opacity: 0;
  background: rgba(255,255,255,0.3);
  border-radius: 0 6px 6px 0;
  transition: opacity 0.15s;
}

.cal-event:hover .cal-event-resize-grip {
  opacity: 1;
}

/* ─── DRAG STATE ──────────────────────────────────────────────────────────── */

/* pointer-events: none nutné aby elementsFromPoint vrátil cell pod kurzorem,
   ne tažený event sám */
.cal-event-dragging {
  opacity: 0.7 !important;
  z-index: 50 !important;
  pointer-events: none !important;
  box-shadow: 0 6px 18px rgba(0,0,0,0.32) !important;
  transition: none !important;
}

/* ─── BARVA SWATCH – VYBRANÁ ─────────────────────────────────────────────── */

.cal-color-swatch.selected {
  outline: 3px solid var(--c-primary, #3b82f6);
  outline-offset: 2px;
  transform: scale(1.15);
}

/* ─── FILTR TOOLBAR ──────────────────────────────────────────────────────── */

.cal-filter-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.cal-filter-input {
  max-width: 220px;
  padding-right: 28px;
  font-size: 13px;
}

.cal-filter-clear {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-text-muted, #9ca3af);
  font-size: 14px;
  line-height: 1;
  padding: 2px;
  border-radius: 4px;
}

.cal-filter-clear:hover {
  color: var(--c-text, #111827);
}
