/* Rotina: calendário (dia, semana e mês) */

.cal-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 24px 20px;
  overflow: hidden;
}

.cal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-shrink: 0;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.cal-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 12px;
  border: 0.5px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.cal-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.cal-today {
  font-size: 12px;
}

.cal-title {
  margin-left: 10px;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-title::first-letter {
  text-transform: uppercase;
}

.cal-hint {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--color-muted);
}

.cal-body {
  flex: 1;
  min-height: 0;
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: 14px;
  overflow: hidden;
}

.cal-scroll {
  height: 100%;
  overflow: auto;
}

/* ---- dia e semana ---- */

.cal-grid {
  display: grid;
  grid-template-columns: 54px repeat(var(--cols), minmax(0, 1fr));
  position: relative;
}

.cal-grid.semana {
  min-width: 760px;
}

.cal-corner,
.cal-dayhead {
  position: sticky;
  top: 0;
  z-index: 6;
  height: 56px;
  background: var(--color-surface);
  border-bottom: 0.5px solid var(--color-border);
}

.cal-dayhead {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-left: 0.5px solid var(--color-border-soft);
  cursor: pointer;
}

.cal-dow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--color-muted);
}

.cal-dnum {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
}

.cal-dayhead:hover .cal-dnum {
  background: var(--color-primary-soft);
}

.cal-dayhead.today .cal-dow {
  color: var(--color-accent-text);
}

.cal-dayhead.today .cal-dnum {
  background: var(--color-primary);
  color: #ffffff;
}

.cal-allday-label,
.cal-allday-cell {
  position: sticky;
  top: 56px;
  z-index: 5;
  min-height: 34px;
  background: var(--color-surface);
  border-bottom: 0.5px solid var(--color-border);
}

.cal-allday-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.cal-allday-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px 4px 5px;
  border-left: 0.5px solid var(--color-border-soft);
  cursor: pointer;
}

.cal-allday-cell.drop-over,
.cal-mcell.drop-over {
  background: var(--color-primary-soft);
}

.cal-hours {
  position: relative;
}

.cal-hours span {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 500;
  color: var(--color-muted);
}

.cal-col {
  position: relative;
  height: calc(24 * var(--hour));
  border-left: 0.5px solid var(--color-border-soft);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--hour) - 1px),
    var(--color-border-soft) calc(var(--hour) - 1px),
    var(--color-border-soft) var(--hour)
  );
  cursor: cell;
}

.cal-col.today {
  background-color: rgba(201, 169, 106, 0.07);
}

/* ---- blocos e chips ---- */

.cal-block {
  position: absolute;
  z-index: 2;
  padding: 4px 26px 4px 9px;
  border-radius: 9px;
  background: var(--c);
  color: var(--on, #ffffff);
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(46, 46, 46, 0.18);
  transition: box-shadow 0.15s, transform 0.15s;
}

.cal-block:hover {
  z-index: 3;
  box-shadow: 0 6px 14px rgba(46, 46, 46, 0.24);
  transform: translateY(-1px);
}

.cal-block:active {
  cursor: grabbing;
}

.cal-block-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-block-time {
  font-size: 10px;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-block.done,
.cal-chip.done {
  opacity: 0.5;
}

.cal-block.done .cal-block-title,
.cal-chip.done .cal-chip-text {
  text-decoration: line-through;
}

.cal-check {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--on, #ffffff);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
}

.cal-check:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.25);
}

.cal-block.done .cal-check {
  background: var(--on, #ffffff);
  color: var(--c);
  opacity: 1;
}

/* Blocos que dividem a coluna ficam estreitos: sem o botão de concluir e com texto menor, para o nome aparecer */
.cal-block.shared {
  padding: 4px 6px;
}

.cal-block.shared .cal-check {
  display: none;
}

.cal-block.shared .cal-block-title {
  font-size: 10px;
  line-height: 1.2;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.cal-block.shared .cal-block-time {
  display: none;
}

.dragging {
  opacity: 0.35;
}

.cal-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--c);
  color: var(--on, #ffffff);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(46, 46, 46, 0.14);
}

.cal-chip:hover {
  filter: brightness(1.06);
}

.cal-chip-dot {
  display: none;
}

.cal-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-chip-text b {
  font-weight: 700;
}

.cal-ghost {
  position: absolute;
  left: 2px;
  right: 2px;
  z-index: 4;
  padding: 3px 8px;
  border: 1.5px dashed var(--color-primary);
  border-radius: 8px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}

.cal-now {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 4;
  height: 2px;
  background: var(--color-primary);
  pointer-events: none;
}

.cal-now::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary);
}

/* ---- mês ---- */

.cal-month {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 460px;
}

.cal-mheads,
.cal-mgrid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-mheads {
  flex-shrink: 0;
  border-bottom: 0.5px solid var(--color-border);
}

.cal-mhead {
  padding: 10px 0;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--color-muted);
}

.cal-mgrid {
  flex: 1;
  grid-auto-rows: minmax(92px, 1fr);
  overflow-y: auto;
}

.cal-mcell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 6px 6px 8px;
  border-right: 0.5px solid var(--color-border-soft);
  border-bottom: 0.5px solid var(--color-border-soft);
  cursor: cell;
}

.cal-mcell:nth-child(7n) {
  border-right: none;
}

.cal-mcell.other {
  background: rgba(247, 241, 231, 0.55);
}

.cal-mcell.other .cal-mnum {
  color: var(--color-muted);
  opacity: 0.6;
}

.cal-mnum {
  align-self: flex-start;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 4px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.cal-mnum:hover {
  background: var(--color-primary-soft);
}

.cal-mcell.today .cal-mnum {
  background: var(--color-primary);
  color: #ffffff;
}

.cal-mlist {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.cal-more {
  align-self: flex-start;
  padding: 2px 6px;
  border: none;
  background: transparent;
  color: var(--color-accent-text);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

/* ---- criar ---- */

.cal-create {
  width: 400px;
}

.cal-kind {
  display: flex;
  margin-bottom: 16px;
}

.cal-kind button {
  flex: 1;
}

.cal-create-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ---- Configurações: integrações ---- */

.integration-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.integration-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.integration-info strong {
  font-size: 14px;
}

.integration-info span {
  font-size: 12px;
  color: var(--color-muted);
}

button:disabled.btn {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .cal-view {
    padding: 12px 16px 24px;
    overflow: visible;
  }

  .cal-body {
    height: 72vh;
    min-height: 420px;
    flex: none;
  }

  .cal-title {
    font-size: 16px;
    white-space: normal;
  }

  .cal-hint {
    display: none;
  }
}

/* ===== Blocos da rotina (faixas por trás das tarefas) ===== */
.cal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cal-actions .btn {
  padding: 8px 14px;
  font-size: 12.5px;
}

.cal-band {
  position: absolute;
  left: 2px;
  right: 2px;
  z-index: 1;
  border-left: 3px solid var(--c);
  border-radius: 8px;
  background: color-mix(in srgb, var(--c) 13%, transparent);
  pointer-events: none;
  overflow: hidden;
}

.cal-band-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
  padding: 2px 8px;
  font-size: 10.5px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--c);
  white-space: nowrap;
  overflow: hidden;
  pointer-events: auto;
  cursor: grab;
}

.cal-band-head span {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* o horário só aparece se sobrar espaço depois do nome */
.cal-band-head small {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  font-size: 9.5px;
  font-weight: 500;
  opacity: 0.8;
}

.cal-band-head:hover {
  background: color-mix(in srgb, var(--c) 16%, transparent);
}

.cal-band-head:active {
  cursor: grabbing;
}

.cal-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  flex-shrink: 0;
}

.cal-toggle {
  padding: 5px 12px;
  border: 0.5px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.cal-toggle.on {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* Resumo de horas por categoria */
.rs-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rs-tile {
  --c: var(--color-muted);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 0.5px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  font-size: 12px;
  color: var(--color-muted);
}

.rs-tile i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
}

.rs-tile strong {
  font-size: 13px;
  color: var(--color-text);
}

.rs-tile.free i {
  background: transparent;
  border: 1.5px dashed var(--color-muted);
}

.rs-tiles.compact .rs-tile {
  padding: 5px 10px;
  font-size: 11px;
}

/* ===== Assistente "Montar minha rotina" ===== */
.wizard {
  width: 560px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 32px);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
}

.wizard-bar {
  height: 4px;
  background: var(--color-border-soft);
}

.wizard-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--color-accent);
  transition: width 0.25s;
}

.wizard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px 0;
}

.wizard-count {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--color-accent-text);
}

.wizard-title {
  padding: 6px 24px 0;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
}

.wizard-sub {
  padding: 4px 24px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-muted);
}

.wizard-body {
  flex: 1;
  min-height: 0;
  padding: 16px 24px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wizard-error {
  margin: 0 24px 6px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--color-danger-soft);
  color: var(--color-danger);
  font-size: 12.5px;
  font-weight: 500;
}

.wizard-foot {
  display: flex;
  gap: 10px;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--color-border-soft);
}

.wizard-foot .btn {
  padding: 11px 18px;
}

.wizard-foot .btn-primary {
  flex: 1;
}

.ws-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.ws-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.ws-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
}

.ws-row > .ws-field {
  flex: 1 1 180px;
}

.ws-time {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.ws-time button {
  width: 40px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 18px;
  font-family: inherit;
  cursor: pointer;
}

.ws-time button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.ws-time input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
}

.ws-time input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.ws-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ws-chip {
  padding: 9px 14px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.ws-chip:hover {
  border-color: var(--color-primary);
}

.ws-chip.active {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-accent-text);
  font-weight: 700;
}

.ws-chips.days .ws-chip {
  min-width: 46px;
  padding: 9px 8px;
  text-align: center;
}

.ws-hint {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-olive);
}

.ws-hint.warn {
  color: var(--color-danger);
}

.ws-meal {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--color-border-soft);
  border-radius: 14px;
  background: var(--color-chip);
}

.ws-meal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.ws-meal-head .ws-chip {
  padding: 6px 12px;
  font-size: 12px;
}

.ws-notes {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--color-muted);
}

.ws-notes b {
  color: var(--color-text);
}

.ws-notes .replace {
  color: var(--color-accent-text);
  font-weight: 600;
}

/* Prévia da semana montada */
.rs-preview {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.rs-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rs-dow {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--color-muted);
}

.rs-track {
  position: relative;
  height: 220px;
  border: 1px solid var(--color-border-soft);
  border-radius: 8px;
  background: var(--color-chip);
  overflow: hidden;
}

.rs-track i {
  position: absolute;
  left: 0;
  right: 0;
  opacity: 0.92;
}

/* Editor de bloco */
.block-modal {
  width: 400px;
}

.block-actions {
  align-items: center;
}

@media (max-width: 700px) {
  .wizard-head,
  .wizard-title,
  .wizard-sub,
  .wizard-body,
  .wizard-foot {
    padding-left: 18px;
    padding-right: 18px;
  }

  .wizard-error {
    margin-left: 18px;
    margin-right: 18px;
  }

  .wizard-title {
    font-size: 21px;
  }

  .ws-chip {
    padding: 8px 11px;
    font-size: 12.5px;
  }

  .rs-track {
    height: 170px;
  }

  .cal-actions {
    width: 100%;
  }

  .cal-actions .btn {
    flex: 1;
  }

  .block-modal {
    width: calc(100vw - 24px);
  }
}
