:root {
  color-scheme: light;
  --bg: #f8fafc;
  --text: #0f172a;
  --muted: #334155;
  --muted-2: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-ring: rgba(37, 99, 235, 0.22);
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --card-bg: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  min-height: 100vh;
}

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 24px 44px;
}

.header h1 {
  margin: 0 0 8px 0;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0 0 18px 0;
  color: var(--muted-2);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(6px);
  margin-bottom: 18px;
}

.toolbarLeft {
  display: flex;
  gap: 10px;
  align-items: center;
}

.toolbarRight {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.hint {
  color: var(--muted-2);
  font-size: 12.5px;
  line-height: 1.35;
  max-width: 520px;
  text-align: right;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 650;
  background: var(--card-bg);
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  user-select: none;
}

.btnIcon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.08);
}

.btn:active {
  transform: translateY(0);
}

.btnPrimary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btnPrimary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btnOutline {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.7);
  color: var(--text);
}

.btnOutline:hover {
  border-color: rgba(37, 99, 235, 0.35);
}

.cardsList {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.episodesSection {
  margin-top: 18px;
}

.seasonsWrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 400px; /* Altura máxima para el contenedor */
  overflow-y: auto; /* Scroll vertical cuando sea necesario */
  padding-right: 8px; /* Espacio para el scrollbar */
}

.seasonHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.seasonTitle {
  font-size: 13px;
  font-weight: 750;
  color: var(--text);
  letter-spacing: -0.01em;
}

.seasonMeta {
  font-size: 12px;
  color: var(--muted-2);
}

.titlesWrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.episodesValidation {
  font-size: 12.5px;
  color: var(--muted-2);
  margin-top: 2px;
}

.episodesValidation.bad {
  color: #b91c1c;
}

.episodePicker {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.7);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  user-select: none;
  cursor: default;
}

.episodePicker:focus-within {
  border-color: rgba(37, 99, 235, 0.65);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.episodeChip {
  flex: 0 0 auto;
  min-width: 44px;
  height: 34px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: #fff;
  color: var(--text);
  font-weight: 650;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: start;
  transition: all 0.2s ease;
}

.episodeChip:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.08);
}

.episodeChip.selected {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.55);
  color: #1d4ed8;
}

.episodeChip.custom:not(.selected) {
  border-style: dashed;
}

.episodePicker.dragging .episodeChip {
  transition: none;
}

.participationsGroups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.participationGroup {
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.65);
  padding: 12px;
}

.participationGroupHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.participationGroupTitle {
  font-weight: 750;
  font-size: 13px;
  color: var(--text);
}

.participationGroupTitle input {
  max-width: 360px;
}

.participationGroupBody {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.workCard {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg);
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.06);
  transition: all 0.3s ease;
  overflow: hidden;
}

.workCard:hover {
  box-shadow: 0 18px 44px rgba(2, 6, 23, 0.08);
}

.workCardEnter {
  animation: cardEnter 0.3s ease both;
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cardHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(255, 255, 255, 1));
}

.cardTitleWrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cardActions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cardTitle {
  font-size: 14px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.cardMeta {
  font-size: 12px;
  color: var(--muted-2);
}

.miniBtn {
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(255, 255, 255, 0.75);
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  font-weight: 650;
  font-size: 13px;
  transition: all 0.3s ease;
}

.miniBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.miniBtn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.08);
}

.miniBtnPrimary {
  border-color: rgba(37, 99, 235, 0.35);
  color: #1d4ed8;
}

.miniBtnPrimary:hover:not(:disabled) {
  border-color: rgba(37, 99, 235, 0.6);
}

.iconBtn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #334155;
  transition: all 0.3s ease;
}

.iconBtn:hover {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.35);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.08);
}

.cardBody {
  padding: 16px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
  max-height: 5000px;
  opacity: 1;
  transition: all 0.3s ease;
}

.workCard.collapsed .cardBody {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
}

.workCard.collapsed .cardHeader {
  border-bottom-color: transparent;
}

.group {
  border: 1px solid rgba(226, 232, 240, 0.8);
  background: rgba(248, 250, 252, 0.6);
  border-radius: 12px;
  padding: 14px 12px 12px;
}

.groupTitle {
  margin: 0 0 12px 0;
  font-size: 12px;
  font-weight: 750;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}

.col1 {
  grid-column: span 1;
}

.col2 {
  grid-column: span 2;
}

.col6 {
  grid-column: span 6;
}

.col4 {
  grid-column: span 4;
}

.col3 {
  grid-column: span 3;
}

.col12 {
  grid-column: span 12;
}

@media (max-width: 980px) {
  .hint {
    display: none;
  }
}

@media (max-width: 820px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbarRight {
    justify-content: flex-start;
  }
  .hint {
    display: block;
    text-align: left;
    max-width: none;
  }
  .col6,
  .col4,
  .col3 {
    grid-column: span 12;
  }
}

input,
select {
  width: 100%;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #fff;
  font-size: 13px;
  transition: all 0.3s ease;
  color: var(--text);
}

input:disabled,
select:disabled {
  background: #f1f5f9;
  color: #64748b;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.65);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
}

.helpText {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted-2);
  line-height: 1.35;
}

.rowActions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* Estilos para autocompletado */
.autocomplete-container {
  position: relative;
}

.autocomplete-input {
  width: 100%;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
  font-size: 13px;
}

.autocomplete-item:hover {
  background-color: #f8f9fa;
}

.autocomplete-item:last-child {
  border-bottom: none;
}
.header h1 {
  margin: 0 0 8px 0;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0 0 18px 0;
  color: var(--muted-2);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(6px);
  margin-bottom: 18px;
}

.toolbarLeft {
  display: flex;
  gap: 10px;
  align-items: center;
}

.toolbarRight {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.hint {
  color: var(--muted-2);
  font-size: 12.5px;
  line-height: 1.35;
  max-width: 520px;
  text-align: right;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 650;
  background: var(--card-bg);
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  user-select: none;
}

.btnIcon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.08);
}

.btn:active {
  transform: translateY(0);
}

.btnPrimary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btnPrimary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btnOutline {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.7);
  color: var(--text);
}

.btnOutline:hover {
  border-color: rgba(37, 99, 235, 0.35);
}

.cardsList {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.episodesSection {
  margin-top: 18px;
}

.seasonsWrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.seasonHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.seasonTitle {
  font-size: 13px;
  font-weight: 750;
  color: var(--text);
  letter-spacing: -0.01em;
}

.seasonMeta {
  font-size: 12px;
  color: var(--muted-2);
}

.titlesWrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.episodesValidation {
  font-size: 12.5px;
  color: var(--muted-2);
  margin-top: 2px;
}

.episodesValidation.bad {
  color: #b91c1c;
}

.episodePicker {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.7);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  user-select: none;
  cursor: default;
}

.episodePicker:focus-within {
  border-color: rgba(37, 99, 235, 0.65);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.episodeChip {
  flex: 0 0 auto;
  min-width: 44px;
  height: 34px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: #fff;
  color: var(--text);
  font-weight: 650;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: start;
  transition: all 0.2s ease;
}

.episodeChip:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.08);
}

.episodeChip.selected {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.55);
  color: #1d4ed8;
}

.episodeChip.custom:not(.selected) {
  border-style: dashed;
}

.episodePicker.dragging .episodeChip {
  transition: none;
}

.participationsGroups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.participationGroup {
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.65);
  padding: 12px;
}

.participationGroupHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.participationGroupTitle {
  font-weight: 750;
  font-size: 13px;
  color: var(--text);
}

.participationGroupTitle input {
  max-width: 360px;
}

.participationGroupBody {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.workCard {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg);
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.06);
  transition: all 0.3s ease;
  overflow: hidden;
}

.workCard:hover {
  box-shadow: 0 18px 44px rgba(2, 6, 23, 0.08);
}

.workCardEnter {
  animation: cardEnter 0.3s ease both;
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cardHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(255, 255, 255, 1));
}

.cardTitleWrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cardActions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cardTitle {
  font-size: 14px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.cardMeta {
  font-size: 12px;
  color: var(--muted-2);
}

.miniBtn {
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(255, 255, 255, 0.75);
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  font-weight: 650;
  font-size: 13px;
  transition: all 0.3s ease;
}

.miniBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.miniBtn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.08);
}

.miniBtnPrimary {
  border-color: rgba(37, 99, 235, 0.35);
  color: #1d4ed8;
}

.miniBtnPrimary:hover:not(:disabled) {
  border-color: rgba(37, 99, 235, 0.6);
}

.iconBtn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #334155;
  transition: all 0.3s ease;
}

.iconBtn:hover {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.35);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.08);
}

.cardBody {
  padding: 16px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
  max-height: 5000px;
  opacity: 1;
  transition: all 0.3s ease;
}

.workCard.collapsed .cardBody {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
}

.workCard.collapsed .cardHeader {
  border-bottom-color: transparent;
}

.group {
  border: 1px solid rgba(226, 232, 240, 0.8);
  background: rgba(248, 250, 252, 0.6);
  border-radius: 12px;
  padding: 14px 12px 12px;
}

.groupTitle {
  margin: 0 0 12px 0;
  font-size: 12px;
  font-weight: 750;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}

.col1 {
  grid-column: span 1;
}

.col2 {
  grid-column: span 2;
}

.col6 {
  grid-column: span 6;
}

.col4 {
  grid-column: span 4;
}

.col3 {
  grid-column: span 3;
}

.col12 {
  grid-column: span 12;
}

@media (max-width: 980px) {
  .hint {
    display: none;
  }
}

@media (max-width: 820px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbarRight {
    justify-content: flex-start;
  }
  .hint {
    display: block;
    text-align: left;
    max-width: none;
  }
  .col6,
  .col4,
  .col3 {
    grid-column: span 12;
  }
}

input,
select {
  width: 100%;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #fff;
  font-size: 13px;
  transition: all 0.3s ease;
  color: var(--text);
}

input:disabled,
select:disabled {
  background: #f1f5f9;
  color: #64748b;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.65);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
}

.helpText {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted-2);
  line-height: 1.35;
}

.rowActions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* Estilos para autocompletado */
.autocomplete-container {
  position: relative;
}

.autocomplete-input {
  width: 100%;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
  font-size: 13px;
}

.autocomplete-item:hover {
  background-color: #f8f9fa;
}

.autocomplete-item:last-child {
  border-bottom: none;
}
