/* ============================================================
   YLV Customize — builder UI styles
   Chart styles come from ../your-life.css
   ============================================================ */

body {
  background: #f0f4f8;
}

/* ── Two-column layout ── */
.cst-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.25rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
  align-items: start;
}

/* ── Left panel: controls ── */
.cst-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.cst-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.cst-card-title {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a0aec0;
  margin: 0 0 0.75rem;
}

/* DOB inputs (reuse ylv- classes from parent CSS) */
.cst-dob-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* View tabs */
.cst-view-tabs {
  display: flex;
  gap: 0.35rem;
}
.cst-tab {
  flex: 1;
  padding: 0.4rem 0.4rem;
  border: 1.5px solid var(--ylv-btn-border, #1a4e8a);
  border-radius: 6px;
  background: transparent;
  color: var(--ylv-btn-border, #1a4e8a);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: var(--ylv-font);
  white-space: nowrap;
}
.cst-tab:hover, .cst-tab.active {
  background: var(--ylv-btn-active-bg, #1a4e8a);
  color: var(--ylv-btn-active-text, #fff);
}

/* ── Presets ── */
.cst-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}
.cst-preset-btn {
  padding: 0.45rem 0.5rem;
  border-radius: 7px;
  border: 1.5px solid #e2e8f0;
  background: #f7fafc;
  color: #2d3748;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  font-family: var(--ylv-font);
}
.cst-preset-btn:hover { border-color: var(--ylv-accent, #2471a3); background: #ebf4ff; }

/* ── Rule list ── */
.cst-rules-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 40px;
}
.cst-rule {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.65rem;
  background: #f7fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  font-size: 0.82rem;
}
.cst-rule-drag { cursor: grab; color: #cbd5e0; font-size: 1rem; }
.cst-rule-label { font-weight: 600; color: #2d3748; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cst-rule-swatch {
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
}
.cst-rule-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 0.2rem;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.cst-rule-toggle.on { opacity: 1; color: var(--ylv-accent, #2471a3); }
.cst-rule-edit {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: #68d391;
  padding: 0 0.1rem;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.cst-rule-edit:hover { opacity: 1; }
.cst-rule-del {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: #fc8181;
  padding: 0 0.1rem;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.cst-rule-del:hover { opacity: 1; }

/* Edit mode highlight on Add button */
.cst-btn--editing { background: #68d391 !important; color: #1a202c !important; }

/* ── Add rule form ── */
.cst-add-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.cst-field-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.cst-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #718096;
  margin-bottom: 0.25rem;
  display: block;
}
.cst-input, .cst-select {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: var(--ylv-font);
  color: #1a202c;
  background: #fff;
  transition: border-color 0.15s;
}
.cst-input:focus, .cst-select:focus {
  outline: none;
  border-color: var(--ylv-accent, #2471a3);
}
.cst-input[type="color"] {
  padding: 0.15rem 0.25rem;
  height: 36px;
  width: 48px;
  cursor: pointer;
  flex-shrink: 0;
}
.cst-emoji-input {
  width: 52px;
  text-align: center;
  font-size: 1.1rem;
}
.cst-btn {
  padding: 0.45rem 0.85rem;
  border-radius: 7px;
  border: none;
  background: var(--ylv-btn-active-bg, #1a4e8a);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--ylv-font);
  transition: opacity 0.15s;
  white-space: nowrap;
}
.cst-btn:hover { opacity: 0.85; }
.cst-btn--outline {
  background: transparent;
  color: var(--ylv-accent, #2471a3);
  border: 1.5px solid var(--ylv-accent, #2471a3);
}
.cst-btn--sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}
.cst-btn--full { width: 100%; }
.cst-btn--danger { background: #fc8181; }

/* ── Conditional fields ── */
.cst-conditional { display: none; }
.cst-conditional.visible { display: block; }

/* Season grid */
.cst-season-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}
.cst-season-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: #4a5568;
}
.cst-season-item input[type="color"] {
  width: 28px; height: 24px;
  padding: 0.05rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  cursor: pointer;
}
.cst-season-item input[type="text"] {
  width: 36px;
  font-size: 1rem;
  text-align: center;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0.1rem;
}

/* ── Holiday panel ── */
.cst-holiday-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.cst-holiday-status {
  font-size: 0.78rem;
  color: #718096;
  margin-top: 0.35rem;
  min-height: 1.2em;
}
textarea.cst-input {
  min-height: 80px;
  resize: vertical;
  font-family: monospace;
  font-size: 0.75rem;
}

/* ── Share section ── */
.cst-share-url {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.72rem;
  font-family: monospace;
  color: #4a5568;
  background: #f7fafc;
  word-break: break-all;
  margin-bottom: 0.5rem;
  min-height: 48px;
}
.cst-share-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Right: chart area ── */
.cst-chart-col {
  min-width: 0;
}
.cst-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.cst-chart-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ylv-title, #1a4e8a);
  margin: 0;
}
.cst-chart-stat {
  font-size: 0.82rem;
  color: #718096;
}

/* Chart card wrapper */
.cst-chart-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem 1.25rem 1.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

/* Days zoom container — overflow/cursor toggled by JS per active view */
.cst-zoom-wrap {
  position: relative;
  border-radius: 8px;
  /* overflow and cursor set dynamically: hidden+grab for days, visible+default otherwise */
}
.cst-zoom-wrap.grabbing { cursor: grabbing !important; }
.cst-zoom-inner {
  transform-origin: 0 0;
  will-change: transform;
  /* transition removed for smooth drag */
}
.cst-zoom-controls {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.6rem;
}
.cst-zoom-btn {
  width: 30px; height: 30px;
  border-radius: 6px;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ylv-font);
  transition: border-color 0.15s;
}
.cst-zoom-btn:hover { border-color: var(--ylv-accent, #2471a3); }
.cst-zoom-label {
  font-size: 0.78rem;
  color: #718096;
  min-width: 3rem;
  text-align: center;
}

/* Legend */
.cst-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f0f4f8;
}
.cst-legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: #4a5568;
}
.cst-legend-swatch {
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
}

/* ── Responsive ── */
@media (max-width: 820px) {
  .cst-layout {
    grid-template-columns: 1fr;
  }
  .cst-panel {
    position: static;
    max-height: none;
  }
}

/* ── Print ── */
@page { size: Letter portrait; margin: 0.75in; }
@media print {
  body { background: white; }
  .ylv-nav,
  .cst-panel,
  .cst-zoom-controls,
  .cst-chart-header,
  .cst-legend { display: none !important; }
  /* Hide every chart that isn't active — prevents background bleed */
  .chart:not(.ylv-active) { display: none !important; }
  .chart.days { background: transparent; }
  .cst-layout {
    display: block;
    padding: 0;
  }
  .cst-chart-card {
    box-shadow: none;
    border-radius: 0;
    padding: 0;
  }
  .cst-zoom-wrap { overflow: visible; }
  .cst-zoom-inner { transform: none !important; }
  .chart li, .chart li.ylv-filled {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
