/* =========================================================
   GERENCIADOR DE ORÇAMENTOS - DATA HORA TECH
   Estilos Principais e Mídia de Impressão (Print/PDF)
========================================================= */

:root {
  --bg-dark: #070b14;
  --bg-panel: #0d1527;
  --bg-card: #131f38;
  --bg-card-hover: #192847;
  --border-color: #1e3054;
  --border-focus: #00e5ff;
  
  --primary: #00c8ff;
  --primary-hover: #00b0e0;
  --primary-glow: rgba(0, 200, 255, 0.25);
  
  --secondary: #3b82f6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 15px rgba(0, 200, 255, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ================= HEADER & BRAND ================= */
.app-header {
  background: linear-gradient(180deg, #0d1527 0%, rgba(13, 21, 39, 0.8) 100%);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-img {
  height: 48px;
  width: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  filter: drop-shadow(0 0 8px rgba(0, 200, 255, 0.3));
}

.brand-title-box h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #fff;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.brand-title-box h1 span {
  color: var(--primary);
  text-shadow: 0 0 10px var(--primary-glow);
}

.brand-title-box p {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-tabs {
  display: flex;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.nav-tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.nav-tab-btn:hover {
  color: #fff;
}

.nav-tab-btn.active {
  background: var(--primary);
  color: #070b14;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* ================= MAIN CONTAINER ================= */
.main-container {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================= CARDS & PANELS ================= */
.panel-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.panel-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0.7;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title i {
  color: var(--primary);
}

.panel-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ================= GRID & FORM CONTROLS ================= */
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.form-grid-12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}

.col-span-12 { grid-column: span 12; }
.col-span-8 { grid-column: span 8; }
.col-span-6 { grid-column: span 6; }
.col-span-4 { grid-column: span 4; }
.col-span-3 { grid-column: span 3; }
.col-span-2 { grid-column: span 2; }

@media (max-width: 992px) {
  .form-grid-2, .form-grid-3, .form-grid-4 {
    grid-template-columns: 1fr;
  }
  .col-span-8, .col-span-6, .col-span-4, .col-span-3, .col-span-2 {
    grid-column: span 12;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 9px 12px;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.2s ease;
  width: 100%;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0, 200, 255, 0.15);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

select.form-control option {
  background: var(--bg-card);
  color: #fff;
}

/* ================= PRODUCT ITEM CARDS ================= */
.products-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.product-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: relative;
  transition: all 0.25s ease;
}

.product-item-card:hover {
  border-color: rgba(0, 200, 255, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.product-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.product-badge-number {
  background: rgba(0, 200, 255, 0.15);
  color: var(--primary);
  border: 1px solid rgba(0, 200, 255, 0.3);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.product-item-layout {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1.25rem;
}

@media (max-width: 768px) {
  .product-item-layout {
    grid-template-columns: 1fr;
  }
}

/* Image Upload Box */
.image-upload-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.image-preview-box {
  width: 100%;
  height: 160px;
  background: #090d17;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
  text-align: center;
  padding: 6px;
}

.image-preview-box:hover {
  border-color: var(--primary);
  background: rgba(0, 200, 255, 0.03);
}

.image-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius-md) - 2px);
}

.image-preview-box .upload-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  pointer-events: none;
}

.image-preview-box .upload-prompt svg {
  width: 32px;
  height: 32px;
  stroke: var(--text-subtle);
}

.image-remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: background 0.2s ease;
}

.image-remove-btn:hover {
  background: var(--danger);
}

.item-fields-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #00c8ff 0%, #0088cc 100%);
  color: #070b14;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 200, 255, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1ad0ff 0%, #009ceb 100%);
  box-shadow: 0 6px 16px rgba(0, 200, 255, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #0ea371;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-icon {
  padding: 7px;
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
}

/* ================= TOTALS BAR ================= */
.totals-summary-card {
  background: linear-gradient(135deg, #0f1c36 0%, #162447 100%);
  border: 1px solid #1e3a6d;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1rem;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.totals-row.grand-total {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  margin-top: 8px;
  padding-top: 12px;
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
}

.totals-row.grand-total .value {
  color: var(--primary);
  text-shadow: 0 0 12px var(--primary-glow);
}

/* ================= BUDGET LIST TABLE ================= */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border-color);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
  vertical-align: middle;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-draft { background: rgba(148, 163, 184, 0.15); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.3); }
.badge-sent { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-approved { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-rejected { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

/* ================= MODAL / PREVIEW ================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(3, 7, 18, 0.88);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 980px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.modal-header {
  padding: 1rem 1.5rem;
  background: #0d1527;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  background: #2a3447;
}

/* ================= PROPOSTA COMERCIAL A4 (DOCUMENT PREVIEW) ================= */
.quote-sheet {
  background: #ffffff;
  color: #1e293b;
  max-width: 820px;
  margin: 0 auto;
  padding: 2.2rem 2.5rem;
  border-radius: 4px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  font-size: 13px;
  line-height: 1.5;
  position: relative;
}

/* Header da Folha */
.qs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid #00c8ff;
  padding-bottom: 18px;
  margin-bottom: 20px;
}

.qs-brand-box {
  display: flex;
  align-items: center;
  gap: 16px;
}

.qs-logo-img {
  height: 60px;
  width: auto;
  object-fit: contain;
  background: #000;
  padding: 4px 8px;
  border-radius: 4px;
}

.qs-company-info h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #0b1329;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.qs-company-info p {
  font-size: 11px;
  color: #64748b;
  margin: 1px 0;
}

.qs-doc-meta {
  text-align: right;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 8px 14px;
  border-radius: 6px;
}

.qs-doc-title {
  font-size: 15px;
  font-weight: 800;
  color: #0284c7;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.qs-doc-number {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.qs-doc-date {
  font-size: 11px;
  color: #64748b;
}

/* Seção de Dados do Cliente */
.qs-section {
  margin-bottom: 20px;
}

.qs-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #0f172a;
  background: #f1f5f9;
  border-left: 3px solid #00c8ff;
  padding: 4px 10px;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.qs-client-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  background: #fafafa;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid #f1f5f9;
}

.qs-info-item {
  display: flex;
  font-size: 12px;
}

.qs-info-item .label {
  font-weight: 600;
  color: #475569;
  width: 130px;
  flex-shrink: 0;
}

.qs-info-item .val {
  color: #0f172a;
  font-weight: 500;
  word-break: break-word;
}

/* Tabela de Produtos da Folha */
.qs-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  margin-bottom: 16px;
}

.qs-table th {
  background: #0f172a;
  color: #ffffff;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  text-align: left;
}

.qs-table td {
  padding: 10px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
  font-size: 12px;
}

.qs-table tr:nth-child(even) td {
  background: #f8fafc;
}

.qs-item-col-prod {
  display: flex;
  gap: 12px;
}

.qs-item-thumb {
  width: 60px;
  height: 60px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  object-fit: cover;
  background: #f1f5f9;
  flex-shrink: 0;
}

.qs-item-details {
  flex: 1;
}

.qs-item-title {
  font-weight: 700;
  color: #0f172a;
  font-size: 13px;
  margin-bottom: 3px;
}

.qs-item-specs {
  font-size: 11px;
  color: #475569;
  white-space: pre-line;
  line-height: 1.4;
}

/* Totais da Folha */
.qs-summary-wrap {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}

.qs-summary-box {
  width: 280px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}

.qs-sum-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 12px;
  color: #475569;
  background: #fafafa;
  border-bottom: 1px solid #f1f5f9;
}

.qs-sum-row.total {
  background: #0f172a;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  border-bottom: none;
}

.qs-sum-row.total .val {
  color: #00c8ff;
}

/* Condições e Pagamento */
.qs-conditions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 25px;
}

.qs-cond-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 11.5px;
}

.qs-cond-card h4 {
  font-size: 11px;
  text-transform: uppercase;
  color: #0284c7;
  margin-bottom: 6px;
  font-weight: 700;
}

/* Assinaturas */
.qs-signatures {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 40px;
  margin-top: 35px;
  padding-top: 20px;
}

.qs-sig-box {
  text-align: center;
}

.qs-sig-line {
  border-top: 1px solid #94a3b8;
  margin-bottom: 6px;
}

.qs-sig-name {
  font-weight: 700;
  font-size: 12px;
  color: #0f172a;
}

.qs-sig-role {
  font-size: 11px;
  color: #64748b;
}

/* Rodapé da Folha */
.qs-footer {
  margin-top: 25px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
  font-size: 10px;
  color: #94a3b8;
  text-align: center;
}

/* ================= PRINT RULES (A4 PDF) ================= */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .app-header,
  .main-container,
  .modal-header,
  .modal-overlay:not(.active),
  .no-print {
    display: none !important;
  }

  .modal-overlay {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
  }

  .modal-container {
    max-width: 100% !important;
    max-height: none !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  .modal-body {
    background: transparent !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  .quote-sheet {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    page-break-after: avoid;
  }

  @page {
    size: A4 portrait;
    margin: 12mm 15mm 12mm 15mm;
  }

  tr {
    page-break-inside: avoid;
  }
}
