/* app.css — TradeWind classification tool styles */
/* Extends theme.css variables. Must be loaded after theme.css. */

/* ---- APP LAYOUT ---- */
.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 100px 32px 64px;
}

/* ---- APP NAV ---- */
.app-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.92);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.app-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--fg);
}
.app-nav-brand svg { flex-shrink: 0; }
.app-nav-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.app-nav-badge {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
  background: var(--amber-dim);
  border: 1px solid rgba(232,168,56,0.18);
  border-radius: 4px;
  padding: 2px 8px;
  font-weight: 500;
}
.app-nav-back {
  font-size: 13px;
  color: var(--fg-dim);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
}
.app-nav-back:hover { color: var(--fg); }

/* ---- PAGE HEADER ---- */
.page-header {
  margin-bottom: 40px;
}
.page-eyebrow {
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 10px;
  font-weight: 500;
}
.page-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin-bottom: 10px;
}
.page-sub {
  font-size: 15px;
  color: var(--fg-dim);
  line-height: 1.6;
}

/* ---- TWO COLUMN LAYOUT ---- */
.classify-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

/* ---- FORM PANEL ---- */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.panel-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-title-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
}

/* ---- FORM ELEMENTS ---- */
.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-dim);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}
.form-label span {
  color: var(--fg-muted);
  font-weight: 400;
  font-size: 12px;
}
textarea.form-input,
input.form-input,
select.form-input {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  padding: 12px 14px;
  transition: border-color 0.2s, background 0.2s;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  resize: vertical;
}
textarea.form-input {
  min-height: 120px;
}
select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238899b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}
textarea.form-input:focus,
input.form-input:focus,
select.form-input:focus {
  border-color: rgba(232,168,56,0.35);
  background: rgba(232,168,56,0.03);
}
textarea.form-input::placeholder,
input.form-input::placeholder {
  color: var(--fg-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ---- SUBMIT BUTTON ---- */
.btn-classify {
  width: 100%;
  margin-top: 8px;
  padding: 14px 24px;
  background: var(--amber);
  color: #0a0e17;
  border: none;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-classify:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}
.btn-classify:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn-classify .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(10,14,23,0.3);
  border-top-color: #0a0e17;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.btn-classify.loading .spinner { display: block; }
.btn-classify.loading .btn-text { opacity: 0.7; }
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- RESULT PANEL ---- */
.result-panel {
  display: none;
}
.result-panel.visible {
  display: block;
}

/* HS code big display */
.hs-display {
  text-align: center;
  padding: 28px 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.hs-label {
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--amber);
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 8px;
}
.hs-code-big {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--fg);
  line-height: 1;
  margin-bottom: 8px;
}
.hs-description {
  font-size: 14px;
  color: var(--fg-dim);
  line-height: 1.5;
}

/* Confidence badge */
.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 3px 10px;
  margin-top: 10px;
}
.confidence-badge.high {
  background: rgba(52,211,153,0.1);
  color: var(--green);
  border: 1px solid rgba(52,211,153,0.2);
}
.confidence-badge.medium {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(232,168,56,0.2);
}
.confidence-badge.low {
  background: rgba(248,113,113,0.08);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.15);
}

/* Result rows */
.result-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.result-row:last-child { border-bottom: none; }
.result-row-label {
  font-size: 13px;
  color: var(--fg-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.result-row-value {
  font-size: 13px;
  color: var(--fg);
  text-align: right;
  font-weight: 500;
}
.result-row-value.duty {
  color: var(--amber);
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 15px;
}

/* Reasoning */
.reasoning-block {
  margin-top: 20px;
  padding: 14px;
  background: rgba(255,255,255,0.02);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.reasoning-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 500;
}
.reasoning-text {
  font-size: 13px;
  line-height: 1.65;
  color: var(--fg-dim);
}

/* Alternatives */
.alt-codes {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.alt-chip {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--fg-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
}
.alt-codes-label {
  font-size: 12px;
  color: var(--fg-muted);
  margin-bottom: 6px;
}

/* Doc buttons */
.doc-actions {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.btn-doc {
  padding: 11px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-dim);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
.btn-doc:hover {
  border-color: rgba(232,168,56,0.3);
  color: var(--amber);
  background: var(--amber-dim);
}

/* Error state */
.error-box {
  background: rgba(248,113,113,0.06);
  border: 1px solid rgba(248,113,113,0.15);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--red);
  line-height: 1.5;
  display: none;
  margin-top: 12px;
}
.error-box.visible { display: block; }

/* ---- HISTORY SECTION ---- */
.history-section {
  margin-top: 48px;
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.history-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-dim);
}
.history-count {
  font-size: 12px;
  color: var(--fg-muted);
}
.history-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.history-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  font-weight: 500;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: rgba(255,255,255,0.01);
}
.history-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--fg-dim);
  vertical-align: top;
}
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: rgba(255,255,255,0.02); }
.history-table td.hs {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--amber);
  white-space: nowrap;
}
.history-table td.product {
  color: var(--fg);
  max-width: 200px;
}
.history-table td.duty {
  color: var(--fg);
  font-weight: 500;
  white-space: nowrap;
}
.conf-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
}
.conf-dot.high { background: var(--green); }
.conf-dot.medium { background: var(--amber); }
.conf-dot.low { background: var(--red); }
.history-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--fg-muted);
  font-size: 14px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 860px) {
  .classify-grid {
    grid-template-columns: 1fr;
  }
  .app-main {
    padding: 90px 20px 48px;
  }
}
@media (max-width: 500px) {
  .form-row {
    grid-template-columns: 1fr;
  }
  .doc-actions {
    grid-template-columns: 1fr;
  }
  .hs-code-big {
    font-size: 2.2rem;
  }
}
