/* index.css - FIT to CSV Converter Stylesheet (v3.3) */
@import url('https://fonts.googleapis.com/css2?family=Amaranth:ital,wght@0,400;0,700;1,400&display=swap');

@import url('../variables.css');

:root {
  --code-text: #062f47;
  --table-head-bg: rgba(255, 255, 255, 0.55);
  --table-line: rgba(30, 54, 65, 0.28);
}

html[data-theme="dark"] {
  --code-text: #d7fbff;
  --table-head-bg: rgba(2, 17, 24, 0.88);
  --table-line: rgba(198, 220, 227, 0.22);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --code-text: #d7fbff;
    --table-head-bg: rgba(2, 17, 24, 0.88);
    --table-line: rgba(198, 220, 227, 0.22);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: linear-gradient(
    -45deg,
    var(--cycler-gradient-start),
    var(--cycler-gradient-mid-a),
    var(--cycler-gradient-mid-b),
    var(--cycler-gradient-end)
  );
  background-size: 400% 400%;
  background-attachment: fixed;
  background-color: #313131;
  animation: cycler-gradient 18s ease infinite;
  color: var(--panel-text);
  font-family: 'Amaranth', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: clamp(18px, 0.4vw + 16px, 20px);
  line-height: 1.6;
  padding: 0 0 32px;
}

@keyframes cycler-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

main {
  width: 95%;
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1em;
}

header {
  width: 100%;
  margin: 0.2em auto 0;
  padding: 0.5em 0.7em 0.65em;
  text-align: center;
  background: var(--cycler-glass-bg);
  border: 1px solid var(--cycler-glass-border);
  border-radius: 20px;
  box-shadow: var(--cycler-header-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

h1 {
  color: var(--heading-text);
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-variant: small-caps;
  font-weight: 700;
  line-height: 1.12;
}

.subhead {
  max-width: 75ch;
  margin: 0.35em auto 0;
  color: var(--heading-copy);
  font-size: clamp(1rem, 1vw + 0.75rem, 1.25rem);
  line-height: 1.35;
}

.drop-zone,
.status,
.export-panel,
.metric,
.panel {
  background-color: var(--cycler-grid-bg-color);
  background-image: var(--panel-bg-image);
  border: 1px solid var(--cycler-border);
  border-radius: 20px;
  box-shadow: 1px 1px 4px 0 var(--cycler-shadow);
}

.export-panel textarea:focus {
  border-color: var(--cycler-hover);
  box-shadow: 0 0 0 3px rgba(199, 42, 147, 0.22);
}

.drop-zone {
  position: relative;
  display: grid;
  min-height: 240px;
  place-items: center;
  overflow: hidden;
  padding: 2.2em 1.4em;
  text-align: center;
  cursor: pointer;
  transition: box-shadow 0.15s ease-out, transform 0.15s ease-out, border-color 0.15s ease-out;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.16);
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

.drop-zone:hover,
.drop-zone.dragging {
  transform: translateY(2px);
  border-color: var(--cycler-hover);
  box-shadow:
    inset 2px 2px 6px rgba(0, 0, 0, 0.2),
    inset -1px -1px 4px rgba(255, 255, 255, 0.1),
    0 0 15px var(--cycler-button-glow);
}

.drop-zone:hover::before,
.drop-zone.dragging::before {
  opacity: 1;
}

.drop-zone > div {
  position: relative;
  z-index: 1;
}

.drop-icon {
  display: block;
  margin-bottom: 0.35em;
  font-size: 2.6rem;
}

.drop-zone h2 {
  margin-bottom: 0.15em;
  color: var(--strong-text);
  font-size: clamp(1.3rem, 2vw + 0.7rem, 2rem);
}

.drop-zone p,
.export-panel p {
  color: var(--panel-muted);
  font-size: 1rem;
  line-height: 1.35;
}

.file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  margin-top: 0.85em;
}

button,
.file-label,
.export-panel a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.35rem;
  padding: 0.35em 0.8em;
  color: var(--cycler-button-text);
  background-color: var(--cycler-button-bg);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(0, 0, 0, 0.05) 51%,
    rgba(0, 0, 0, 0.1) 100%
  );
  border: 1px solid var(--cycler-border);
  border-radius: 6px;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.6),
    inset -1px -1px 0 rgba(0, 0, 0, 0.1),
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 0 12px var(--cycler-button-glow);
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);
  transition: background-color 0.15s ease-out, box-shadow 0.15s ease-out, transform 0.15s ease-out;
  user-select: none;
}

button:hover,
.file-label:hover,
.export-panel a:hover {
  background-color: var(--cycler-button-bg-hover);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.5) 0%,
    rgba(255, 255, 255, 0.1) 100%
  );
  transform: translateY(2px);
  box-shadow:
    inset 2px 2px 6px rgba(0, 0, 0, 0.2),
    inset -1px -1px 4px rgba(255, 255, 255, 0.1),
    0 0 15px var(--cycler-button-glow);
}

button:focus-visible,
.file-label:focus-visible,
.export-panel a:focus-visible {
  outline: 3px solid var(--cycler-hover);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.status {
  min-height: 54px;
  display: flex;
  align-items: center;
  padding: 0.75em 0.9em;
  color: var(--success-text);
  font-weight: 700;
}

.status.error {
  color: var(--danger);
  border-color: var(--danger);
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.6em;
}

.metric {
  min-width: 0;
  padding: 0.65em;
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
}

.metric:hover {
  border-color: var(--cycler-hover);
  box-shadow: 0 0 15px var(--cycler-button-glow);
}

.metric span,
.panel h2 {
  display: block;
  color: var(--panel-muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.metric span {
  margin-bottom: 0.25em;
}

.metric strong {
  display: block;
  overflow: hidden;
  color: var(--strong-text);
  font-size: clamp(1rem, 1vw + 0.75rem, 1.35rem);
  font-weight: 700;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-panel {
  padding: 0.8em;
}

.export-panel p {
  margin-bottom: 0.65em;
}

.preview-label {
  display: block;
  margin-top: 0.65em;
  color: var(--panel-muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
}

.export-panel textarea {
  width: 100%;
  min-height: 160px;
  margin-top: 0.65em;
  padding: 0.9em;
  color: var(--field-text);
  background: var(--field-bg);
  border: 1px solid var(--cycler-border);
  border-radius: 10px;
  font: 0.82rem/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
  outline: none;
}

.content-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8em;
  align-items: start;
}
.content-grid > :first-child {
  flex: 1 0 280px;
}
.content-grid > :last-child {
  flex: 999 1 480px;
}

.panel {
  overflow: hidden;
}

.panel h2 {
  margin: 0;
  padding: 0.7em 0.85em;
  border-bottom: 1px solid var(--cycler-border);
  background: var(--panel-softer);
}

.message-list,
.table-wrap {
  max-height: 440px;
  overflow: auto;
}

.message-type {
  display: flex;
  justify-content: space-between;
  gap: 0.6em;
  padding: 0.55em 0.85em;
  border-bottom: 1px solid var(--table-line);
  font-size: 1rem;
}

.message-type code,
td code {
  color: var(--code-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

table {
  width: 100%;
  border-collapse: collapse;
  font: 0.82rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

th,
td {
  padding: 0.55em 0.65em;
  border-bottom: 1px solid var(--table-line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--panel-muted);
  background: var(--table-head-bg);
}

.hidden {
  display: none !important;
}

/* ============================================================================
   THEME SWITCHER
   ============================================================================ */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25em;
  width: fit-content;
  max-width: 95%;
  margin: 0;
  padding: 0.22em;
  color: var(--cycler-theme-text);
  background: var(--cycler-theme-bg);
  border: 1px solid var(--cycler-glass-border);
  border-radius: 999px;
  box-shadow: 0 8px 16px rgba(45, 4, 82, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.theme-toggle button {
  appearance: none;
  -webkit-appearance: none;
  min-height: 1.9rem;
  padding: 0.25em 0.58em;
  color: var(--cycler-theme-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: clamp(13px, 0.45vw + 0.65rem, 16px);
  line-height: 1;
  transition: background-color 0.15s ease-out,
              border-color 0.15s ease-out,
              box-shadow 0.15s ease-out,
              transform 0.15s ease-out;
}

.theme-toggle button:hover,
.theme-toggle button:focus {
  background: var(--cycler-theme-active-bg);
  border-color: var(--cycler-glass-border);
  outline: none;
}

.theme-toggle button[aria-pressed="true"] {
  color: var(--cycler-button-text);
  background-color: var(--cycler-button-bg);
  border-color: var(--cycler-border);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.35),
    0 0 10px var(--cycler-button-glow);
}

.theme-toggle button:focus-visible {
  outline: 3px solid var(--cycler-hover);
  outline-offset: 2px;
}

/* ============================================================================
   FOOTER
   ============================================================================ */
footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1em;
  width: 95%;
  max-width: 1180px;
  margin: 2em auto 1.5em auto;
  padding: 1.2em 1em;
  color: var(--panel-text);
  font-size: 0.9em;
  border: 1px solid var(--cycler-border);
  background-color: var(--cycler-grid-bg-color);
  background-image: var(--panel-bg-image);
  border-radius: 20px;
  box-shadow: 1px 1px 4px 0 var(--cycler-shadow);
  box-sizing: border-box;
}

footer p {
  margin: 0;
}

@media (min-width: 48rem) {
  main,
  footer {
    width: 85%;
  }
}

@media (max-width: 48rem) {
  .button-row {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  body {
    animation: none;
  }
}
