/* ============================================================
   PaintLab AI — INDUSTHANE Calculation Table Styles
============================================================ */

/* ── Calculation Table ───────────────────────────────────── */
.calc-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
}

.calc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  min-width: 900px;
}

.calc-table thead th {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #94a3b8;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 12px;
  text-align: center;
  border-bottom: 2px solid rgba(20,65,150,0.4);
  white-space: nowrap;
}

.calc-table thead th:first-child {
  text-align: left;
  border-radius: var(--radius-sm) 0 0 0;
}
.calc-table thead th:last-child {
  border-radius: 0 var(--radius-sm) 0 0;
}

.calc-table tbody tr {
  transition: background 0.15s;
}

.calc-table tbody tr:hover {
  background: rgba(20,65,150,0.05);
}

.calc-table tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.02);
}

.calc-table tbody tr:nth-child(even):hover {
  background: rgba(20,65,150,0.06);
}

.calc-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.calc-table tbody td:first-child {
  font-weight: 600;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calc-table td.num {
  text-align: right;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px;
  color: var(--text-sub);
}

/* Totals row */
.calc-table tfoot .totals-row td {
  background: linear-gradient(135deg,
    rgba(20,65,150,0.1),
    rgba(201,164,0,0.08));
  border-top: 2px solid rgba(20,65,150,0.3);
  border-bottom: none;
  font-size: 12px;
  padding: 12px;
}

.calc-table tfoot .totals-row td:first-child {
  border-radius: 0 0 0 var(--radius-sm);
}
.calc-table tfoot .totals-row td:last-child {
  border-radius: 0 0 var(--radius-sm) 0;
}

/* Type badges in calc table */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.type-resina   { background: rgba(20,65,150,0.15); color: #4d7fd4; }
.type-pigmento { background: rgba(220,38,38,0.15); color: #f87171; }
.type-carga    { background: rgba(161,161,170,0.15); color: #a1a1aa; }
.type-solvente { background: rgba(201,164,0,0.15); color: #e8c400; }
.type-aditivo  { background: rgba(16,185,129,0.15); color: #34d399; }
.type-outros   { background: rgba(245,158,11,0.15); color: #fbbf24; }

/* ── Calculation Summary ──────────────────────────────────── */
.calc-summary {
  margin-top: 20px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.calc-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.calc-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 12px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.calc-kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.calc-kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.calc-kpi.kpi-ok::before    { background: linear-gradient(90deg, var(--success), #22c55e); }
.calc-kpi.kpi-warning::before { background: linear-gradient(90deg, var(--warning), #f59e0b); }
.calc-kpi.kpi-danger::before  { background: linear-gradient(90deg, var(--danger), #ef4444); }

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  line-height: 1.2;
}

.kpi-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  font-family: 'Inter', sans-serif;
}

.calc-kpi.kpi-ok    .kpi-value { color: var(--success); }
.calc-kpi.kpi-warning .kpi-value { color: var(--warning); }
.calc-kpi.kpi-danger  .kpi-value { color: var(--danger); }

/* ── Inline formula calc button ─────────────────────────── */
.btn-calc-table {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, rgba(20,65,150,0.1), rgba(201,164,0,0.1));
  border: 1px solid rgba(20,65,150,0.3);
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-calc-table:hover {
  background: linear-gradient(135deg, rgba(20,65,150,0.2), rgba(201,164,0,0.2));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(20,65,150,0.2);
}

/* ── Properties grid enhanced ──────────────────────────── */
.props-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px;
}

.prop-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.prop-item::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.prop-item:hover::after {
  transform: scaleX(1);
}

.prop-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.prop-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.prop-label i {
  color: var(--primary);
  font-size: 12px;
}

.prop-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

/* Dark mode adjustments */
[data-theme="dark"] .calc-table thead th {
  background: rgba(15, 23, 42, 0.8);
}

[data-theme="dark"] .type-resina   { background: rgba(20,65,150,0.2); }
[data-theme="dark"] .type-pigmento { background: rgba(220,38,38,0.2); }
[data-theme="dark"] .type-carga    { background: rgba(100,116,139,0.2); }
[data-theme="dark"] .type-solvente { background: rgba(201,164,0,0.2); }
[data-theme="dark"] .type-aditivo  { background: rgba(16,185,129,0.2); }
[data-theme="dark"] .type-outros   { background: rgba(245,158,11,0.2); }

/* Print styles for calc table */
@media print {
  .calc-table-wrapper {
    overflow: visible;
  }
  .calc-kpi:hover {
    transform: none;
    box-shadow: none;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .calc-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .props-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
