:root {
  --app-theme: #f7fafc;
}

html,
body {
  background: var(--app-theme);
}

.error {
  background-color: rgba(239, 68, 68, 0.9);
  color: #fff;
}

.custom-select {
  position: relative;
}
.custom-select .options {
  display: none;
  position: absolute;
  background-color: white;
  max-height: 200px;
  overflow-y: auto;
  border-radius: 6px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  width: 100%;
}
.custom-select .option {
  padding: 8px 12px;
  cursor: pointer;
}
.custom-select .option:hover {
  background-color: #f3f4f6;
}

.dropdown {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06);
  z-index: 9999;
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  color: var(--text);
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #d1d5db #f3f4f6;
}
.dropdown::-webkit-scrollbar {
  width: 6px;
}
.dropdown::-webkit-scrollbar-track {
  background: #f3f4f6;
}
.dropdown::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 3px;
}
.dropdown-option {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: all 0.12s ease;
  color: var(--text);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
  text-align: center;
}
.dropdown-option:hover {
  background: #f3f4f6;
}
.dropdown-option.disabled {
  color: var(--muted);
  cursor: default;
}
.dropdown-option.active {
  background-color: var(--bg);
  color: var(--text);
}
.dropdown-option:first-child {
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}
.dropdown-option:last-child {
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
}

#capture-area {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px;
  margin-bottom: 8px !important;
}
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0 !important;
}
#site-footer {
  margin-top: 60px;
  text-align: center;
  color: var(--muted);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.offscreen-textarea {
  position: fixed !important;
}

.error {
  background-color: rgba(239, 68, 68, 0.9);
  color: #fff;
}

input[type="text"],
input[type="search"],
select,
textarea,
.custom-select {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1.5px solid var(--border) !important;
  box-shadow: none !important;
  padding: 0.75rem !important;
  border-radius: 0.5rem !important;
}

input:focus,
select:focus,
textarea:focus,
.custom-select:focus-within,
button:focus {
  outline: 3px solid rgba(37, 99, 235, 0.12) !important;
  box-shadow: none !important;
  border-color: var(--primary-600) !important;
}

.input-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 8px;
}

.btn,
button,
.copy-button {
  color: var(--surface) !important;
  background: var(--primary) !important;
  border: 1px solid transparent !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto !important;
  white-space: nowrap;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.55rem 1.25rem !important;
  border-radius: 10px;
  gap: 0.45rem;
  line-height: 1;
  min-height: 44px;
  box-sizing: border-box;
  box-shadow: none;
}

.btn:hover,
button:hover {
  background: var(--primary-600) !important;
}
.btn-accent {
  color: var(--surface) !important;
  background: var(--accent) !important;
}
.btn-danger {
  color: var(--surface) !important;
  background: var(--danger) !important;
}

.btn i,
button i,
.copy-button i {
  margin-right: 0.25rem !important;
}

#reset-btn i,
#cross-check-btn i,
#print-btn i,
#find-btn i,
.print-icon {
  margin-right: 0.5rem !important;
  font-size: 1.15rem !important;
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 1.15rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#footer-controls {
  margin-bottom: 16px;
}

.btn-uppercase {
  text-transform: uppercase !important;
  font-size: 0.88rem !important;
  letter-spacing: 0.04em !important;
  padding-top: 0.2rem !important;
  padding-bottom: 0.2rem !important;
}

.badge-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 18px;
}
.badge {
  background: var(--bg);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: none;
  font-weight: 600;
}
.badge-success {
  display: inline-block;
  background: #059669;
  color: var(--surface);
  padding: 0.125rem 0.375rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
}

.page-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}
.page-row .course-code {
  flex: 1 1 60%;
  padding: 12px 14px;
  font-size: 1rem;
  border-radius: 10px;
  box-shadow: none;
  border: 1.5px solid var(--border);
  background: var(--surface);
  margin-bottom: 0;
  color: var(--text) !important;
  text-align: center !important;
}
.page-row .section {
  flex: 0 0 140px;
  text-align: center;
  padding: 12px 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  margin-bottom: 0;
  color: var(--text) !important;
}
.page-row .add-course {
  display: none !important;
}

.input-row {
  display: flex;
  flex-direction: row;
  width: 100%;
  margin-bottom: 8px;
  gap: 8px;
  align-items: center;
}
.input-row .course-code {
  flex: 2;
}
.input-row .section {
  flex: 1;
}

.input-row input.section,
.page-row input.section {
  height: 44px !important;
  line-height: 44px !important;
  padding: 0 14px !important;
  box-sizing: border-box !important;
  text-align: center !important;
}

.dropdown {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  box-shadow: 0 4px 6 -1px rgba(0, 0, 0, 0.06);
  z-index: 9999;
  max-height: 240px;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  color: var(--text);
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #d1d5db #f3f4f6;
}
.dropdown::-webkit-scrollbar {
  width: 6px;
}
.dropdown::-webkit-scrollbar-track {
  background: #f3f4f6;
}
.dropdown::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 3px;
}
.dropdown-option {
  display: block !important;
  width: 100% !important;
  box-sizing: border-box !important;
  text-align: center !important;
  padding: 0.5rem 0.75rem !important;
  cursor: pointer !important;
  background-color: transparent !important;
  color: var(--text) !important;
  white-space: normal !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  hyphens: auto !important;
}
.dropdown-option:hover {
  background: #f3f4f6;
}
.dropdown-option.disabled {
  color: var(--muted);
  cursor: default;
}
.dropdown-option.active {
  background-color: var(--bg);
  color: var(--text);
}
.dropdown-option:first-child {
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}
.dropdown-option:last-child {
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
}

.routine-table {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
  margin-top: 12px;
  border-radius: 12px;
  overflow: visible;
  border: 1.5px solid var(--border);
}
.routine-table th,
.routine-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;

  white-space: nowrap;
}
.routine-table thead th {
  background: transparent;
  color: var(--text);
  font-weight: 700;
}

.routine-table th.text-center,
.routine-table td.text-center {
  text-align: center;
}
.cell-with-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.action-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.row-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--danger, #dc2626);
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 140ms ease;
  width: 34px;
  height: 34px;
}
.row-remove-btn i {
  font-size: 1rem;
}
.row-remove-btn.danger {
  border-color: transparent;
  background: transparent;
}
.row-remove-btn:hover {
  transform: translateY(-1px);
  background: transparent;
}
.row-remove-btn:focus {
  outline: 3px solid rgba(220, 38, 38, 0.12);
}

.row-remove-label {
  display: none !important;
}

@media (min-width: 720px) {
  .row-remove-label {
    display: none !important;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .dropdown-enter {
    opacity: 0;
    transform: translateY(-6px);
    animation: ddEnter 220ms ease forwards;
  }
  @keyframes ddEnter {
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}
@media (prefers-reduced-motion: reduce) {
  .dropdown-enter {
    transition: none !important;
  }
}

.auto-added,
.mt-4.text-center,
.auto-search-pulse,
.confirm-banner,
.temp-tooltip {
  animation: none !important;
  transition: none !important;
  transform: none !important;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.985);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}
@keyframes modalFadeOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translateY(-6px) scale(0.985);
    filter: blur(2px);
  }
}
.modal-show {
  animation: modalFadeIn 220ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.modal-hide {
  animation: modalFadeOut 180ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

#print-modal.hidden {
  display: none;
}
#print-modal {
  display: flex;
  align-items: center;
  justify-content: center;
}

#print-modal > div {
  box-shadow: 0 20px 50px rgba(2, 6, 23, 0.28);
  border-radius: 12px;
  max-width: 880px;
  width: 95%;
}

body.modal-open::before {
  content: none;
  position: static;
  pointer-events: none;
}

.print-modal-content {
  text-align: center;
  padding: 8px 6px;
}
.print-modal-content .printable-cloned-table {
  margin: 0 auto;
  text-align: left;
  max-width: 100%;
}
.print-modal-content h2 {
  text-align: center;
  margin-bottom: 10px;
  font-size: 1.05rem;
}
.print-modal-content p {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--muted);
}

#print-modal .printable-cloned-table thead th:last-child,
#print-modal .printable-cloned-table tbody td:last-child,
#print-modal .printable-cloned-table tfoot td:last-child {
  display: none;
}
#print-modal .printable-cloned-table .action-cell,
#print-modal .printable-cloned-table .row-remove-btn,
#print-modal .printable-cloned-table .row-remove-btn * {
  display: none !important;
}
.dropdown-option,
.btn,
button {
  transition: none !important;
}
.text-dark {
  color: var(--text) !important;
}

.totals-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, auto));
  gap: 28px;
  justify-content: center;
  align-items: center;
  justify-items: center;
  place-items: center;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}
.totals-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.totals-item .totals-btn {
  min-width: 84px;
  padding: 8px 14px !important;
  font-size: 1rem !important;
  border-radius: 10px !important;
}
.totals-btn {
  background: transparent !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  padding: 6px 10px !important;
  font-weight: 700 !important;
  border-radius: 8px !important;
  min-width: auto !important;
  box-shadow: none !important;
}
.totals-btn {
  background: transparent !important;
  color: #2563eb !important;
  border: 1.5px solid #2563eb !important;
  box-shadow: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  pointer-events: auto !important;
  z-index: 2 !important;
}
.totals-btn:hover {
  background: rgba(37, 99, 235, 0.06) !important;
  border-color: rgba(37, 99, 235, 0.9) !important;
}
.totals-item .text-sm {
  text-align: center;
  color: #1e3a8a;
  font-weight: 700;
}
@media (max-width: 520px) {
  .totals-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

body.modal-open .totals-row {
  visibility: hidden !important;
  pointer-events: none !important;
}

#summary-search {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1.5px solid var(--border) !important;
  padding: 0.45rem 0.65rem !important;
  border-radius: 0.5rem !important;
  box-shadow: none !important;

  width: clamp(90px, 20vw, 160px) !important;
  max-width: 100%;
  box-sizing: border-box !important;
}

.summary-search-inline {
  width: clamp(80px, 18vw, 140px) !important;
  box-sizing: border-box !important;
}
#summary-search:focus {
  outline: 3px solid rgba(37, 99, 235, 0.12) !important;
  border-color: var(--primary-600) !important;
}

.summary-item {
  transition:
    box-shadow 140ms ease,
    transform 100ms ease,
    background-color 120ms ease;
  outline: none;
}

.summary-item:hover {
  background: rgba(37, 99, 235, 0.02);
}

.summary-item:focus {
  outline: none;

  position: relative;
  z-index: 3;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.18);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.04);
  border-radius: 8px;
}

.summary-item:active {
  transform: translateY(1px);
  background: rgba(37, 99, 235, 0.04);
}

#summary-modal .summary-close {
  z-index: 60;
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.06);
  color: #ef4444;
  padding: 8px;
  border-radius: 6px;
}

@media (max-width: 640px) {
  #summary-search {
    width: clamp(80px, 32vw, 120px) !important;
    box-sizing: border-box !important;
    margin-bottom: 0;
    padding: 0.35rem 0.5rem !important;
  }
  .summary-search-inline {
    width: clamp(70px, 36vw, 100px) !important;
  }
  #summary-modal .summary-close {
    transform: translateZ(0);
    padding: 6px !important;
    min-width: 36px !important;
  }
}

#cross-check-btn {
  background: #10b981 !important;
  color: #ffffff !important;
  border: 1px solid transparent !important;
}
#cross-check-btn:hover {
  background: #059669 !important;
}
#cross-check-btn:focus {
  outline: 3px solid rgba(5, 150, 105, 0.18) !important;
  outline-offset: 2px !important;
}

#cross-check-modal,
#cross-check-modal #pdf-container {
  color: #0f172a !important;
}
#cross-check-modal #pdf-container .text-white {
  color: #0f172a !important;
}
#cross-check-modal #pdf-container .text-gray-300 {
  color: #6b7280 !important;
}
#cross-check-modal #pdf-container .text-gray-400 {
  color: #9ca3af !important;
}
#cross-check-modal #pdf-container .bg-green-700,
#cross-check-modal #pdf-container .bg-green-700 * {
  color: #ffffff !important;
}

@media (max-width: 640px) {
  input,
  button,
  select {
    font-size: 16px;
    height: 44px;
  }
  .table-container {
    margin: 0 -16px;
  }
  .floating-search,
  .copy-button,
  #site-footer {
    position: static !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    z-index: auto !important;
  }
  button,
  .copy-button {
    width: 100%;
    display: block;
    margin-bottom: 0.5rem;
  }
  .dropdown {
    position: absolute !important;
    z-index: 22000 !important;
    max-height: 48vh !important;
  }
  .dropdown-option {
    padding: 1rem !important;
    font-size: 1.05rem !important;
  }
  #reset-btn,
  #cross-check-btn {
    height: 48px !important;
    padding: 12px 20px !important;
    border-radius: 12px !important;
    font-size: 1.125rem !important;
    line-height: 1 !important;
  }

  .page-row {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  .page-row .course-code,
  .page-row .section,
  .page-row .add-course {
    flex: none;
    width: 100% !important;
    min-width: 0;
  }
  .page-row .section {
    text-align: left;
  }
  .page-row .add-course {
    display: flex;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .totals-row {
    grid-template-columns: repeat(3, minmax(0, 120px));
    gap: 12px;
    overflow-x: auto;
    padding: 6px 8px;
    justify-content: center;
  }
  .totals-row .totals-btn {
    width: auto !important;
    min-width: 84px !important;
    padding: 8px 12px !important;
  }
}

@media (max-width: 420px) {
  .totals-row {
    grid-template-columns: repeat(3, minmax(0, 120px));
    gap: 10px;
  }
}

@media (min-width: 641px) {
  #reset-btn,
  #cross-check-btn,
  #print-btn {
    width: auto !important;
    min-width: 0 !important;
    height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    box-sizing: border-box !important;
  }
  #reset-btn i,
  #cross-check-btn i,
  #print-btn i {
    display: inline-block;
    vertical-align: middle;
  }
}

@media (min-width: 641px) {
  #reset-btn,
  #cross-check-btn,
  #print-btn {
    width: 160px !important;
    min-width: 160px !important;
  }
}

.temp-tooltip {
  position: absolute;
  background: rgba(15, 23, 42, 0.95);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  z-index: 9999;
  pointer-events: none;
  opacity: 1;
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

#pdf-fullscreen-modal {
  opacity: 1 !important;
  animation: none !important;
}
#pdf-fullscreen-img {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: none;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
#reset-zoom-btn {
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 4px;
  padding: 8px 16px;
  cursor: pointer;
  z-index: 2001;
  font-size: 1rem;
  transition: background 0.1s;
}
#reset-zoom-btn:hover {
  background: transparent;
}
