:root {
  --bg: #ffffff;
  --fg: #000000;
  --gray: #f3f3f3;
}

*{
  box-sizing: border-box;
  font-family: "Inter", sans-serif;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
}

.view {
  display: none;
  min-height: 100vh;
  padding: 30px;
}

.view.active{
  display: flex;
  flex-direction: column;
}

#home header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

#home header button {
  padding: 10px 18px;
  background: #000;
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

#sortBar{
  margin-bottom: 20px;
}

#sortBar select {
  padding: 6px 10px;
  border: 1px solid #000;
  background: #fff;
  font-weight: 600;
}

#scheduleList {
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(220px,1fr));
  gap: 15px;
}

.schedule-card {
  border: 2px solid #000;
  padding: 14px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  position: relative;
}

.schedule-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  background: #f5f5f5;
}

.schedule-card h3 {
  margin: 0;
  font-size: 16px;
}

.schedule-card span {
  font-size: 12px;
  color: #444;
}

.card-actions{
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
}

.card-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
}

.card-actions button img {
  width: 18px;
  height: 18px;
  display: block;
}

.subject-count {
  display: block;
  margin-top: 6px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.2);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 3px;
  width: fit-content;
}

.subject-info {
  position: absolute;
  font-size: 10px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.15);
  padding: 2px 6px;
  border-radius: 3px;
  line-height: 1;
}

.subject-credits {
  top: 4px;
  right: 4px;
}

.subject-group {
  top: 4px;
  left: 4px;
}

.subject-program {
  position: relative;
  font-size: 11px;
  margin-top: 4px;
  font-weight: 400;
  background: rgba(0, 0, 0, 0.2);
  padding: 3px 8px;
  border-radius: 4px;
}

.input-with-checkbox {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-with-checkbox input[type="text"],
.input-with-checkbox input[type="number"] {
  flex: 1;
}

.input-with-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

#app header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

#app header button {
  padding: 6px 15px;
  border: 1px solid #000;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

.actions button {
  padding: 8px 16px;
  background: #000;
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th, td{
  border: 1px solid #000;
  text-align: center;
  font-size: 14px;
}

th {
  background: #000;
  color: #fff;
  padding: 6px;
}

.time {
  font-weight: 600;
  background: #f4f4f4;
  padding: 6px;
}

.cell {
  cursor: pointer;
  position: relative;
  height: 60px;
  padding: 0;
  transition: background-color .15s ease, box-shadow .15s ease, transform .1s ease;
  overflow: visible;
}

.cell:active {
  transform: scale(0.97);
}

.cell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
  z-index: 1;
}

.cell:hover::before {
  background:rgba(0,0,0,0.1);
  box-shadow: inset 0 0 0 3px rgba(0,0,0,0.35);
  z-index: 1;
}

.cell.blocked {
  border-top:none;
  pointer-events:none;
  background:transparent;
}

.cell.blocked::before,
.cell.blocked::after {
  display:none !important;
}

.cell:hover::after {
  content:"+";
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%, -50%);
  font-weight:bold;
  font-size:22px;
  color:rgba(0,0,0,.4);
}

.cell:has(.subject):hover::after {
  content: "";
}

.cell.blocked:hover::after {
  content:"";
}

.cell .subject{
  pointer-events:auto;
  z-index:10;
}

.cell::before{
  z-index:1;
}

.subject { 
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  border-radius: 6px;
  color:white;
  z-index: 10;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  transform-origin: center center;
  will-change: transform;
  transition:
    height .15s ease,
    top .15s ease,
    transform .15s ease,
    opacity .15s ease,
    box-shadow .15s ease;
}

.subject:hover {
  transform: scale(1.03);
}

.subject-hover {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.subject-content {
  margin: 4px;
  border-radius: 6px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
  font-weight: bold;
}

.modal {
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.5);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:50;
}

.modal.active {
  display:flex;
}

#monthlyDetailModal {
  background: transparent;
}

#monthlyDetailContent ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#monthlyDetailContent li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #e6e6e6;
}

#monthlyDetailContent li:last-child {
  border-bottom: none;
}

#monthlyDetailContent .day-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#monthlyDetailContent .day-date {
  font-size: 12px;
  color: #666;
}

#monthlyDetailContent .trip-info {
  text-align: right;
}

#monthlyDetailContent .trip-count {
  font-weight: 600;
  color: #000;
}

#monthlyDetailContent .gap-flag {
  display: inline-block;
  background: #ffe6e6;
  color: #b00020;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}

.modal-content{
  background:#fff;
  border:2px solid #000;
  padding:20px 20px 24px 20px;
  width:320px;
  max-height: 90vh;
  position:relative;
  animation: modalIn .2s ease-out;
  overflow-y: auto;
  overflow-x: visible;
}

#dailyDetailModal .modal-content {
  width: 520px;
  max-width: 95vw;
  position: relative;
  padding: 60px 20px 20px 20px;
  overflow-x: hidden;
  overflow-y: auto;
}

#dailyDetailModal #backToResultBtn {
  position: absolute;
  top: 20px;
  left: 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 28px;
  padding: 0;
  margin: 0;
  line-height: 1;
  color: #000;
  width: 30px;
  height: 30px;
  display: block;
  z-index: 10;
}

#dailyDetailModal h3 {
  position: absolute;
  top: 20px;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  line-height: 30px;
  pointer-events: none;
  padding: 0;
}

#monthlyModal .modal-content {
  width: 480px;
  max-width: 95vw;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
}

.input-group label {
  margin-bottom: 4px;
}

.input-group input,
.input-group select {
  width: 100%;
}

@keyframes modalIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }

  to {
    transform: scale(1.0);
    opacity: 1;
  }
}

.modal-content h3{
  margin:0 0 10px 0;
}

.modal-content input,
.modal-content select{
  width:100%;
  padding:8px;
  border:1px solid #000;
  margin-top:4px;
}

.modal-content button{
  width:100%;
  padding:8px;
  background:#000;
  color:#fff;
  border:none;
  cursor:pointer;
  font-weight:600;
  margin-top:12px;
}

.close-btn{
  position:absolute;
  top:8px;
  right:12px;
  font-size:20px;
  font-weight:700;
  cursor:pointer;
  color:#000;
  user-select:none;
}

.close-btn:hover{
  color:#555;
}

.modal-content h3{
  padding-right:35px;
}

@keyframes ghostpulse {
  from { opacity: 0.25; }

  to { opacity: 0.45;}
}

.ghost-subject{
  position:absolute;
  inset:4px;
  border-radius:6px;
  opacity:0.4;
  pointer-events:none;
  animation: ghostpulse 1s infinite alternate;
}

.input-error{
  border:2px solid #b00020 !important;
  background:#ffecec;
}

.error-text{
  color:#b00020;
  font-size:12px;
  margin-top:4px;
}

button:disabled{
  background:#999 !important;
  cursor:not-allowed;
  opacity:0.6;
}

.changelog-panel{
  position: fixed;
  top: 0;
  right: -360px;
  width: 360px;
  height: 100%;
  background: #ffffff;
  box-shadow: -4px 0 10px rgba(0,0,0,0.2);
  transition: right 0.3s ease;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  font-family: inherit;
}

.changelog-panel.open{
  right: 0;
}

.changelog-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #1e1e2f;
  color: white;
}

.changelog-header h2{
  margin: 0;
  font-size: 18px;
}

.changelog-header button{
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
}

.changelog-content{
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}
.changelog-entry{
  border:1px solid #000;
  padding:12px;
  margin-bottom:12px;
  background:#f9f9f9;
}

.changelog-entry h3{
  margin:0 0 6px 0;
  font-size:15px;
}

.changelog-entry ul{
  margin:6px 0;
  padding-left:18px;
}

.changelog-entry li{
  font-size:13px;
  margin-bottom:4px;
}

.changelog-entry .date{
  font-size:12px;
  color:#444;
  margin-top:6px;
  font-weight:600;
}

.jornada-header {
  background: #000;
  color: #fff;
  font-weight: 700;
  text-align: center;
  font-size: 14px;
  letter-spacing: 1px;
}

.cell.active-root {
  position: relative;
  z-index: 3;
}

.cell.active-root::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--active-height);
  outline: 3px solid #46E563;
  outline-offset: -2px;
  background-color: rgba(70, 229, 99, 0.15);
  pointer-events: none;
  z-index: 20;
}

.aguinaldo-details {
  margin-top: 10px;
}

.aguinaldo-details ul {
  margin: 8px 0 0 18px;
  padding: 0;
}

.aguinaldo-details li {
  margin-bottom: 4px;
}

.gap-flag {
  color: #c0392b;
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
  background: #ffe6e6;
  padding: 2px 6px;
  border-radius: 4px;
}

.aguinaldo-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.aguinaldo-main {
  flex: 1;
  min-width: 220px;
}

.aguinaldo-side {
  width: 260px;
}

.aguinaldo-details {
  margin-top: 0;
}

.aguinaldo-details summary {
  cursor: pointer;
}

.monthly-detail-panel {
  width: 100%;
  max-height: 300px;
  background: #f9f9f9;
  color: #111;
  padding: 14px;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-top: 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.monthly-detail-panel.hidden {
  display: none;
}

.monthly-detail-panel ul {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}

.monthly-detail-panel li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  font-size: 14px;
  border-bottom: 1px solid #e6e6e6;
}

.monthly-detail-panel li:last-child {
  border-bottom: none;
}

.monthly-detail-panel .day-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.monthly-detail-panel .day-date {
  font-size: 12px;
  color: #666;
}

.monthly-detail-panel .trip-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}

.monthly-detail-panel .trip-count {
  font-weight: 600;
  color: #000;
}

.aguinaldo-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  cursor: pointer;
  user-select: none;
}

.aguinaldo-switch input {
  display: none;
}

.aguinaldo-switch .slider {
  width: 42px;
  height: 22px;
  background: #ccc;
  border-radius: 22px;
  position: relative;
  transition: background .2s;
}

.aguinaldo-switch .slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 2px;
  left: 2px;
  background: white;
  border-radius: 50%;
  transition: transform .2s;
}

.aguinaldo-switch input:checked + .slider {
  background: #4caf50;
}

.aguinaldo-switch input:checked + .slider::before {
  transform: translateX(20px);
}

.aguinaldo-switch .label-text {
  font-size: 14px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ddd;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.15s ease;
  user-select: none;
  min-height: 50px;
}

.calendar-day:hover:not(.calendar-day-disabled) {
  background: #f0f0f0;
  transform: scale(1.05);
}

.calendar-day-disabled {
  background: #f9f9f9;
  color: #ccc;
  cursor: not-allowed;
}

.calendar-day-holiday {
  background: #ffebee;
  color: #c62828;
  font-weight: 600;
  cursor: not-allowed;
}

.calendar-day-holyweek {
  background: #f3e5f5;
  color: #7b1fa2;
  font-weight: 600;
  cursor: not-allowed;
}

.calendar-day-excluded {
  background: #fff9c4;
  color: #f57f17;
  font-weight: 600;
  border: 2px solid #f57f17;
}

.calendar-day-header {
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  color: #666;
  padding: 4px 0;
}

#excludeDaysModal {
  background: transparent;
}

#dailyDetailModal {
  background: transparent;
}

#excludeDaysModal .modal-content {
  width: 520px;
  max-width: 95vw;
  position: relative;
  padding: 20px;
  overflow-x: hidden;
}

#excludeDaysModal #backToAguinaldoBtn {
  position: absolute;
  top: 20px;
  left: 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 28px;
  padding: 0;
  margin: 0;
  line-height: 1;
  color: #000;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#excludeDaysModal .calendar-header {
  position: relative;
  margin-bottom: 20px;
}

#excludeDaysModal .calendar-header-content {
  text-align: center;
}

#excludeDaysModal .calendar-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  padding: 0;
}

#excludeDaysModal #excludeDaysCount {
  color: #666;
  font-size: 13px;
  margin-top: 4px;
  display: block;
}

#excludeDaysModal #calendarGrid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

#excludeDaysModal .calendar-legend {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: #666;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 4px;
  justify-content: center;
  margin-bottom: 12px;
}

#excludeDaysModal .legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

#excludeDaysModal .legend-box-festivos {
  width: 16px;
  height: 16px;
  background: #ffb5C0;
  border: 1px solid #d32f2f;
}

#excludeDaysModal .legend-box-excluidos {
  width: 16px;
  height: 16px;
  background: #fff9c4;
  border: 2px solid #f57f17;
}

#excludeDaysModal .calendar-note {
  color: #666;
  display: block;
  text-align: center;
  font-size: 13px;
}

#excludeDaysModal .legend-box-holyweek {
  width: 16px;
  height: 16px;
  background: #f3e5f5;
  border: 1px solid #7b1fa2;
}

#monthlyResult {
  margin-top: 12px;
  border-top: 1px solid #000;
  padding-top: 10px;
  display: none;
  position: relative;
}

#viewDailyDetailBtn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: #000;
  text-decoration: underline;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Calendar Button */
#openCalendarBtn {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  height: 38px;
  width: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#openCalendarBtn img {
  width: 24px;
  height: 24px;
}

/* Duplicate Bar */
#duplicateBar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #0066cc;
  color: white;
  padding: 8px 12px;
  font-weight: 600;
  display: none;
  z-index: 100;
  justify-content: space-between;
  align-items: center;
}

#cancelDuplicateBtn {
  background: #fff;
  color: #0066cc;
  border: none;
  padding: 4px 8px;
  font-weight: 600;
  cursor: pointer;
}

#changelogAlert {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #b00020;
  color: white;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 11px;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

#dailyDetailModal {
  background: transparent;
}

#openCalendarBtn {
  transition: transform 0.15s ease;
}

#openCalendarBtn:hover {
  transform: scale(1.1);
}

#openCalendarBtn:active {
  transform: scale(0.98);
}
