/* ================================================
   Panel Mixeros v5.9.0 — Custom Theme
   ================================================ */

/* ---- CSS Variables (Light) ---- */
:root,
[data-bs-theme="light"] {
  --mx-primary: #1F4E79;
  --mx-primary-light: #2B6CB0;
  --mx-accent: #38A169;
  --mx-accent-light: #48BB78;
  --mx-bg: #f4f6f9;
  --mx-card-bg: #ffffff;
  --mx-nav-bg: #1F4E79;
  --mx-nav-text: rgba(255,255,255,.85);
  --mx-nav-active: #ffffff;
  --mx-muted: #667085;
  --mx-border: #e2e8f0;
  --mx-kpi-shadow: 0 2px 12px rgba(31,78,121,.08);
  --mx-table-hover: #f0f4f8;
}

/* ---- CSS Variables (Dark) ---- */
[data-bs-theme="dark"] {
  --mx-primary: #4A9BD9;
  --mx-primary-light: #63B3ED;
  --mx-accent: #48BB78;
  --mx-accent-light: #68D391;
  --mx-bg: #0f1117;
  --mx-card-bg: #1a1d28;
  --mx-nav-bg: #141620;
  --mx-nav-text: rgba(255,255,255,.7);
  --mx-nav-active: #ffffff;
  --mx-muted: #94a3b8;
  --mx-border: #2d3348;
  --mx-kpi-shadow: 0 2px 12px rgba(0,0,0,.3);
  --mx-table-hover: #1e2233;
}

/* ---- Global ---- */
body {
  background: var(--mx-bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  transition: background-color .2s ease;
}

/* ---- Navbar ---- */
#mainNav {
  background: var(--mx-nav-bg) !important;
  border-bottom: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(10px);
  z-index: 1030;
}

#mainNav .navbar-brand {
  color: #fff !important;
  font-size: 1.15rem;
  letter-spacing: -.02em;
}

#mainNav .nav-link {
  color: var(--mx-nav-text) !important;
  font-size: .875rem;
  font-weight: 500;
  padding: .5rem .75rem;
  border-radius: 8px;
  transition: all .15s ease;
}

#mainNav .nav-link:hover,
#mainNav .nav-link.active {
  color: var(--mx-nav-active) !important;
  background: rgba(255,255,255,.1);
}

#mainNav .dropdown-menu {
  border-radius: 12px;
  border: 1px solid var(--mx-border);
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  padding: .5rem;
  animation: fadeIn .15s ease;
}

#mainNav .dropdown-item {
  border-radius: 8px;
  font-size: .875rem;
  padding: .5rem .75rem;
  transition: background .1s ease;
}

#mainNav .dropdown-item:hover {
  background: var(--mx-table-hover);
}

#mainNav .dropdown-item.active {
  background: var(--mx-primary);
  color: #fff;
}

/* ---- Cards ---- */
.card {
  border-radius: 16px;
  border: 1px solid var(--mx-border);
  background: var(--mx-card-bg);
  transition: box-shadow .2s ease, transform .2s ease;
}

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

/* ---- KPI Cards ---- */
.kpi {
  border-radius: 16px;
  border: 1px solid var(--mx-border);
  background: var(--mx-card-bg);
  box-shadow: var(--mx-kpi-shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(31,78,121,.12);
}

.kpi .display-6 {
  font-weight: 700;
  color: var(--mx-primary);
}

/* ---- Typography ---- */
.mono {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.small-muted {
  color: var(--mx-muted);
  font-size: .85rem;
}

h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -.01em;
}

/* ---- Tables ---- */
.table {
  font-size: .875rem;
}

.table thead th {
  background: var(--mx-bg);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--mx-muted);
  border-bottom-width: 2px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table tbody tr {
  transition: background .1s ease;
}

.table tbody tr:hover {
  background: var(--mx-table-hover);
}

.table td {
  vertical-align: middle;
}

/* ---- Buttons ---- */
.btn {
  font-size: .875rem;
  font-weight: 500;
  border-radius: 10px;
  padding: .45rem 1rem;
  transition: all .15s ease;
}

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

.btn-primary:hover {
  background: var(--mx-primary-light);
  border-color: var(--mx-primary-light);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--mx-accent);
  border-color: var(--mx-accent);
}

.btn-outline-primary {
  color: var(--mx-primary);
  border-color: var(--mx-primary);
}

.btn-outline-primary:hover {
  background: var(--mx-primary);
  color: #fff;
}

.btn-sm {
  font-size: .78rem;
  padding: .3rem .6rem;
  border-radius: 8px;
}

/* ---- Forms ---- */
.form-control, .form-select {
  border-radius: 10px;
  font-size: .875rem;
  border-color: var(--mx-border);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--mx-primary);
  box-shadow: 0 0 0 3px rgba(31,78,121,.15);
}

.form-label {
  font-size: .825rem;
  font-weight: 600;
  color: var(--mx-muted);
  margin-bottom: .3rem;
}

/* ---- Alerts ---- */
.alert {
  border-radius: 12px;
  font-size: .875rem;
  border: none;
}

.alert-success {
  background: rgba(56,161,105,.1);
  color: #276749;
}
[data-bs-theme="dark"] .alert-success {
  background: rgba(56,161,105,.15);
  color: #68D391;
}

.alert-danger {
  background: rgba(229,62,62,.1);
  color: #c53030;
}
[data-bs-theme="dark"] .alert-danger {
  background: rgba(229,62,62,.15);
  color: #FC8181;
}

.alert-warning {
  background: rgba(237,137,54,.1);
  color: #c05621;
}
[data-bs-theme="dark"] .alert-warning {
  background: rgba(237,137,54,.15);
  color: #FBD38D;
}

.alert-info {
  background: rgba(49,130,206,.1);
  color: #2b6cb0;
}
[data-bs-theme="dark"] .alert-info {
  background: rgba(49,130,206,.15);
  color: #63B3ED;
}

/* ---- Badges ---- */
.badge {
  font-weight: 600;
  font-size: .72rem;
  padding: .35em .65em;
  border-radius: 8px;
}

/* ---- Pagination ---- */
.pagination .page-link {
  border-radius: 10px;
  margin: 0 2px;
  font-size: .825rem;
  font-weight: 500;
  border: 1px solid var(--mx-border);
  color: var(--mx-primary);
}

.pagination .page-link:hover {
  background: var(--mx-primary);
  border-color: var(--mx-primary);
  color: #fff;
}

.pagination .page-item.active .page-link {
  background: var(--mx-primary);
  border-color: var(--mx-primary);
}

.pagination .page-item.disabled .page-link {
  color: var(--mx-muted);
}

/* ---- Status badges ---- */
.status-nuevo { background: #3182CE; color: #fff; }
.status-etiqueta { background: #2B6CB0; color: #fff; }
.status-diseno { background: #805AD5; color: #fff; }
.status-aprobacion { background: #DD6B20; color: #fff; }
.status-grabado { background: #D69E2E; color: #fff; }
.status-empaque { background: #38A169; color: #fff; }
.status-enviado { background: #319795; color: #fff; }
.status-entregado { background: #276749; color: #fff; }
.status-cancelado { background: #E53E3E; color: #fff; }

/* ---- Pipeline (Produccion) ---- */
.pipeline-col {
  min-height: 200px;
}

.pipeline-card {
  border-left: 4px solid var(--mx-primary);
  border-radius: 12px;
  transition: transform .15s ease;
}

.pipeline-card:hover {
  transform: translateY(-2px);
}

/* ---- Footer ---- */
footer {
  color: var(--mx-muted);
  font-size: .78rem;
}

/* ---- Scrollbar (webkit) ---- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--mx-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--mx-muted);
}

/* ---- Animation ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn .2s ease;
}

/* ---- Notification dropdown ---- */
#notifList .dropdown-item {
  white-space: normal;
  word-wrap: break-word;
}

/* ---- Login page ---- */
.login-container {
  max-width: 420px;
  margin: 80px auto;
}

.login-container .card {
  border: none;
  box-shadow: 0 4px 30px rgba(0,0,0,.08);
}

/* ---- Chart containers ---- */
canvas {
  max-height: 350px;
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--mx-muted);
}

.empty-state i {
  font-size: 3rem;
  opacity: .3;
}

/* ---- Mobile touch: allow native scroll ---- */
@media (pointer: coarse) {
  html, body {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  /* Cards should not capture touch for drag; only the drag-handle does */
  .card, .order-card, .dash-widget, .pipeline-card, .kanban-col {
    touch-action: pan-y pan-x;
  }
  /* Explicit drag handle for touch devices */
  .drag-handle {
    touch-action: none;
    cursor: grab;
  }
  .drag-handle:active { cursor: grabbing; }
  /* Hide drag handle on non-touch (shown only on mobile) */
  .drag-handle-mobile-only { display: inline-block; }
}
@media (pointer: fine) {
  .drag-handle-mobile-only { display: none; }
}

/* ---- Responsive ---- */
@media (max-width: 991px) {
  #mainNav .navbar-nav {
    padding-top: .5rem;
  }
  #mainNav .nav-link {
    padding: .6rem 1rem;
  }
  .kpi .display-6 {
    font-size: 1.5rem;
  }
}

@media (max-width: 576px) {
  .container-fluid {
    padding-left: 12px;
    padding-right: 12px;
  }
  .kpi .display-6 {
    font-size: 1.25rem;
  }
  .table {
    font-size: .8rem;
  }
}
