/* ============================================================
   GENERADOR DE PRESUPUESTOS COMERCIALES - FIJATE TOOLS
   Diseño corporativo, accesible, responsivo y 100 % local
   ============================================================ */

:root {
  color-scheme: dark;
  --bg-body: #0c0f17;
  --bg-surface: #141824;
  --bg-card: rgba(26, 32, 48, 0.7);
  --bg-card-hover: rgba(32, 40, 60, 0.85);
  --bg-input: #101420;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #ff8507;
  --primary: #ff8507;
  --primary-hover: #ff9924;
  --primary-glow: rgba(255, 133, 7, 0.25);
  --accent-cyan: #06b6d4;
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.25);
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', var(--font-sans);
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
  color-scheme: light;
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #ff8507;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
}

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

body {
  background-color: var(--bg-body);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   CABECERA
   ============================================================ */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-container {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-back-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: var(--transition);
}

.btn-back-tools:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo-box {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(255, 133, 7, 0.2), rgba(255, 153, 36, 0.2));
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.badge-local {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

/* ============================================================
   CONTENEDOR PRINCIPAL
   ============================================================ */
.main-wrapper {
  flex: 1;
  max-width: 1500px;
  width: 100%;
  margin: 1.5rem auto 4rem auto;
  padding: 0 1.5rem;
}

.tool-hero {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.tool-hero-text h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.4rem;
  background: linear-gradient(135deg, var(--text-primary) 40%, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tool-hero-text p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  max-width: 760px;
}

.hero-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

/* Layout 2 columnas: Editor y Previsualización */
.quote-grid {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 2rem;
  align-items: start;
}

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

/* Paneles */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  box-shadow: var(--shadow-subtle);
}

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

.panel-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-primary);
}

/* Formulario */
.form-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  margin-top: 1.25rem;
}

.form-section-title:first-of-type {
  margin-top: 0;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 640px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  padding: 0.65rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition);
}

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

/* Tabla de partidas dinámica */
.items-table-wrapper {
  margin-top: 1rem;
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.items-table th {
  text-align: left;
  padding: 0.5rem 0.4rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.items-table td {
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--border-color);
}

.items-table input,
.items-table select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
}

.items-table input:focus,
.items-table select:focus {
  border-color: var(--primary);
}

.btn-del-item {
  background: transparent;
  border: none;
  color: var(--accent-rose);
  cursor: pointer;
  padding: 0.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.btn-del-item:hover {
  background: rgba(244, 63, 94, 0.15);
}

.btn-add-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px dashed var(--border-color);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
  justify-content: center;
}

.btn-add-item:hover {
  border-color: var(--primary);
  background: rgba(255, 133, 7, 0.08);
}

/* ============================================================
   PREVISUALIZACIÓN DE HOJA A4 IMPRIMIBLE
   ============================================================ */
.preview-sheet-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sheet-a4 {
  background: #ffffff;
  color: #0f172a;
  border-radius: var(--radius-md);
  padding: 2.5rem;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  line-height: 1.5;
  font-family: var(--font-sans);
  min-height: 700px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 1.5rem;
}

.sheet-logo-area {
  max-width: 160px;
  max-height: 70px;
}

.sheet-logo-area img {
  max-width: 100%;
  max-height: 70px;
  object-fit: contain;
}

.sheet-quote-title {
  text-align: right;
}

.sheet-quote-title h2 {
  font-size: 1.6rem;
  font-weight: 800;
  color: #ff8507;
  text-transform: uppercase;
  letter-spacing: -0.02em;
}

.sheet-quote-meta {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 0.3rem;
}

.sheet-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.party-box h4 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #ff8507;
  margin-bottom: 0.4rem;
}

.party-box p {
  color: #334155;
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Tabla en la hoja */
.sheet-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.sheet-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 2px solid #cbd5e1;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.sheet-table td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
}

.sheet-table td.col-num {
  text-align: right;
  font-family: var(--font-mono);
}

.sheet-totals-area {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 2rem;
}

.sheet-totals-table {
  width: 280px;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.sheet-totals-table td {
  padding: 0.35rem 0.5rem;
  color: #475569;
}

.sheet-totals-table td:last-child {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  color: #0f172a;
}

.sheet-totals-table tr.total-final td {
  border-top: 2px solid #ff8507;
  font-size: 1.1rem;
  font-weight: 800;
  color: #ff8507;
  padding-top: 0.6rem;
}

.sheet-footer-clause {
  border-top: 1px solid #e2e8f0;
  padding-top: 1rem;
  margin-top: auto;
  font-size: 0.75rem;
  color: #64748b;
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.5rem;
  align-items: end;
}

.signature-box {
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 0.75rem;
  text-align: center;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 0.75rem;
}

/* ============================================================
   BOTONES CORPORATIVOS
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--primary);
  color: #0b0f17 !important;
  font-weight: 700;
  border: none;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 14px rgba(255, 133, 7, 0.35);
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: #000000 !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 133, 7, 0.5);
}

.preview-actions-bar {
  display: flex;
  gap: 0.75rem;
}

.btn-secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  flex: 1;
}

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

/* ============================================================
   MODAL Y TOAST
   ============================================================ */
.custom-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 1rem;
}

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

.custom-modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 460px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.custom-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.custom-modal-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.custom-modal-title h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

.custom-modal-body p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.custom-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.btn-modal-secondary {
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
}

.btn-modal-danger {
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--accent-rose);
  border: none;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

.toast-notification {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2000;
}

.toast-notification.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-notification svg {
  color: var(--accent-emerald);
}

/* FAQ */
.edu-section {
  margin-top: 3.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border-color);
}

.edu-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.faq-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
}

.faq-card h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.faq-card h4 svg {
  color: var(--primary);
  flex-shrink: 0;
}

.faq-card p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.55;
}

/* ============================================================
   ESTILOS DE IMPRESIÓN LIMPIA (A4)
   ============================================================ */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .app-header,
  .tool-hero,
  .panel:first-child,
  .preview-actions-bar,
  .edu-section,
  .fijate-footer,
  .custom-modal-backdrop,
  .toast-notification {
    display: none !important;
  }

  .main-wrapper {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  .quote-grid {
    grid-template-columns: 1fr !important;
  }

  .panel {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  .panel-header {
    display: none !important;
  }

  .sheet-a4 {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    width: 100% !important;
    min-height: auto !important;
  }
}
