/* ============================================================
   PR331 Estimating Module — TradeRail Field Portal
   All selectors namespaced under .pr331-estimating
   Brand: Primary Orange #FF6B00 | Wordmark Dark #1A1A2E
   Build marker: pr331-estimating:2026-06-19
   ============================================================ */

/* ── Portal Layout ─────────────────────────────────────────── */
.portal-layout {
  display: flex;
  min-height: 100vh;
  background: #f4f5f7;
}

.portal-layout .sidebar {
  width: 240px;
  min-width: 240px;
  background: #1A1A2E;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.portal-layout .main-content {
  flex: 1;
  min-width: 0;
  padding: 24px;
}

/* Sidebar hidden below 768px */
@media (max-width: 767px) {
  .portal-layout .sidebar {
    display: none;
  }
  .portal-layout .main-content {
    padding: 12px;
  }
}

/* ── Top Ribbon ────────────────────────────────────────────── */
.portal-top-ribbon {
  background: #1A1A2E;
  color: #fff;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 200;
  border-bottom: 3px solid #FF6B00;
}

/* ── Root namespace ────────────────────────────────────────── */
.pr331-estimating {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #1A1A2E;
  max-width: 1200px;
}

/* ── Page header ───────────────────────────────────────────── */
.pr331-estimating .pr331-page-header {
  margin-bottom: 20px;
}

.pr331-estimating .pr331-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1A1A2E;
  margin: 0 0 4px 0;
}

.pr331-estimating .pr331-page-subtitle {
  font-size: 0.875rem;
  color: #555;
  margin: 0;
}

/* Lily subtitle: visible admin/owner/foreman, hidden for field_tech */
.pr331-estimating .pr331-subtitle-lily {
  display: block;
}

[data-portal-role="field_tech"] .pr331-estimating .pr331-subtitle-lily {
  display: none;
}

/* ── Lily Bar ──────────────────────────────────────────────── */
.pr331-lily-bar {
  border-left: 4px solid #7C3AED;
  background: #f5f0ff;
  padding: 10px 16px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pr331-lily-bar .pr331-lily-label {
  color: #7C3AED;
  font-weight: 700;
  font-size: 0.875rem;
  white-space: nowrap;
}

.pr331-lily-bar .pr331-lily-insight {
  color: #333;
  font-size: 0.875rem;
}

/* ── Revision Bar ──────────────────────────────────────────── */
.pr331-estimating .pr331-rev-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FF6B00;
  padding: 8px 16px;
  border-radius: 6px 6px 0 0;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.pr331-estimating .pr331-rev-label {
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
}

.pr331-estimating .pr331-rev-select {
  border: 1px solid rgba(255,255,255,0.5);
  background: #fff;
  color: #1A1A2E;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.875rem;
}

/* ── Buttons ────────────────────────────────────────────────── */
.pr331-estimating .pr331-btn {
  display: inline-block;
  padding: 6px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
}

.pr331-estimating .pr331-btn:hover {
  opacity: 0.88;
}

.pr331-estimating .pr331-btn-primary {
  background: #FF6B00;
  color: #fff;
}

.pr331-estimating .pr331-btn-secondary {
  background: #e8e8e8;
  color: #1A1A2E;
}

.pr331-estimating .pr331-btn-danger {
  background: #dc2626;
  color: #fff;
}

.pr331-estimating .pr331-btn-convert {
  background: #FF6B00;
  color: #fff;
}

.pr331-estimating .pr331-btn-sm {
  padding: 3px 9px;
  font-size: 0.8rem;
}

/* Two-tap confirm state */
.pr331-estimating .pr331-btn-confirm-pending {
  background: #b91c1c;
  color: #fff;
  animation: pr331-pulse 0.3s ease-in-out;
  outline: 2px solid #7f1d1d;
}

@keyframes pr331-pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ── Table ──────────────────────────────────────────────────── */
.pr331-estimating .pr331-table-wrap {
  overflow-x: auto;
  border-radius: 0 0 6px 6px;
  border: 1px solid #ddd;
  background: #fff;
  margin-bottom: 20px;
}

.pr331-estimating .pr331-line-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 600px;
}

.pr331-estimating .pr331-thead {
  background: #1A1A2E;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.pr331-estimating .pr331-line-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

.pr331-estimating .pr331-line-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

/* Alternating rows */
.pr331-estimating .pr331-row-even {
  background: #fff;
}

.pr331-estimating .pr331-row-odd {
  background: #f8f9fa;
}

/* Category header rows */
.pr331-estimating .pr331-cat-header {
  background: #eef2ff;
}

.pr331-estimating .pr331-cat-label {
  font-weight: 700;
  color: #1A1A2E;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 12px;
}

/* Subtotal rows */
.pr331-estimating .pr331-subtotal-row {
  background: #f0f0f0;
}

.pr331-estimating .pr331-subtotal-label {
  font-weight: 600;
  color: #444;
  text-align: right;
  padding-right: 12px;
}

.pr331-estimating .pr331-subtotal-val {
  font-weight: 700;
  color: #1A1A2E;
}

/* Grand total row */
.pr331-estimating .pr331-grand-total-row {
  background: #1A1A2E;
  color: #fff;
}

.pr331-estimating .pr331-grand-total-row td {
  border-bottom: none;
  padding: 10px 12px;
}

.pr331-estimating .pr331-grand-label {
  font-weight: 700;
  text-align: right;
  padding-right: 12px;
}

.pr331-estimating .pr331-grand-val {
  font-weight: 700;
  font-size: 1rem;
  color: #FF6B00;
}

/* ── Delta Table ────────────────────────────────────────────── */
.pr331-estimating .pr331-delta-section {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.pr331-estimating .pr331-delta-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1A1A2E;
  margin: 0 0 12px 0;
}

.pr331-estimating .pr331-delta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 500px;
}

.pr331-estimating .pr331-delta-table th {
  background: #1A1A2E;
  color: #fff;
  padding: 8px 10px;
  text-align: left;
}

.pr331-estimating .pr331-delta-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #eee;
}

.pr331-estimating .pr331-delta-up td {
  color: #dc2626;
}

.pr331-estimating .pr331-delta-down td {
  color: #16a34a;
}

/* ── Add Line Form ──────────────────────────────────────────── */
.pr331-estimating .pr331-add-line-form {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
}

.pr331-estimating .pr331-form-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1A1A2E;
  margin: 0 0 12px 0;
}

.pr331-estimating .pr331-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.pr331-estimating .pr331-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.875rem;
  color: #1A1A2E;
  box-sizing: border-box;
}

.pr331-estimating .pr331-input:focus {
  outline: 2px solid #FF6B00;
  border-color: #FF6B00;
}

.pr331-estimating .pr331-select {
  background: #fff;
}

/* ── Action Bar ─────────────────────────────────────────────── */
.pr331-estimating .pr331-action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  align-items: center;
}

/* ── Action cells ───────────────────────────────────────────── */
.pr331-estimating .pr331-actions-cell {
  white-space: nowrap;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 767px) {
  .pr331-estimating .pr331-form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .pr331-estimating .pr331-rev-bar {
    padding: 8px 10px;
    gap: 8px;
  }

  .pr331-estimating .pr331-page-title {
    font-size: 1.2rem;
  }

  .pr331-estimating .pr331-action-bar {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ── Utility ────────────────────────────────────────────────── */
.pr331-estimating .pr331-total-cell {
  font-weight: 600;
}

.pr331-estimating .pr331-convert-banner {
  background: #dcfce7;
  border: 1px solid #16a34a;
  border-radius: 4px;
  padding: 10px 16px;
  color: #166534;
  font-weight: 600;
  margin-bottom: 12px;
}
