/* --------------------- Reset & Base --------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: #f9f9f9;
  color: #1a1a1a;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --------------------- Hidden utility --------------------- */
.hidden {
  display: none !important;
}

.fade-out {
  opacity: 0;
  transition: opacity 0.6s ease;
}

/* --------------------- Header --------------------- */
.main-header {
  background: linear-gradient(135deg, #1a3e5c 0%, #2c5c8a 100%);
  color: white;
  padding: 10px 20px;
  text-align: center;
}

.header-content h1 {
  font-size: 1rem;
  font-weight: 300;
  font-style: bold;
  margin-bottom: 10px;
}

.header-subtitle {
  font-size: 0.8rem;
  opacity: 0.9;
  max-width: 800px;
  margin: 0 auto;
}

/* --------------------- Main Content --------------------- */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 20px;
}

/* --------------------- Hero Section --------------------- */
.hero-section {
  background: linear-gradient(135deg, #eef3f9 0%, #ffffff 100%);
  border-radius: 15px;
  padding: 10px 20px;
  text-align: center;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.hero-content h1 {
  font-size: 2.2rem;
  color: #1a3e5c;
  margin-bottom: 10px;
  font-weight: 700;
}

/* Format Support Text */
.format-support {
  color: #666;
  font-size: 1rem;
  margin-top: 10px;
  font-weight: 500;
}

/* --------------------- Converter Section --------------------- */
.converter-section {
  background: white;
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
}

/* --------------------- Drop Area --------------------- */
.drop-area {
  border: 3px solid transparent;
  padding: 20px 30px;
  border-radius: 15px;
  background: linear-gradient(white, white) padding-box,
    linear-gradient(135deg, #1a3e5c, #42a5f5) border-box;
  cursor: pointer;
  margin: 0 auto 20px auto;
  transition: all 0.3s ease;
  max-width: 600px;
  text-align: center;
  position: relative;
}

.drop-area.highlight {
  background-color: #eaf6ff;
  border-color: #1976d2;
  box-shadow: 0 10px 30px rgba(25, 118, 210, 0.1);
}

.drop-area.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: linear-gradient(white, white) padding-box,
    linear-gradient(135deg, #ccc, #ddd) border-box;
}

.drop-area.disabled:hover {
  transform: none;
  cursor: not-allowed;
}

.drop-icon {
  font-size: 3rem;
  margin-bottom: 15px;
  opacity: 0.7;
}

.drop-area p {
  font-size: 1.1rem;
  margin-bottom: 10px;
  color: #666;
}

/* Muted text for format hints */
.drop-area p.muted {
  font-size: 0.9rem;
  color: #888;
  margin: 5px 0;
}

.file-label {
  display: inline-block;
  padding: 12px 30px;
  background: #1976d2;
  color: white;
  border-radius: 25px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}

.file-label:hover {
  background: #115293;
  transform: translateY(-2px);
}

.file-label.disabled {
  background: #ccc;
  cursor: not-allowed;
}

.file-label.disabled:hover {
  background: #ccc;
  transform: none;
  cursor: not-allowed;
}

.file-name {
  display: block;
  margin-top: 10px;
  color: #666;
  font-style: italic;
}

.file-name.has-file {
  color: #1a3e5c;
  font-weight: 600;
  font-style: normal;
}

#fileInput {
  display: none;
}

/* --------------------- Action Buttons --------------------- */
.action-buttons {
  text-align: center;
  margin-top: 30px;
  width: 100%;
}

/* --------------------- Download Button --------------------- */
#downloadBtn {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: white;
  border: none;
  padding: 15px 40px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(40, 167, 69, 0.3);
  display: inline-block;
  margin: 0 auto;
}

#downloadBtn:hover {
  background: linear-gradient(135deg, #218838, #1e9e8a);
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(40, 167, 69, 0.4);
}

#downloadBtn:active {
  transform: translateY(-1px);
}

/* --------------------- Security Section --------------------- */
.security-section {
  background: #f8f9fa;
  border-radius: 15px;
  padding: 10px;
  text-align: center;
}

.warning-box {
  background: #fff3cd;
  border: 1px solid #ffeeba;
  border-radius: 10px;
  padding: 25px;
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 15px;
  text-align: left;
}

.warning-icon {
  font-size: 2rem;
  margin-top: 2px;
}

.warning-content strong {
  color: #856404;
  display: block;
  margin-bottom: 8px;
}

.warning-content p {
  color: #856404;
  margin: 0;
}

/* --------------------- Floating Button --------------------- */
.floating-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 1000;
  background: linear-gradient(135deg, #1976d2, #42a5f5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 5px 20px rgba(25, 118, 210, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.floating-btn:hover {
  transform: rotate(20deg) scale(1.1);
  box-shadow: 0 8px 25px rgba(25, 118, 210, 0.4);
}

/* --------------------- Message --------------------- */
#message {
  font-weight: 500;
  margin-top: 10px;
  padding: 8px 0;
  min-height: 20px;
  text-align: center;
  width: 100%;
}

#message.success {
  color: #28a745;
  font-weight: 600;
}

#message.error {
  color: #dc3545;
  font-weight: 600;
}

#message.warning {
  color: #856404;
  font-weight: 600;
}

/* --------------------- Results Container --------------------- */
#resultsContainer {
  margin: 2rem auto;
  max-width: 95%;
  text-align: center;
}

#previewTitle {
  color: #1a3e5c;
  margin-bottom: 15px;
  font-size: 1.5rem;
}

/* --------------------- File Info Section --------------------- */
.file-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 15px;
  justify-content: center;
}

.file-info.hidden {
  display: none;
}

/* File Type Badges */
.file-type-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.file-type-badge.txt {
  background: linear-gradient(135deg, #1976d2, #42a5f5);
  color: white;
}

.file-type-badge.xlsx {
  background: linear-gradient(135deg, #217346, #2e9960);
  color: white;
}

/* Sheet Info */
.sheet-info {
  color: #ec4949;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: pre-line;
}

/* --------------------- Preview Table --------------------- */
#previewTable {
  margin: 0 auto;
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 14px;
  text-align: left;
}

#previewTable th,
#previewTable td {
  border: 1px solid #ddd;
  padding: 8px 10px;
  vertical-align: middle;
}

#previewTable thead tr:first-child th {
  background: linear-gradient(135deg, #1a3e5c, #2c5c8a);
  color: white;
  font-weight: 700;
  text-align: center;
  font-size: 1rem;
  padding: 12px;
}

#previewTable thead tr:last-child th {
  background: #f1f1f1;
  font-weight: 600;
  text-align: center;
  font-size: 0.9rem;
}

/* First column (row number) */
#previewTable td:first-child {
  text-align: center;
  font-weight: 600;
  background: #f8f9fa;
}

/* Parsed Content columns: left aligned */
#previewTable td:nth-child(2),
#previewTable td:nth-child(3) {
  text-align: left;
}

/* Parsed Answer column: center aligned */
#previewTable td:nth-child(4) {
  text-align: center;
}

#previewTable td:nth-child(2),
#previewTable th:nth-child(2) {
  width: 45%; /* narrower */
}

#previewTable td:nth-child(3),
#previewTable th:nth-child(3) {
  width: 15%; /* wider */
}

/* Validation Check columns: center aligned */
#previewTable td:nth-child(5),
#previewTable td:nth-child(6),
#previewTable td:nth-child(7),
#previewTable td:nth-child(8) {
  text-align: center;
  white-space: nowrap;
  background: #fafbfc;
}

/* Answer Cell Styling */
.answer-cell {
  color: #1a3e5c;
  font-size: 1rem;
}

/* Correct Answer Highlighting */
.correct {
  color: #217346;
  font-weight: 600;
  background: #d4edda;
  padding: 2px 0px;
}

/* Flags */
.flag-present {
  color: #28a745;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.flag-absent {
  color: #dc3545;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.flag-auto {
  color: #007bff;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Pre tag for options */
#previewTable pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  line-height: 1.6;
}

/* Drag-drop inactive state */
#drop-area.inactive {
  opacity: 0.5;
  pointer-events: none;
}

/* --------------------- Footer --------------------- */
footer {
  background: linear-gradient(135deg, #1a3e5c 0%, #2c5c8a 100%);
  color: white;
  text-align: center;
  padding: 30px 20px;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
}

.footer-main {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 1rem;
}

.footer-sub {
  opacity: 0.8;
  font-size: 0.9rem;
}

/* --------------------- Responsive Design --------------------- */
@media (max-width: 768px) {
  .main-header {
    padding: 30px 15px;
  }

  .header-content h1 {
    font-size: 2rem;
  }

  .hero-section {
    padding: 20px 20px;
  }

  .hero-content h1 {
    font-size: 1.8rem;
  }

  .format-support {
    font-size: 0.9rem;
  }

  .converter-section {
    padding: 20px 20px;
  }

  .drop-area {
    padding: 20px 20px;
  }

  .floating-btn {
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
  }

  .file-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  #previewTable {
    font-size: 12px;
  }

  #previewTable th,
  #previewTable td {
    padding: 4px 6px;
  }
}
