/* ====== BASE ====== */
html, body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;

  background: #f3f4f6;
}

/* ====== LAYOUT GENERAL ====== */
.costeo-layout {
  margin-top: 90px; /* altura navbar */
  height: calc(100vh - 90px); /* ðŸ”¥ altura real sin zoom */
  display: flex;
  flex-direction: column;
}

/* ====== PANEL SUPERIOR ====== */
.top-panel {
  background: #ffffff;
  padding: 20px 40px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0; /* nunca se comprime */
}

/* ====== INPUTS ====== */
.inputs-row {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.inputs-row .form-group {
  display: flex;
  flex-direction: column;
  min-width: 170px;
}

.inputs-row label {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #6b7280;
}

.inputs-row input,
.inputs-row select {
  height: 36px;
  font-size: 14px;
}

/* ===== PREMIUM METRICS PANEL ===== */

.premium-metrics {
  background: linear-gradient(180deg, #ffffff, #f9fafb);
  padding: 20px 40px;
  border-bottom: 1px solid #e5e7eb;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.metric-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 
    0 4px 12px rgba(0,0,0,0.04),
    0 1px 2px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: all 0.25s ease;
  border: 1px solid #f1f5f9;
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: 
    0 10px 25px rgba(0,0,0,0.06),
    0 4px 8px rgba(0,0,0,0.05);
}

/* Label */
.metric-label {
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

/* Value */
.metric-value {
  font-size: 26px;
  font-weight: 700;
  color: #111827;
}

/* Precio actual destacado */
.primary-metric {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: white;
  border: none;
}

.primary-metric .metric-label {
  color: rgba(255,255,255,0.8);
}

.primary-metric .metric-value {
  color: white;
  font-size: 28px;
}

/* ===== PREMIUM METRICS PANEL COMPACTO ===== */

.premium-metrics {
  background: linear-gradient(180deg, #ffffff, #f9fafb);
  padding: 10px 30px; /* ðŸ”¥ reducido */
  border-bottom: 1px solid #e5e7eb;
}

/* Grid mÃ¡s compacto */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; /* ðŸ”¥ menos separaciÃ³n */
}

/* Tarjetas mÃ¡s bajas */
.metric-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 10px 18px;
  box-shadow: 
    0 2px 6px rgba(0,0,0,0.04),
    0 1px 2px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: row; /* ðŸ”¥ ahora en fila */
  align-items: center;
  justify-content: space-between; /* texto izquierda, valor derecha */
  transition: all 0.2s ease;
  border: 1px solid #f1f5f9;
}
.metric-label {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}

.metric-value {
  font-size: 20px;
  font-weight: 700;
}

/* Hover mÃ¡s sutil */
.metric-card:hover {
  transform: translateY(-2px);
}

/* Label mÃ¡s pequeÃ±o */
.metric-label {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}

/* Valor mÃ¡s compacto */
.metric-value {
  font-size: 20px; /* ðŸ”¥ antes 26px */
  font-weight: 700;
}

/* ===== Precio Actual ===== */
.primary-metric {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: white;
  border: none;
}

.primary-metric .metric-label {
  color: rgba(255,255,255,0.8);
}

.primary-metric .metric-value {
  color: white;
  font-size: 22px;
}

/* ===== Precio Sugerido Oscuro ===== */
.highlight {
  background: linear-gradient(135deg, #0f172a, #1e293b) !important;
  border: none !important;
  color: white !important;
}

.highlight .metric-label {
  color: rgba(255,255,255,0.7) !important;
}

.highlight .metric-value {
  color: #34d399 !important;
  font-size: 22px;
  font-weight: 800;
}
/* ====== CONTENEDOR TABLA ====== */
.table-container {
  flex: 1; /* ocupa todo el espacio restante */
  display: flex;
  flex-direction: column;
  min-height: 0; /* ðŸ”¥ CLAVE */
  background: #ffffff;
}

/* Header tabla */
.table-container > .d-flex {
  flex-shrink: 0;
}

/* ====== SCROLL SOLO EN TABLA ====== */
.table-scroll {
    flex: 1;
    min-height: 0; /* 🔥 esto permite que flex reduzca altura */
    overflow-y: auto;
    overflow-x: auto;
}

/* ====== TABLA ====== */
#insumosTable {
  margin: 0;
}

#insumosTable thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: white;
}

/* Scroll mÃ¡s estÃ©tico (opcional pero pro) */
.table-scroll::-webkit-scrollbar {
  width: 8px;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}


/* ===== INPUT COMBINADO PREMIUM ===== */
.input-group-premium {
  display: flex;
  align-items: stretch;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
  transition: all 0.2s ease;
}

.input-group-premium:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Input cantidad */
.input-group-premium .form-control {
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* Select unidad */
.input-group-premium .form-select {
  border: none !important;
  border-left: 1px solid #e5e7eb !important;
  border-radius: 0 !important;
  min-width: 120px;
  padding-right: 30px; /* 🔥 espacio para flecha */
  background-color: #f9fafb !important;
  background-position: right 8px center !important;
  background-size: 12px !important;
  font-weight: 500;
  cursor: pointer;
  color: #111827; /* 🔥 forzar color visible */
}
.input-group-premium .form-select option {
  color: #111827;
}

/* Quitar foco azul feo de bootstrap */
.input-group-premium .form-control:focus,
.input-group-premium .form-select:focus {
  box-shadow: none !important;
}
.th-alert {
  color: #dc2626;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.th-success {
  color: #34d399 !important;
  font-weight: 600;
}
/* ===== GANANCIA ===== */
.profit-card {
  background: linear-gradient(135deg, #14532d, #166534);
  color: white;
  border: none;
}

.profit-card .metric-label {
  color: rgba(255,255,255,0.8);
}

.profit-card .metric-value {
  color: #86efac;
  font-weight: 800;
}

/* ===== SERVICIOS ===== */
.services-card {
  background: linear-gradient(135deg, #7c2d12, #b45309);
  color: white;
  border: none;
}

.services-card .metric-label {
  color: rgba(255,255,255,0.8);
}

.services-card .metric-value {
  color: #fde68a;
  font-weight: 800;
}
/* =========================================================
   ðŸ“± RESPONSIVE MOBILE OPTIMIZATION - RESTIFY COSTEO
   No modifica tu CSS actual, solo lo adapta en mÃ³vil
========================================================= */

@media (max-width: 992px) {

  /* Permitir scroll general en mÃ³vil */
  body {
    overflow: auto;
  }

  .costeo-layout {
    height: auto;
    margin-top: 70px;
  }

  /* ===== PANEL SUPERIOR ===== */

  .top-panel {
    padding: 18px 16px;
  }

  /* Inputs en columna */
  .inputs-row {
    flex-direction: column;
    gap: 14px;
  }

  .inputs-row .form-group {
    width: 100%;
    min-width: 100%;
  }

  .inputs-row input,
  .inputs-row select {
    height: 42px;
    font-size: 16px; /* evita zoom automÃ¡tico iOS */
  }

  /* ===== METRICS ===== */

  .premium-metrics {
    padding: 12px 16px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .metric-card {
    padding: 12px 14px;
  }

  .metric-value {
    font-size: 18px;
  }

  /* ===== TABLA RESPONSIVE INTELIGENTE ===== */

  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #insumosTable {
    min-width: 900px; /* fuerza scroll horizontal elegante */
  }

  /* BotÃ³n agregar insumo */
  #addInsumoBtn {
    width: 100%;
    margin-top: 10px;
  }

  /* Header tabla */
  .d-flex.justify-content-between {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }

  /* Inputs dentro de tabla mÃ¡s cÃ³modos */
  .input-group-premium .form-control,
  .input-group-premium .form-select {
    font-size: 15px;
  }

}


/* =========================================================
   ðŸ“± EXTRA SMALL DEVICES (iPhone SE / Android pequeÃ±os)
========================================================= */

@media (max-width: 576px) {

  .top-panel h4 {
    font-size: 18px;
  }

  .metric-label {
    font-size: 11px;
  }

  .metric-value {
    font-size: 17px;
  }

  .premium-metrics {
    padding: 10px 12px;
  }

 

}
.custom-select-wrapper {
  position: relative;
}

.custom-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  background: #fff;
  z-index: 1000;
  display: none;
  list-style: none;
  margin: 0;
  padding: 0;
}

.custom-options li {
  padding: 6px 12px;
  cursor: pointer;
}

.custom-options li:hover {
  background-color: #f3f4f6;
}
/* Modal con zoom inicial al 90% */



/* ===== MODAL SIN SCROLL GLOBAL ===== */
#modalProducto .modal-dialog {
    height: 95vh;
    max-height: 95vh;
    margin: 0 auto;
    display: flex;
}

#modalProducto .modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#modalProducto .modal-body {
    flex: 1;
    min-height: 0;   /* 🔥 CLAVE ABSOLUTA */
    display: flex;
    flex-direction: column;
}
#modalProducto {
    overflow: visible !important;
}

#modalProducto .modal-body {
    padding: 0;          /* elimina padding extra que genera espacio */
    overflow: visible !important;    /* no scroll aquí */
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

/* Mantener scroll solo en tabla / secciones internas */
.table-scroll {
    overflow-y: auto;
    overflow-x: auto;
    flex: 1 1 auto;
}
/* Evita margen extra dentro del modal */
#modalProducto .costeo-layout {
    margin-top: 0;       /* quitar margen superior global */
    height: 100%;        /* ocupar todo el modal */
    display: flex;
    flex-direction: column;
}
/* Solo el contenido se escala */
#modalProducto .modal-zoom {
    transform: scale(0.9);
    transition: transform 0.3s ease-in-out;
}

#modalProducto.show .modal-zoom {
    transform: scale(1);
}
/* Lista global insumos */
.global-options {
    position: absolute;
    z-index: 1055; /* más alto que el modal */
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    overflow-y: auto;
    display: none;
    max-height: 200px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.global-options li {
    padding: 6px 12px;
    cursor: pointer;
}

.global-options li:hover {
    background-color: #f3f4f6;
}
.custom-select-wrapper {
    position: relative;
}

/* Forzar despliegue hacia arriba */
.custom-select-wrapper {
    position: relative;
}

.custom-select-wrapper .custom-options {
    position: absolute !important;
    bottom: 100% !important;   /* SIEMPRE arriba */
    top: auto !important;
    left: 0;
    right: 0;
    margin-bottom: 6px;
    z-index: 9999 !important;
}
.table-scroll {
  display: block !important;
  max-height: 400px !important;   /* Altura fija */
  height: 400px !important;       /* Fuerza altura */
  overflow-y: scroll !important;  /* Scroll SIEMPRE visible */
  overflow-x: auto !important;
}

.table-scroll table {
  margin-bottom: 0 !important;
}

.table-scroll thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 5;
  background: #f8f9fa !important;
}

.registro-overlay{
    position:fixed;
    inset:0;
    background:rgba(0,0,0,0.65);
    backdrop-filter:blur(6px);
    display:flex;
    align-items:center;
    justify-content:center;
    z-index:9999;
}

.registro-box{
    background:#111827;
    padding:30px;
    border-radius:16px;
    width:350px;
    text-align:center;
    box-shadow:0 0 40px rgba(0,0,0,0.5);
}

.registro-box h3{
    color:#fff;
    margin-bottom:10px;
}

.registro-box p{
    color:#9ca3af;
    font-size:14px;
    margin-bottom:20px;
}

.registro-box input{
    width:100%;
    margin-bottom:12px;
    padding:10px;
    border:none;
    border-radius:8px;
    background:#1f2937;
    color:#fff;
}

.registro-box button{
    width:100%;
    padding:12px;
    border:none;
    border-radius:8px;
    background:linear-gradient(45deg,#10b981,#059669);
    color:#fff;
    font-weight:bold;
    cursor:pointer;
}
/* ========================================
   RESTIFY ULTRA MODAL
======================================== */

.restify-modal{
    position:fixed;
    inset:0;
    background:rgba(15,23,42,.65);
    backdrop-filter:blur(14px);
    display:flex;
    justify-content:center;
    align-items:center;
    z-index:9999;
    animation:fadeIn .25s ease;
}

/* CARD */

.restify-modal-card{
    width:430px;
    max-width:95%;
    padding:38px;
    border-radius:22px;
    background:linear-gradient(145deg,#ffffff,#f1f5f9);
    box-shadow:
        0 25px 60px rgba(0,0,0,.18),
        0 0 0 1px rgba(255,255,255,.6) inset;
    animation:popIn .25s ease;
    position:relative;
}

/* HEADER */

.restify-modal-header h3{
    margin:0 0 6px 0;
    font-size:24px;
    font-weight:700;
    color:var(--restify-text);
}

.restify-modal-header p{
    margin:0 0 28px 0;
    font-size:14px;
    color:var(--restify-muted);
}

/* INPUTS */

.restify-form-group{
    margin-bottom:16px;
}

.restify-form-group input{
    width:100%;
    padding:13px 16px;
    border-radius:14px;
    border:1px solid var(--restify-border);
    background:var(--restify-bg);
    font-size:14px;
    transition:all .25s ease;
}

.restify-form-group input:focus{
    outline:none;
    background:#fff;
    border-color:var(--restify-green-light);
    box-shadow:0 0 0 4px rgba(34,197,94,.15);
}

/* BOTÓN VERDE RESTIFY PREMIUM */

.restify-btn-success{
    width:100%;
    padding:14px;
    border:none;
    border-radius:16px;
    font-size:15px;
    font-weight:600;
    color:#fff;
    cursor:pointer;
    background:linear-gradient(135deg,var(--restify-green),var(--restify-green-dark));
    box-shadow:0 12px 25px rgba(22,163,74,.35);
    transition:all .25s ease;
    position:relative;
    overflow:hidden;
}

/* Hover efecto SaaS */

.restify-btn-success:hover{
    transform:translateY(-3px);
    box-shadow:0 18px 35px rgba(22,163,74,.45);
}

/* Click efecto */

.restify-btn-success:active{
    transform:scale(.98);
}

/* Animaciones */

@keyframes fadeIn{
    from{opacity:0}
    to{opacity:1}
}

@keyframes popIn{
    from{opacity:0; transform:scale(.96)}
    to{opacity:1; transform:scale(1)}
}

/* ========================================
   DARK MODE RESTIFY
======================================== */

body.dark-mode .restify-modal-card{
    background:linear-gradient(145deg,#1e293b,#0f172a);
    box-shadow:
        0 25px 60px rgba(0,0,0,.6),
        0 0 0 1px rgba(255,255,255,.05) inset;
}

body.dark-mode .restify-modal-header h3{
    color:#f1f5f9;
}

body.dark-mode .restify-modal-header p{
    color:#94a3b8;
}

body.dark-mode .restify-form-group input{
    background:#0f172a;
    border-color:#334155;
    color:#e2e8f0;
}

body.dark-mode .restify-form-group input:focus{
    border-color:var(--restify-green-light);
    box-shadow:0 0 0 4px rgba(34,197,94,.25);
}