@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;500;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg-color: #f8fafc;
  --surface: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --primary: #1e293b;
  --secondary: #b45309; /* Deep Gold/Amber */
  --accent: #d4af37; /* Antique Gold */
  --border: #e2e8f0;
  --success: #15803d;
  --error: #be123c;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 2.5rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.logo-section img {
  height: 50px;
  width: auto;
  object-fit: contain;
}

h1 {
  font-family: var(--font-title);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--primary);
  line-height: 1;
}

.tagline {
  font-size: 0.8rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.dashboard {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 3rem;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

h2 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

select, input, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fdfdfd;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  transition: all 0.2s ease;
}

select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.1);
}

.btn {
  width: 100%;
  padding: 0.85rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  border: none;
  font-size: 0.95rem;
}

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

.btn-primary:hover {
  background: #2d3e50;
  transform: translateY(-1px);
}

.btn-gold {
  background: var(--secondary);
  color: white;
}

.btn-gold:hover {
  background: #92400e;
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}

.btn-outline:hover {
  border-color: var(--text-muted);
  color: var(--text-main);
}

.file-input-wrapper {
  position: relative;
  overflow: hidden;
}

.file-input-wrapper input[type=file] {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.quote-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.quote-header {
  padding: 2.5rem;
  background: #fcfcfc;
  border-bottom: 2px solid var(--bg-color);
}

.quote-title {
  font-family: var(--font-title);
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.quote-content {
  padding: 2.5rem;
  flex-grow: 1;
}

.quote-table {
  width: 100%;
  border-collapse: collapse;
}

.quote-table th {
  text-align: left;
  padding: 1rem;
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.quote-table td {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.95rem;
}

.price-cell {
  text-align: right;
  font-family: monospace;
}

.summary-section {
  padding: 2.5rem;
  background: #fcfcfc;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.summary-box {
  width: 320px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  gap: 20px; /* Minimum gutter as requested */
}

.summary-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 2px solid var(--primary);
  color: var(--primary);
  font-weight: 700;
  font-size: 1.4rem;
  gap: 20px; /* Minimum gutter */
  transition: all 0.3s ease;
}

.summary-total.long-value {
  font-size: 1.15rem; /* ~15% reduction from 1.4rem */
}

.summary-total.long-value span:first-child {
  font-size: 1rem;
  flex-shrink: 1;
}

.empty-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 400px;
  color: #cbd5e1;
}

.empty-preview i {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.remove-item {
  color: #94a3b8;
  cursor: pointer;
  transition: color 0.2s;
}

.remove-item:hover {
  color: var(--error);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: #dcfce7;
  color: #166534;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* --- Cloud Login & Editor Styles --- */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  padding: 3rem;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  text-align: center;
  max-width: 450px;
  width: 90%;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-circle {
  width: 100px;
  height: 100px;
  background: #f1f5f9;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.btn-large {
  padding: 1.25rem;
  font-size: 1.1rem;
  margin-top: 2rem;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--surface);
  width: 95%;
  max-width: 1100px;
  max-height: 90vh;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

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

.close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 2rem;
  overflow-y: auto;
}

/* Tabs & Editor */
.editor-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  overflow-x: auto;
}

.tab-btn {
  padding: 0.75rem 1.25rem;
  border: none;
  background: none;
  font-family: var(--font-title);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
}

.editor-actions {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
}

.editor-table-container {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  max-height: 500px;
}

#editor-table {
  width: 100%;
  border-collapse: collapse;
}

#editor-table th, #editor-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

#editor-table th {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 10;
}

.edit-input {
  width: 100%;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

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


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

.animate-spin {
  animation: spin 1s linear infinite;
}

#economic-modal .form-group input[readonly] {
  cursor: not-allowed;
  opacity: 0.7;
}

#economic-modal .modal-content {
  border-top: 5px solid var(--secondary);
}

/* ===== COTIZACIONES RECIENTES ===== */
#recent-quotes-select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(180, 83, 9, 0.35);
  border-radius: 8px;
  background: linear-gradient(135deg, #fffbf3 0%, #fff7e6 100%);
  color: #92400e;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.25s ease;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23b45309' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
  box-shadow: 0 1px 4px rgba(180, 83, 9, 0.1);
}

#recent-quotes-select:hover {
  border-color: var(--secondary);
  background-color: #fff3d6;
  box-shadow: 0 2px 8px rgba(180, 83, 9, 0.2);
}

#recent-quotes-select:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.15);
}

#recent-quotes-select option {
  background: #ffffff;
  color: #1e293b;
  font-weight: 500;
}

#recent-quotes-select option:first-child {
  color: #94a3b8;
  font-style: italic;
  font-weight: 400;
}

#new-quote-btn {
  border: none;
  background: transparent;
  color: var(--secondary);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

#new-quote-btn:hover {
  background: rgba(180, 83, 9, 0.1);
  color: #92400e;
}

/* ===== AUTOCOMPLETE & REAL-TIME SEARCH ===== */
.autocomplete-wrapper {
  position: relative;
  width: 100%;
}

.search-input-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-input-box input {
  padding-left: 2.3rem;
  padding-right: 2.2rem;
  width: 100%;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.search-input-box input:focus {
  background: #ffffff;
}

.search-input-icon {
  position: absolute;
  left: 0.75rem;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear-btn {
  position: absolute;
  right: 0.65rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: #f1f5f9;
  color: #64748b;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  transition: all 0.15s ease;
}

.search-clear-btn:hover {
  background: #fee2e2;
  color: #ef4444;
}

.search-clear-btn.visible {
  display: flex;
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 310px;
  overflow-y: auto;
  background: #ffffff;
  border: 1.5px solid rgba(180, 83, 9, 0.25);
  border-radius: 10px;
  box-shadow: 0 12px 28px -4px rgba(15, 23, 42, 0.18), 0 4px 10px -2px rgba(15, 23, 42, 0.08);
  z-index: 999;
  display: none;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f8fafc;
}

.autocomplete-dropdown::-webkit-scrollbar {
  width: 6px;
}

.autocomplete-dropdown::-webkit-scrollbar-track {
  background: #f8fafc;
  border-radius: 0 10px 10px 0;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 6px;
}

.autocomplete-dropdown.show {
  display: block;
  animation: dropdownFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.autocomplete-header-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.85rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.autocomplete-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.autocomplete-item {
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background-color: #fffbeb;
  border-left: 3.5px solid var(--secondary);
  padding-left: calc(0.85rem - 3.5px);
}

.autocomplete-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.autocomplete-item-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.35;
  flex: 1;
}

.autocomplete-item-code {
  font-size: 0.72rem;
  font-weight: 700;
  color: #475569;
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: monospace;
}

.autocomplete-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.autocomplete-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.autocomplete-price {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--secondary);
  white-space: nowrap;
}

.autocomplete-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.badge-inversores, .badge-eri {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-paneles, .badge-erp {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-estructuras, .badge-ere {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.badge-equipos, .badge-otros, .badge-erb, .badge-equ {
  background: #f3e8ff;
  color: #6b21a8;
  border: 1px solid #e9d5ff;
}

.badge-servicios, .badge-servicio, .badge-ers, .badge-ser {
  background: #ccfbf1;
  color: #0f766e;
  border: 1px solid #99f6e4;
}

.badge-clientes, .badge-erc {
  background: #e2e8f0;
  color: #334155;
  border: 1px solid #cbd5e1;
}

mark.autocomplete-match {
  background-color: #fef08a;
  color: #713f12;
  font-weight: 700;
  border-radius: 2px;
  padding: 0 1px;
}

.autocomplete-empty {
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.autocomplete-empty i {
  color: #94a3b8;
  width: 24px;
  height: 24px;
}

.selected-item-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 0.4rem;
}


