/* Paleta accesible para tema claro */
:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f8f9fa;
  --border: #dee2e6;
  --text: #212529;
  --muted: #6c757d;
  --primary: #0d6efd;
  --primary-600: #0b5ed7;
  --secondary: #6c757d;
  --success: #198754;
  --success-600: #157347;
  --danger: #dc3545;
}

body { background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; }
.navbar { background: var(--panel); border-bottom: 1px solid var(--border); }
.container { max-width: 1100px; }
.card { background: var(--panel); border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.card h5, .card h6 { color: var(--text); }

.table { color: var(--text); }
.table thead { background: var(--panel-2); }
.table tbody tr:hover { background: #f8f9fa; }

.form-control, .form-select { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.form-control::placeholder { color: var(--muted); }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-secondary { background: var(--secondary); border-color: var(--secondary); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-600); border-color: var(--success-600); }

a { color: #4ea1ff; }
a:hover { color: #61b0ff; }

.text-muted { color: var(--muted) !important; }
.badge { background: #e9ecef; color: var(--text); }
.totales { background: var(--panel-2); padding: 12px; border-radius: 8px; border: 1px solid var(--border); }
.brand { font-weight: 700; letter-spacing: .2px; }
input[readonly] { opacity: .9; }

/* Modal personalizado para número de teléfono */
.phone-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  animation: fadeIn 0.3s;
}

.phone-modal-content {
  background-color: var(--panel);
  margin: 15% auto;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  animation: slideIn 0.3s;
}

.phone-modal h4 {
  margin-top: 0;
  color: var(--text);
  font-size: 1.25rem;
}

.phone-modal .form-group {
  margin-bottom: 15px;
}

.phone-modal label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: var(--text);
}

.phone-modal input[type="tel"] {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
}

.phone-modal input[type="tel"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
}

.phone-modal .modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.phone-modal .btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.phone-modal .btn-cancel {
  background: var(--secondary);
  color: white;
}

.phone-modal .btn-cancel:hover {
  background: #5a6268;
}

.phone-modal .btn-send {
  background: #10b981;
  color: white;
}

.phone-modal .btn-send:hover {
  background: #059669;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* Estilos específicos para navegación - compatibilidad cross-browser */
.navbar-nav .nav-item {
  display: block !important;
  visibility: visible !important;
  position: relative !important;
  z-index: 1000 !important;
  list-style: none !important;
}

.navbar-nav .nav-link {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: relative !important;
  z-index: 1001 !important;
  padding: 0.5rem 1rem !important;
  color: rgba(255, 255, 255, 0.75) !important;
  text-decoration: none !important;
  transition: color 0.15s ease-in-out !important;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus {
  color: rgba(255, 255, 255, 1) !important;
}

/* Asegurar visibilidad en Edge y Brave */
.navbar-collapse {
  display: flex !important;
  visibility: visible !important;
  position: relative !important;
  z-index: 999 !important;
  flex-basis: 100% !important;
  flex-grow: 1 !important;
  align-items: center !important;
}

.navbar-nav {
  display: flex !important;
  flex-direction: row !important;
  visibility: visible !important;
  position: relative !important;
  z-index: 998 !important;
  padding-left: 0 !important;
  margin-bottom: 0 !important;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Forzar visibilidad específica para los botones Logo y Fondo */
.navbar-nav .nav-item:nth-last-child(3),
.navbar-nav .nav-item:nth-last-child(2) {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: static !important;
}

/* Asegurar que Bootstrap no oculte elementos */
.navbar-nav > .nav-item {
  float: none !important;
  display: block !important;
}

@media (min-width: 992px) {
  .navbar-nav {
    flex-direction: row !important;
  }
  .navbar-nav .nav-item {
    display: block !important;
    margin-right: 1rem !important;
  }
}

/* Alinear valores del resumen a la derecha con ancho fijo */
#subtotal_general, #impuesto_general, #total_general {
  display: inline-block;
  min-width: 120px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Animación de entrada para panel derecho del Dashboard */
@keyframes panelSlideIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
.panel-slide-enter { animation: panelSlideIn 180ms ease-out; }

/* --- Login Hero (fondo + formulario centrado) --- */
.login-hero { min-height: 100vh; position: relative; background: #0b0f14 url('../assets/login-bg.jpg') center/cover no-repeat fixed; width: 100vw; left: 50%; right: 50%; margin-left: -50vw; margin-right: -50vw; margin-top: -1.5rem; margin-bottom: -1.5rem; }
.login-hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.55), rgba(0,0,0,.35)); }
.login-center { min-height: 100vh; display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; }
.login-card { width: 420px; max-width: 92vw; background: rgba(18,24,36,.42); border: 1px solid rgba(255,255,255,.22); border-radius: 12px; padding: 20px; box-shadow: 0 12px 28px rgba(0,0,0,.35); backdrop-filter: blur(6px); }
.login-logo-wrap { display: flex; justify-content: center; align-items: center; }
.login-logo { display: block; height: 72px; width: auto; max-width: 85%; margin: 0 auto; object-fit: contain; image-rendering: -webkit-optimize-contrast; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.login-title { color: #ffffff; font-weight: 700; font-size: 16px; }
.login-footer { color: #e8edf2; font-size: 12px; margin-top: 10px; display: flex; align-items: center; justify-content: space-between; }
.social-icons a { color: #ffffff; font-size: 18px; opacity: .9; }
.social-icons a:hover { opacity: 1; }

/* Overrides para inputs y botón dentro de la tarjeta de login */
.login-card .form-control, .login-card .form-select { background: #ffffff; color: #111827; border: 1px solid #d0d7de; }
.login-card .form-control::placeholder { color: #6b7280; }
.login-card .input-group-text { background: #ffffff; color: #6b7280; border: 1px solid #d0d7de; }
.login-card .form-check-label, .login-card .form-label { color: #e8edf2; }
.login-card .btn-primary { background: #22c1b9; border-color: #22c1b9; color: #fff; }
.login-card .btn-primary:hover { background: #1aaea7; border-color: #1aaea7; }

/* Estilos de impresión (PDF via navegador) */
@page {
  margin: 12mm;
}
@media print {
  body { background: #ffffff !important; color: #000000 !important; }
  nav, .navbar, .btn, .no-print { display: none !important; }
  .container { max-width: 100% !important; }
  .card, .totales { background: #ffffff !important; border-color: #cccccc !important; box-shadow: none !important; }
  .table { color: #000000 !important; }
  .table thead { background: #f3f4f6 !important; color: #000000 !important; }
  a { color: #000000 !important; text-decoration: none !important; }
  .shadow, .shadow-sm { box-shadow: none !important; }

  /* Mostrar/ocultar según contexto de impresión */
  .print-only { display: block !important; }
  .screen-only { display: none !important; }

  /* Diseño específico para factura/cotización */
  .invoice-print { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-variant-numeric: tabular-nums; }
  .page-frame { border: 1px solid #1565c0; border-radius: 12px; padding: 14px; }
  .invoice-header { display: grid; grid-template-columns: 1fr 280px; gap: 16px; align-items: start; margin-bottom: 10px; }
  .invoice-header { border-bottom: 2px solid #1565c0; padding-bottom: 10px; }
  .invoice-logo { height: 46px; width: auto; margin-bottom: 6px; object-fit: contain; image-rendering: -webkit-optimize-contrast; }
  .invoice-brand { font-weight: 700; font-size: 18px; }
  .invoice-meta { text-align: right; }
  .invoice-title { font-size: 26px; font-weight: 800; letter-spacing: .3px; }
  .invoice-meta .meta-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 2px 0; border-bottom: 1px dotted #b3c5e7; }
  .invoice-meta .meta-line:last-child { border-bottom: none; }
  .bar-title { background: #1565c0; color: #fff; padding: 6px 8px; font-weight: 700; font-size: 12px; display:flex; align-items:center; gap:8px; }
  .box { border: 1px solid #cfd8dc; border-radius: 2px; padding: 8px; }
  /* Bordes y líneas al color de cotizaciones */
  .box { border-color: #1565c0; }
  .table-invoice { width: 100%; border-collapse: collapse; }
  .table-invoice th { background: #1565c0; color: #fff; padding: 6px; font-weight: 700; border: 1px solid #0e4ea8; }
  .table-invoice td { padding: 6px; border: 1px solid #1565c0; }
  .table-invoice tbody tr:nth-child(even) { background: #f3f7ff; }
  .totals-grid { display: grid; grid-template-columns: 1fr 260px; gap: 12px; margin-top: 12px; }
  .totals-box { border: 1px solid #1565c0; padding: 0; }
  .totals-head { background: #1565c0; color: #fff; font-weight: 700; padding: 6px 8px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .totals-body { padding: 8px; }
  .grand-total { background: #1565c0; color: #fff; font-weight: 800; padding: 6px 8px; border-radius: 4px; display: flex; justify-content: space-between; }
  .terms { margin-top: 12px; }
  .terms .box { padding: 10px; }
  .invoice-footer { margin-top: 12px; font-size: 11px; color: #333; }
  .invoice-footer .contact { margin-bottom: 4px; }
  .invoice-footer .thanks { font-style: italic; }

  /* Iconos para impresión */
  .icon-inline { color: #fff; font-size: 12px; line-height: 1; }
  .label-icon { color: #1565c0; margin-right: 6px; }
}

/* Ocultar elementos sólo de impresión en pantalla habitual */
.print-only { display: none; }
.screen-only { display: block; }

/* Estilos de vista previa en pantalla para la factura/cotización
   (se aplican cuando .print-only está visible en preview=1) */
@media screen {
  /* Diseño específico para factura/cotización (duplicado del bloque de impresión) */
  .invoice-print { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-variant-numeric: tabular-nums; }
  .page-frame { border: 1px solid #1565c0; border-radius: 12px; padding: 14px; }
  .invoice-header { display: grid; grid-template-columns: 1fr 280px; gap: 16px; align-items: start; margin-bottom: 10px; }
  .invoice-header { border-bottom: 2px solid #1565c0; padding-bottom: 10px; }
  .invoice-logo { height: 46px; width: auto; margin-bottom: 6px; object-fit: contain; image-rendering: -webkit-optimize-contrast; }
  .invoice-brand { font-weight: 700; font-size: 18px; }
  .invoice-meta { text-align: right; }
  .invoice-title { font-size: 26px; font-weight: 800; letter-spacing: .3px; }
  .invoice-meta .meta-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 2px 0; border-bottom: 1px dotted #b3c5e7; }
  .invoice-meta .meta-line:last-child { border-bottom: none; }
  .bar-title { background: #1565c0; color: #fff; padding: 6px 8px; font-weight: 700; font-size: 12px; display:flex; align-items:center; gap:8px; }
  .box { border: 1px solid #1565c0; border-radius: 2px; padding: 8px; }
  .table-invoice { width: 100%; border-collapse: collapse; }
  .table-invoice th { background: #1565c0; color: #fff; padding: 6px; font-weight: 700; border: 1px solid #0e4ea8; }
  .table-invoice td { padding: 6px; border: 1px solid #1565c0; }
  .table-invoice tbody tr:nth-child(even) { background: #f3f7ff; }
  .totals-grid { display: grid; grid-template-columns: 1fr 260px; gap: 12px; margin-top: 12px; }
  .totals-box { border: 1px solid #1565c0; padding: 0; }
  .totals-head { background: #1565c0; color: #fff; font-weight: 700; padding: 6px 8px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .totals-body { padding: 8px; }
  .grand-total { background: #1565c0; color: #fff; font-weight: 800; padding: 6px 8px; border-radius: 4px; display: flex; justify-content: space-between; }
  .terms { margin-top: 12px; }
  .terms .box { padding: 10px; }
  .invoice-footer { margin-top: 12px; font-size: 11px; color: #333; }
  .invoice-footer .contact { margin-bottom: 4px; }
  .invoice-footer .thanks { font-style: italic; }

  /* Iconos de etiquetas y en línea en modo pantalla */
  .icon-inline { color: #fff; font-size: 12px; line-height: 1; }
  .label-icon { color: #1565c0; margin-right: 6px; }
}