/* CSS Design System for Cotizador Centro Constructor SPA */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Exact Colors extracted from provided SVG logo */
  --primary-blue: #246DFF;
  --primary-hover: #1a56cc;
  --accent-orange: #FB6200;
  --accent-orange-hover: #d95400;
  --primary-dark: #0f172a;
  
  --bg-slate: #f1f5f9;
  --card-bg: #ffffff;
  --border-color: #cbd5e1;
  --border-focus: #246DFF;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --excel-header: #f8fafc;
  --excel-border: #cbd5e1;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-slate);
  color: var(--text-main);
  line-height: 1.5;
  padding-bottom: 40px;
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Global Navbar / Action Header */
.top-navbar {
  background: #ffffff;
  color: #333333;
  padding: 12px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  margin-bottom: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.brand-badge {
  background: var(--accent-orange);
  color: #fff;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.nav-actions {
  display: flex;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background-color: var(--primary-blue);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-accent {
  background-color: var(--accent-orange);
  color: white;
}
.btn-accent:hover {
  background-color: var(--accent-orange-hover);
}

.btn-outline {
  background-color: transparent;
  color: #475569;
  border: 1px solid var(--border-color);
}
.btn-outline:hover {
  background-color: #f1f5f9;
  color: var(--primary-dark);
}

.top-navbar .btn-outline {
  color: #333333;
  border: 1px solid #cbd5e1;
}
.top-navbar .btn-outline:hover {
  background-color: #f1f5f9;
  color: #333333;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.82rem;
}

/* SECTION 1: SOFTLAND PRODUCT SEARCH SYSTEM */
.softland-section {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  margin-bottom: 30px;
}

/* Search input expands to full width when categories are collapsed */
.search-input-group.expanded {
  max-width: 100% !important;
}

/* Menu Toggle Wrapper (Positioned over the category sidebar) */
.menu-toggle-wrapper {
  display: flex;
  align-items: center;
}

#btn-toggle-categories {
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

/* Category & Subcategory Sidebars */
.menu-panel {
  background: #fafafa;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.menu-title {
  background: #eef4ff;
  color: var(--primary-blue);
  font-weight: 800;
  font-size: 0.82rem;
  padding: 10px 14px;
  border-bottom: 2px solid var(--primary-blue);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-title.orange {
  color: var(--accent-orange);
  background: #fff5ee;
  border-bottom: 2px solid var(--accent-orange);
}

.category-list, .subcategory-list {
  list-style: none;
  max-height: 380px;
  overflow-y: auto;
}

/* ENFORCE MAX 2 LINES FOR MENU ITEMS AND OPTIMAL LEGIBILITY (ICON-FREE) */
.category-item, .subcategory-item {
  padding: 10px 12px;
  font-size: 0.84rem;
  font-weight: 600;
  display: block;
  width: 100%;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: all 0.15s ease;
  color: var(--text-main);
  text-align: left;
}

.category-item .cat-text, .subcategory-item .sub-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  word-break: break-word;
}

.category-item:hover, .subcategory-item:hover {
  background-color: #eef4ff;
  color: var(--primary-blue);
}

.category-item.active {
  background-color: var(--primary-blue);
  color: #ffffff;
  border-left: 4px solid var(--accent-orange);
}

.subcategory-item.active {
  background-color: #fff5ee;
  color: var(--accent-orange);
  border-left: 4px solid var(--accent-orange);
  font-weight: 700;
}

.cat-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Softland Excel Table Area */
.softland-main-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.search-box-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.search-input-group {
  display: flex;
  width: 100%;
  max-width: 600px;
  position: relative;
  transition: max-width 0.3s ease;
}

.search-input {
  width: 100%;
  padding: 12px 50px 12px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  border: 2px solid var(--border-color);
  border-radius: 30px;
  outline: none;
  transition: border-color 0.2s ease;
}

.search-input:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(36, 109, 255, 0.15);
}

.search-btn {
  position: absolute;
  right: 4px;
  top: 4px;
  bottom: 4px;
  width: 42px;
  border-radius: 50%;
  background: var(--accent-orange);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.search-btn:hover {
  background: var(--accent-orange-hover);
}

/* Excel Style Table */
.excel-table-container {
  overflow-x: auto;
  border: 1px solid var(--excel-border);
  border-radius: var(--radius-sm);
  max-height: 380px;
  overflow-y: auto;
  background: #ffffff;
  width: 100%;
}

.excel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
}

.excel-table th, .excel-table td {
  border: 1px solid var(--excel-border);
  padding: 6px 10px;
  white-space: nowrap;
}

.excel-table th {
  background-color: var(--excel-header);
  font-weight: 700;
  color: var(--text-main);
  position: sticky;
  top: 0;
  z-index: 10;
}

.excel-table tr.header-group th {
  text-align: center;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px;
}

.excel-table tr.header-group th.group-products {
  background-color: #eef4ff;
  color: var(--primary-blue);
  border-bottom: 2px solid var(--primary-blue);
}

.excel-table tr.header-group th.group-compare {
  background-color: #fff5ee;
  color: var(--accent-orange);
  border-bottom: 2px solid var(--accent-orange);
}

.excel-table tbody tr {
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.excel-table tbody tr:hover {
  background-color: #eef4ff !important;
}

.price-cell {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  text-align: right;
}

.softland-price {
  color: var(--primary-dark);
  font-weight: 700;
}

.stock-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

.stock-high { background: #dcfce7; color: #15803d; }
.stock-low { background: #fef3c7; color: #b45309; }
.stock-out { background: #fee2e2; color: #b91c1c; }

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

.comp-price.cheaper {
  color: var(--success);
  font-weight: 700;
}

.comp-price.expensive {
  color: var(--danger);
}

.add-item-btn {
  background: var(--primary-blue);
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.add-item-btn:hover {
  background: var(--accent-orange);
  transform: translateY(-1px);
}


/* SECTION 2: OFFICIAL COTIZACIÓN DOCUMENT (BOTTOM WIREFRAME SECTION) */
.cotizacion-document-wrapper {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 36px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  margin-top: 20px;
  position: relative;
}

/* Document Top Banner Header */
.doc-header-grid {
  border-bottom: 2px solid var(--primary-dark);
}

.company-branding {
  display: flex;
  align-items: center;
  gap: 20px;
}

.company-details p {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-top: 2px;
  margin-bottom: 2px;
}

.company-details small {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Red Border Official Document Box (Wireframe Requirement) */
.official-rut-box {
  border: 3px solid #dc2626;
  border-radius: 4px;
  padding: 16px;
  text-align: center;
  background: #fff;
  box-shadow: var(--shadow-sm);
  max-width: 260px;
  margin-left: auto;
}

.official-rut-box .rut-number {
  font-size: 0.95rem;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 4px;
}

.official-rut-box .doc-type {
  font-size: 1.2rem;
  font-weight: 900;
  color: #dc2626;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.official-rut-box .doc-folio {
  font-size: 1rem;
  font-weight: 800;
  color: #1e293b;
}

/* Client & Sale Meta Fields */
.client-info-section {
  margin-bottom: 24px;
  background: #f8fafc;
  padding: 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.field-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--primary-dark);
  min-width: 90px;
  text-transform: uppercase;
}

.field-input {
  flex: 1;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  outline: none;
  background: #ffffff;
  transition: border-color 0.2s;
}

.field-input:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 2px rgba(36, 109, 255, 0.15);
}

/* Quotation Items Table */
.quote-table-wrapper {
  margin-bottom: 24px;
  overflow-x: auto;
}

.quote-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.quote-table th {
  background: #f1f5f9;
  color: var(--primary-dark);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.8rem;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.quote-table td {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  vertical-align: middle;
}

.quote-table th.col-qty, .quote-table td.col-qty { width: 90px; text-align: center; }
.quote-table th.col-unit, .quote-table td.col-unit { width: 100px; text-align: center; }
.quote-table th.col-desc, .quote-table td.col-desc { width: auto; }
.quote-table th.col-price, .quote-table td.col-price { width: 130px; text-align: right; }
.quote-table th.col-total, .quote-table td.col-total { width: 140px; text-align: right; }
.quote-table th.col-actions, .quote-table td.col-actions { width: 70px; text-align: center; }

.qty-input, .price-input, .desc-input, .unit-input {
  width: 100%;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 0.88rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.qty-input {
  text-align: center;
  font-weight: 700;
}

.price-input {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}

.item-total-text {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--primary-dark);
}

.btn-remove-row {
  background: #fee2e2;
  color: #dc2626;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-remove-row:hover {
  background: #dc2626;
  color: white;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

/* Totals Summary Card (Bottom Right Box as per Wireframe) */

.terms-note-box {
  background: #f8fafc;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.terms-note-box h4 {
  color: var(--primary-dark);
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.terms-note-box ul {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Totals Summary Box */
.totals-summary-box {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: #ffffff;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.total-row:last-child {
  border-bottom: none;
}

.total-row .label {
  font-weight: 700;
  color: var(--primary-dark);
  text-transform: uppercase;
  font-size: 0.85rem;
}

.total-row .value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
}

.total-row.discount-row {
  background: #fefce8;
}

.total-row.discount-row input {
  width: 100px;
  text-align: right;
  padding: 4px 6px;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.total-row.neto-row {
  background: #f8fafc;
}

.total-row.grand-total {
  background: var(--primary-blue);
  color: #ffffff;
}

.total-row.grand-total .label,
.total-row.grand-total .value {
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 800;
}

.total-row.grand-total .value {
  color: #ffb07c;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--primary-dark);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 4px solid var(--accent-orange);
}

@keyframes slideIn {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* PRINT MEDIA STYLES */
@media print {
  body {
    background: white;
    padding: 0;
    font-size: 11pt;
  }

  .top-navbar,
  .softland-section,
  .nav-actions,
  .table-toolbar,
  .btn-remove-row,
  .col-actions,
  .toast-container {
    display: none !important;
  }

  .container {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  .cotizacion-document-wrapper {
    box-shadow: none;
    border: none;
    padding: 0;
    margin: 0;
  }

  .official-rut-box {
    border-color: #000 !important;
  }

  .official-rut-box .doc-type {
    color: #000 !important;
  }

  .field-input, .qty-input, .price-input, .desc-input, .unit-input {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
  }

  .total-row.grand-total {
    background: #f1f5f9 !important;
    color: #000 !important;
    border: 2px solid #000 !important;
  }

  .total-row.grand-total .label,
  .total-row.grand-total .value {
    color: #000 !important;
  }
}
