/* ============================================
   Component Styles
   ============================================ */

/* ===== DATA TABLES ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 18px;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 12px 14px;
  background: var(--paper-deep);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: 1px solid var(--ink);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.data-table tbody tr:hover td {
  background: rgba(246, 241, 231, 0.5);
}

.data-table td.num {
  font-family: var(--font-mono);
  text-align: right;
  font-feature-settings: "tnum";
}

.data-table td strong {
  font-weight: 600;
}

.data-table .row-actions {
  display: flex;
  gap: 6px;
}

/* ===== RESULT PANEL ===== */
.result-pane {
  position: sticky;
  top: 20px;
}

.result-card {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--ink);
}

.result-header h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  font-variation-settings: "opsz" 144;
  letter-spacing: -0.02em;
  line-height: 1;
}

.mode-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 2px;
  margin-top: 8px;
}

#result-body {
  font-size: 13px;
}

.result-section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 16px 0 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.result-section-title:first-of-type { 
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.line-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
}

.line-item .label-txt {
  color: var(--muted);
}

.line-item .val {
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  white-space: nowrap;
  color: var(--ink);
}

.line-item.bold {
  font-weight: 600;
  padding-top: 8px;
  padding-bottom: 8px;
  border-top: 1px solid var(--ink);
  margin-top: 6px;
}

.line-item.bold .val {
  font-weight: 600;
}

.line-item.profit-line {
  background: var(--green-soft);
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-top: 10px;
  color: var(--green);
  font-weight: 600;
}

.line-item.total-line {
  background: var(--ink);
  color: var(--paper);
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.line-item.total-line .val {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--paper);
}

.per-piece-display {
  text-align: center;
  margin-top: 12px;
  padding: 10px;
  background: var(--paper-deep);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--muted);
}

.per-piece-display strong {
  font-family: var(--font-mono);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
}

.machine-suggestion {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.machine-suggestion strong {
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 600;
}

.machine-suggestion .meta {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
  margin-top: 4px;
}

.cut-visual {
  background: var(--paper-deep);
  padding: 10px 12px;
  border-radius: var(--radius);
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.machine-compare {
  background: var(--paper-deep);
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-top: 12px;
  font-size: 12px;
}

.machine-compare .compare-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
}

.machine-compare .compare-row:last-child { border: none; }
.machine-compare .compare-row.best { color: var(--green); font-weight: 600; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 32px;
  color: var(--line);
  margin-bottom: 12px;
}

.result-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

@media (max-width: 700px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card.highlight {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.stat-card.highlight .stat-label { color: rgba(246, 241, 231, 0.6); }
.stat-card.highlight .stat-value { color: var(--paper); }

.stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 500;
}

.stat-value {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-top: 6px;
}

/* ===== FILTERS ===== */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-input {
  width: auto;
  min-width: 140px;
  padding: 8px 12px;
  font-size: 13px;
}

/* ===== PILLS ===== */
.pill {
  display: inline-block;
  padding: 3px 9px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 2px;
  background: var(--paper-deep);
  color: var(--muted);
}

.pill.offset { background: var(--accent-soft); color: var(--accent); }
.pill.book { background: var(--blue-soft); color: var(--blue); }
.pill.digital { background: var(--green-soft); color: var(--green); }

/* ===== FINISHING ROW IN CALCULATOR ===== */
.finishing-row {
  background: var(--paper-deep);
  border: 1px dashed var(--line);
  padding: 14px;
  border-radius: var(--radius);
  margin-bottom: 10px;
}

/* ===== BOOK SECTION BLOCK ===== */
.book-section {
  background: var(--blue-soft);
  border: 1px solid #b5c8de;
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  position: relative;
}

.book-section .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #b5c8de;
}

.book-section .section-header h4 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 22, 18, 0.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 640px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-content h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: var(--paper);
  padding: 14px 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  font-size: 14px;
  font-weight: 500;
  transform: translateY(120px);
  opacity: 0;
  transition: all 0.3s ease;
  font-family: var(--font-body);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error { background: var(--accent); }
.toast.success { background: var(--green); }

/* ===== LOADING STATE ===== */
.loading {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== DETAILS ===== */
details {
  margin-top: 12px;
}

details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 0;
  user-select: none;
}

details summary:hover { color: var(--ink); }

details[open] summary { color: var(--ink); margin-bottom: 8px; }

.detail-content {
  font-size: 12px;
  padding: 10px 12px;
  background: var(--paper-deep);
  border-radius: var(--radius);
  color: var(--ink-soft);
  line-height: 1.6;
}

/* ===== PRINT STYLES ===== */
@media print {
  .grain, .tabs-nav, .header-actions, .result-actions,
  .actions, .filters, .mode-switcher, .btn { display: none !important; }
  
  body { background: #fff; }
  .app-header { padding: 0 0 14px; border-color: #000; }
  .panel { padding: 0; }
  .card, .result-card { 
    border: 1px solid #000;
    box-shadow: none;
    page-break-inside: avoid;
  }
  .grid-calc { grid-template-columns: 1fr; }
  .result-pane { position: static; }
}
