/* =============================================================
   PT&I Theme — Postharvest Technology & Innovation v1.0.0
   Paleta: #0d2550 (navy), #132d5e (sidebar), #4a9eff (accent)
   ============================================================= */

:root {
  --pti-navy:    #0d2550;
  --pti-sidebar: #132d5e;
  --pti-accent:  #4a9eff;
}

/* ---- Login Page Background ---- */
.login-page {
  background: radial-gradient(ellipse at center, #1a3a6e 0%, #0d2550 65%, #071830 100%) !important;
  min-height: 100vh;
}

/* ---- Login Box Width ---- */
.login-page .login-box {
  width: 720px;
  max-width: 96vw;
}

/* ---- Card Split Layout ---- */
.login-page .login-box .card {
  display: flex;
  flex-direction: row;
  overflow: hidden;
  border-radius: 12px;
  border: none;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  min-height: 440px;
  margin-bottom: 0;
}

/* ---- Left Panel — PT&I Identity ---- */
.pti-login-panel {
  flex: 0 0 42%;
  background: linear-gradient(160deg, #0d2550 0%, #132d5e 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.5rem 2rem;
}

.pti-login-panel h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: #fff;
}

.pti-login-panel p {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.6;
  margin-bottom: 0;
}

.pti-login-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(74, 158, 255, 0.18);
  color: #4a9eff;
  border: 1px solid rgba(74, 158, 255, 0.4);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 1.5rem;
}

/* ---- Right Panel — Form ---- */
.login-page .login-box .login-card-body {
  flex: 1;
  background: #fff;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.pti-login-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #0d2550;
  margin-bottom: 0.2rem;
}

.pti-login-subtitle {
  font-size: 0.84rem;
  color: #6c757d;
  margin-bottom: 1.4rem;
}

/* ---- Labels ---- */
.login-card-body label {
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: #495057;
  margin-bottom: 4px;
}

/* ---- Inputs ---- */
.login-card-body .form-control:focus {
  border-color: #4a9eff;
  box-shadow: 0 0 0 0.2rem rgba(74, 158, 255, 0.25);
}

.login-card-body .input-group-text {
  background-color: #f4f6f9;
  border-color: #ced4da;
  color: #0d2550;
}

/* ---- Primary Button ---- */
.login-card-body .btn-primary {
  background-color: #0d2550;
  border-color: #0d2550;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 0.55rem 1rem;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.login-card-body .btn-primary:hover,
.login-card-body .btn-primary:focus {
  background-color: #132d5e;
  border-color: #132d5e;
  box-shadow: 0 4px 14px rgba(13, 37, 80, 0.35);
}

/* ---- Alerts ---- */
.login-card-body .alert {
  font-size: 0.84rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

/* ---- Responsive: stack on small screens ---- */
@media (max-width: 576px) {
  .login-page .login-box {
    width: 100%;
    padding: 0 8px;
    margin-top: 0;
  }

  .login-page .login-box .card {
    flex-direction: column;
    border-radius: 8px;
  }

  .pti-login-panel {
    flex: none;
    padding: 1.5rem;
  }

  .login-page .login-box .login-card-body {
    padding: 1.5rem;
  }
}

/* ================================================================
   Navbar & Sidebar — aplica en el portal interno (post-login)
   ================================================================ */

.main-header.navbar {
  background-color: #0d2550 !important;
  border-bottom: none;
}

.main-sidebar,
.main-sidebar::before {
  background-color: #132d5e !important;
}

.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link.active,
.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link:focus {
  background-color: rgba(74, 158, 255, 0.15) !important;
  border-left: 3px solid #4a9eff;
  color: #fff !important;
}

/* ---- Nav Tabs ---- */
.nav-tabs {
  border-bottom: 3px solid #0d2550;
}
.nav-tabs .nav-link {
  color: #0d2550;
  background-color: #e8f0f5;
  border: 1px solid #0d2550;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  font-weight: 600;
  padding: 8px 20px;
  margin-right: 4px;
  transition: background-color 0.2s, color 0.2s;
}
.nav-tabs .nav-link:hover {
  background-color: #b0cfe0;
  color: #0d2550;
}
.nav-tabs .nav-link.active {
  background-color: #0d2550 !important;
  color: #fff !important;
  border-color: #0d2550 !important;
  border-bottom-color: #0d2550 !important;
  font-weight: 700;
}

/* ---- Data table header rows ---- */
.header-row {
  background-color: #0d2550 !important;
  color: #fff !important;
  font-size: 12px;
}

/* ---- Inline input utility ---- */
.inline-input {
  width: 100px;
  display: inline-block;
  font-size: 14px;
  margin-right: 10px;
}

/* ---- Utilidades generales ---- */
.clscaja { display: none; }
.dataTables_filter { float: right !important; }

/* ---- Sidebar nav-link hover (non-active) ---- */
.sidebar-dark-primary .nav-sidebar .nav-link:not(.active):hover {
  background-color: rgba(255, 255, 255, 0.08);
}

/* ---- Sidebar emoji icons ---- */
.nav-sidebar .pti-nav-emoji { font-size: 1rem; line-height: 1; text-align: center; }

/* ================================================================
   Componentes reutilizables — vistas internas del portal
   ================================================================ */

/* ---- Hover de filas en tablas ---- */
table tbody tr:not(.nothover) { cursor: pointer; }
table tbody tr:not(.nothover):hover td,
table tbody tr:not(.nothover):hover th {
  background-color: rgba(74, 158, 255, 0.07);
}

/* ---- Card Header PT&I ---- */
.pti-card-header {
  background: linear-gradient(135deg, #0d2550 0%, #1f4e79 100%) !important;
  color: #fff !important;
  padding: 0.85rem 1.25rem;
  border-bottom: none !important;
  border-radius: 4px 4px 0 0;
}
.pti-card-header .card-title {
  color: #fff !important;
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pti-card-header .card-title i { color: #4a9eff !important; font-size: 1.1rem; }
.pti-card-header .card-subtitle { color: rgba(255,255,255,.75) !important; font-size: 0.82rem; margin: 4px 0 0 0; }

/* ---- Botón Guardar ---- */
.pti-btn-save {
  background: #4a9eff !important;
  border-color: #4a9eff !important;
  border-radius: 8px;
  font-weight: 600;
  transition: box-shadow .2s ease, transform .15s ease;
}
.pti-btn-save:hover { box-shadow: 0 4px 14px rgba(74,158,255,.45); transform: translateY(-1px); }

/* ---- Botón Volver ---- */
.pti-btn-back {
  background: #1f4e79 !important;
  border-color: #1f4e79 !important;
  color: #fff !important;
  border-radius: 8px;
  font-weight: 600;
  transition: box-shadow .2s ease, transform .15s ease;
}
.pti-btn-back:hover { box-shadow: 0 4px 14px rgba(31,78,121,.45); transform: translateY(-1px); }

/* ---- Botones de acción en tablas (34×34px) ---- */
.btn.btn-sm.pti-btn-slate {
  background: #1f4e79 !important;
  border-color: #1f4e79 !important;
  color: #fff !important;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow .2s ease, transform .15s ease;
}
.btn.btn-sm.pti-btn-slate:hover { box-shadow: 0 4px 14px rgba(31,78,121,.45); transform: translateY(-2px); }

/* Clases de color para drawCallback DataTables */
.pti-btn-navy   { background: #4a9eff !important; color: #fff !important; }
.pti-btn-navy:hover { box-shadow: 0 4px 14px rgba(74,158,255,.45) !important; }

.pti-btn-teal,
.pti-btn-green,
.pti-btn-cyan,
.pti-btn-purple { background: #1f4e79 !important; color: #fff !important; }

.pti-btn-teal:hover,
.pti-btn-green:hover,
.pti-btn-cyan:hover,
.pti-btn-purple:hover { box-shadow: 0 4px 14px rgba(31,78,121,.45) !important; }

/* Alta especificidad — garantiza que los colores ganen sobre Bootstrap/AdminLTE */
#empresas_wrapper .btn.btn-sm.pti-btn-navy  { background: #4a9eff !important; color: #fff !important; border-color: #4a9eff !important; }
#empresas_wrapper .btn.btn-sm.pti-btn-teal,
#empresas_wrapper .btn.btn-sm.pti-btn-green,
#empresas_wrapper .btn.btn-sm.pti-btn-cyan,
#empresas_wrapper .btn.btn-sm.pti-btn-purple,
#empresas_wrapper .btn.btn-sm.pti-btn-slate  { background: #1f4e79 !important; color: #fff !important; border-color: #1f4e79 !important; }

/* ---- DataTable: botones de acción 34×34px (#empresas_wrapper) ---- */
#empresas_wrapper .btn.btn-sm {
  width: 34px; height: 34px; padding: 0;
  border-radius: 8px; border: none; font-size: 0.88rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: box-shadow .2s ease, transform .15s ease;
}
#empresas_wrapper .btn.btn-sm:hover { transform: translateY(-2px); }
#empresas_wrapper .btn-danger.btn-sm {
  background: #c0392b !important; border-color: #c0392b !important; border-radius: 8px !important;
}
#empresas_wrapper .btn-danger.btn-sm:hover { box-shadow: 0 4px 14px rgba(192,57,43,.45) !important; }

/* ---- DataTable: botones sobre tabla ---- */
#btnenviar {
  background: #1f4e79 !important; border-color: #1f4e79 !important;
  border-radius: 8px !important; color: #fff !important; font-weight: 600;
  transition: background .15s ease, box-shadow .2s ease;
}
#btnenviar:hover {
  background: #1a4268 !important; border-color: #1a4268 !important;
  box-shadow: 0 4px 14px rgba(31,78,121,.45) !important;
}
#btnvolver {
  background: #1f4e79 !important; border-color: #1f4e79 !important;
  border-radius: 8px !important; color: #fff !important; font-weight: 600;
  transition: background .15s ease, box-shadow .2s ease;
}
#btnvolver:hover {
  background: #1a4268 !important; border-color: #1a4268 !important;
  box-shadow: 0 4px 14px rgba(31,78,121,.45) !important;
}

/* ---- Global Primary Button ---- */
.btn-primary {
  background-color: #0d2550;
  border-color: #0d2550;
  border-radius: 8px;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: #132d5e;
  border-color: #132d5e;
}

/* ================================================================
   KPI Cards — estilo moderno (panel de indicadores por documento)
   ================================================================ */

/* ---- Chip informativo dentro del header (ej: exportador/partida) ---- */
.pti-kpi-banner-tag {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff !important;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

/* ---- Barra de datos del documento (exportador/central/productor/variedad) ---- */
.pti-kpi-infobar {
  background: #f6f7fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 0.75rem 1.1rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
}
.pti-kpi-infobar strong { color: #23324a; }

/* ---- Tarjeta individual de KPI ---- */
.pti-kpi-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(74, 158, 255, 0.35);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(13, 37, 80, 0.06);
  transition: box-shadow 0.2s ease, transform 0.15s ease;
  height: 100%;
}
.pti-kpi-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #4a9eff, #8ec4ff);
  box-shadow: 0 2px 6px rgba(74, 158, 255, 0.45);
}
.pti-kpi-card:hover {
  box-shadow: 0 8px 24px rgba(13, 37, 80, 0.12);
  transform: translateY(-2px);
}
.pti-kpi-card .card-body { padding: 1.1rem 1.25rem 1.25rem; }

.pti-kpi-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 1rem;
}
.pti-kpi-head-left { display: flex; align-items: center; gap: 10px; }
.pti-kpi-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex: none;
}
.pti-kpi-title { font-size: 0.95rem; font-weight: 700; color: #23324a; margin: 0; line-height: 1.25; }
.pti-kpi-subtitle { font-size: 0.73rem; color: #8a94a6; margin: 0; }

.pti-kpi-arrow {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: #f1f3f6;
  color: #556;
  display: flex; align-items: center; justify-content: center;
  flex: none;
  transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease;
}
.pti-kpi-arrow:hover { background: #e4e8ee; transform: translateX(2px); color: #23324a; }

/* ---- Tiles de estadística ---- */
.pti-kpi-tiles { display: flex; gap: 10px; margin-bottom: 1rem; flex-wrap: wrap; }
.pti-kpi-tile {
  background: #f6f7fa;
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  flex: 1 1 0;
  min-width: 90px;
  text-align: center;
}
.pti-kpi-tile-value { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.pti-kpi-tile-label {
  font-size: 0.64rem; font-weight: 600; letter-spacing: 0.4px;
  color: #8a94a6; text-transform: uppercase; margin-top: 2px;
}

/* ---- Gráfico de barras verticales (calibre / color / firmeza) ---- */
.pti-kpi-barchart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 130px;
  margin-bottom: 0.4rem;
}
.pti-kpi-bar-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.pti-kpi-bar-value {
  font-size: 0.6rem;
  font-weight: 700;
  color: #23324a;
  margin-bottom: 3px;
  white-space: nowrap;
}
.pti-kpi-bar-track {
  width: 100%;
  max-width: 26px;
  height: 92px;
  background: #f1f3f6;
  border-radius: 4px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.pti-kpi-bar-fill {
  width: 100%;
  border-radius: 3px 3px 0 0;
  transition: height 0.3s ease;
}
.pti-kpi-bar-label {
  font-size: 0.6rem;
  color: #8a94a6;
  margin-top: 5px;
  text-align: center;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Paleta "cereza" — usada en los gráficos de calibre/color/firmeza ---- */
.pti-cherry-0 { background: #4a0d0d; }
.pti-cherry-1 { background: #6b1414; }
.pti-cherry-2 { background: #8b1a1a; }
.pti-cherry-3 { background: #a52a2a; }
.pti-cherry-4 { background: #c62828; }
.pti-cherry-5 { background: #d84343; }
.pti-cherry-6 { background: #e57373; }
.pti-cherry-7 { background: #ef9a9a; }

/* ---- Marca visual de remuestreo (misma tonalidad de color + rayado) ---- */
.pti-kpi-bar-fill--remuestreo {
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.4) 0 3px, transparent 3px 6px);
}

/* ---- Leyenda de detalle ---- */
.pti-kpi-legend { display: flex; flex-wrap: wrap; gap: 5px 14px; margin: 0; padding: 0; list-style: none; }
.pti-kpi-legend li { font-size: 0.73rem; color: #556; display: flex; align-items: center; gap: 6px; }
.pti-kpi-legend .pti-kpi-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pti-kpi-legend strong { color: #23324a; }

.pti-kpi-empty { color: #a0a8b4; font-size: 0.85rem; text-align: center; padding: 1.5rem 0; }

/* ---- Variantes de color por parámetro (paleta PT&I + Bootstrap ya usados en el proyecto) ---- */
.pti-kpi-accent  .pti-kpi-icon { background: rgba(74, 158, 255, 0.14); color: #4a9eff; }
.pti-kpi-accent  .pti-kpi-tile-value { color: #4a9eff; }

.pti-kpi-success .pti-kpi-icon { background: rgba(40, 167, 69, 0.14); color: #28a745; }
.pti-kpi-success .pti-kpi-tile-value { color: #28a745; }

.pti-kpi-navy    .pti-kpi-icon { background: rgba(13, 37, 80, 0.10); color: #0d2550; }
.pti-kpi-navy    .pti-kpi-tile-value { color: #0d2550; }

.pti-kpi-info    .pti-kpi-icon { background: rgba(23, 162, 184, 0.14); color: #17a2b8; }
.pti-kpi-info    .pti-kpi-tile-value { color: #17a2b8; }

.pti-kpi-slate   .pti-kpi-icon { background: rgba(31, 78, 121, 0.12); color: #1f4e79; }
.pti-kpi-slate   .pti-kpi-tile-value { color: #1f4e79; }

.pti-kpi-danger  .pti-kpi-icon { background: rgba(192, 57, 43, 0.12); color: #c0392b; }
.pti-kpi-danger  .pti-kpi-tile-value { color: #c0392b; }

/* Tarjetas de gráfico de barras (dashboard consolidado por temporada) */
.pti-chart-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(13, 37, 80, 0.08);
  border-radius: 16px;
  box-shadow: 0 3px 14px rgba(13, 37, 80, 0.07);
  transition: box-shadow 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
  height: 100%;
}
.pti-chart-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(90deg, #4a9eff, #8ec4ff);
}
.pti-chart-card::after {
  content: "";
  position: absolute;
  top: -60px; right: -60px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74, 158, 255, 0.10), transparent 70%);
  pointer-events: none;
}
.pti-chart-card:hover {
  box-shadow: 0 12px 30px rgba(13, 37, 80, 0.15);
  transform: translateY(-3px);
  border-color: rgba(13, 37, 80, 0.14);
}
.pti-chart-card .card-body { padding: 1.35rem 1.5rem 1.5rem; position: relative; z-index: 1; }

.pti-chart-card.pti-kpi-accent { border-color: rgba(74, 158, 255, 0.22); }
.pti-chart-card.pti-kpi-accent::before { background: linear-gradient(90deg, #4a9eff, #8ec4ff); }
.pti-chart-card.pti-kpi-accent::after  { background: radial-gradient(circle, rgba(74, 158, 255, 0.10), transparent 70%); }

.pti-chart-card.pti-kpi-info { border-color: rgba(23, 162, 184, 0.22); }
.pti-chart-card.pti-kpi-info::before   { background: linear-gradient(90deg, #17a2b8, #6bd0dd); }
.pti-chart-card.pti-kpi-info::after    { background: radial-gradient(circle, rgba(23, 162, 184, 0.10), transparent 70%); }

.pti-chart-card.pti-kpi-navy { border-color: rgba(13, 37, 80, 0.18); }
.pti-chart-card.pti-kpi-navy::before   { background: linear-gradient(90deg, #0d2550, #1f4e79); }
.pti-chart-card.pti-kpi-navy::after    { background: radial-gradient(circle, rgba(13, 37, 80, 0.10), transparent 70%); }

.pti-chart-card.pti-kpi-slate { border-color: rgba(31, 78, 121, 0.22); }
.pti-chart-card.pti-kpi-slate::before  { background: linear-gradient(90deg, #1f4e79, #4a7bab); }
.pti-chart-card.pti-kpi-slate::after   { background: radial-gradient(circle, rgba(31, 78, 121, 0.10), transparent 70%); }

.pti-chart-card.pti-kpi-danger { border-color: rgba(192, 57, 43, 0.22); }
.pti-chart-card.pti-kpi-danger::before { background: linear-gradient(90deg, #c0392b, #e0796c); }
.pti-chart-card.pti-kpi-danger::after  { background: radial-gradient(circle, rgba(192, 57, 43, 0.10), transparent 70%); }

.pti-chart-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: #556;
  background: #f1f3f6;
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
}
.pti-chart-wrap { position: relative; height: 300px; margin-top: 0.5rem; }
