/* === GLOBAL RESETS === */
* {
  box-sizing: border-box;
  max-width: 100%;
}

body {
  font-family: system-ui, sans-serif;
  margin: 0;
  background: #f6f6f6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  color: #222;
  overflow-x: hidden;
}

header {
  text-align: center;
  padding: 1rem 0;
}

.logo {
  width: 120px;
  height: auto;
  max-width: 80vw;
}

/* === MAIN === */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1.5rem;
  gap: 2rem;
}

/* === CARDS === */
.card {
  background: white;
  padding: 2rem 1.5rem;
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  text-align: center;
  max-width: 500px;
  width: 100%;
  overflow-wrap: break-word;
}

h2 {
  margin-top: 0;
  color: #004d38;
}

.note {
  color: #555;
  margin-bottom: 1.5rem;
}

/* === SEARCH === */
#searchInput {
  width: 100%;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  margin-top: 0.5rem;
  text-align: center;
  display: block;
}

#searchResults {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  text-align: left;
  overflow-wrap: break-word;
}

#searchResults li {
  padding: 0.5rem;
  border-bottom: 1px solid #eee;
}

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

/* === UPLOAD BOX === */
.center-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed #bbb;
  border-radius: 14px;
  padding: 2.5rem;
  text-align: center;
  background: #fafafa;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 0 auto 1.5rem;
  max-width: 320px;
  position: relative;
}

.center-upload:hover {
  border-color: #008060;
  background: #f3fbf6;
}

.center-upload.dragover {
  border-color: #008060;
  background: #e9f8f1;
}

.center-upload p {
  margin: 0.75rem 0 0;
  color: #444;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
}

.upload-icon {
  width: 56px;
  height: 56px;
  opacity: 0.8;
  pointer-events: none;
}

.center-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* === TABLE === */
.hidden {
  display: none;
}

.table-wrapper {
  position: relative;
  max-height: 400px;
  overflow: hidden;
  margin-top: 1rem;
}

.table-wrapper::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(to bottom, transparent, white);
  pointer-events: none;
}

#outputTable {
  width: 100%;
  border-collapse: collapse;
  word-break: break-word;
}

#outputTable th,
#outputTable td {
  border: 1px solid #ddd;
  padding: 8px;
}

#outputTable th {
  background: #e6f7ef;
  color: #004d38;
  text-align: center;
}

/* === BUTTONS === */
button.green {
  background: #008060;
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  margin-top: 1rem;
  transition: background 0.2s ease;
}

button.green:hover {
  background: #00694e;
}

/* === FOOTER === */
footer {
  text-align: center;
  padding: 0.75rem 0;
  font-size: 0.9rem;
  color: #555;
}

footer a {
  color: #007e61;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* === ANIMATIONS === */
.fade-in {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeUp 0.7s ease forwards;
}

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

/* === RESPONSIVE === */
@media (max-width: 600px) {
  main {
    padding: 1rem;
    gap: 1.5rem;
  }

  .card {
    padding: 1.5rem 1rem;
    max-width: 90vw;
  }

  #searchInput {
    font-size: 0.95rem;
  }

  .upload-icon {
    width: 48px;
  }
}

/* === PRINT STYLES === */
@media print {
  /* Hide everything except the output table */
  header,
  footer,
  .card:first-of-type,
  .drop-zone,
  .note,
  h2,
  #downloadBtn,
  #printBtn {
    display: none !important;
  }

  body {
    background: white;
    margin: 0;
    padding: 0;
  }

  main {
    padding: 0;
    margin: 0;
  }

  .card {
    box-shadow: none;
    padding: 0;
    margin: 0;
    max-width: 100%;
  }

  #outputTableContainer {
    display: block !important;
    margin: 0;
    padding: 0;
  }

  /* Remove height restriction and fade for printing */
  .table-wrapper {
    max-height: none !important;
    overflow: visible !important;
  }

  .table-wrapper::after {
    display: none !important;
  }

  #outputTable {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    page-break-inside: auto;
  }

  #outputTable tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  #outputTable thead {
    display: table-header-group;
  }

  #outputTable th,
  #outputTable td {
    border: 1px solid #333;
    padding: 8px;
    font-size: 12pt;
  }

  #outputTable th {
    background: #e6f7ef !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
