/* ============================================================
   FM4 - Estilos corporativos + Mobile card-list
   ============================================================ */

:root {
  --fm4-rojo:       #C0392B;
  --fm4-rojo-osc:   #962d22;
  --fm4-rojo-claro: #e74c3c;
  --fm4-blanco:     #ffffff;
  --fm4-gris-claro: #f8f9fa;
  --fm4-gris:       #6c757d;
  --fm4-texto:      #212529;
  --fm4-borde:      #dee2e6;
  --fm4-sombra:     0 2px 12px rgba(0,0,0,.08);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f0f2f5;
  color: var(--fm4-texto);
  min-height: 100vh;
}

/* ── Navbar ── */
.fm4-navbar {
  background: var(--fm4-rojo) !important;
  box-shadow: 0 2px 8px rgba(192,57,43,.4);
  padding: 0 1rem;
  min-height: 56px;
  position: relative;
  z-index: 1050;
}

/* Logo sin filtro: se ve con sus colores reales */
.fm4-navbar .navbar-brand img {
  max-height: 38px;
}

.fm4-navbar .nav-link {
  color: rgba(255,255,255,.88) !important;
  font-size: .9rem;
  padding: .6rem .85rem;
  border-radius: 6px;
  transition: background .15s;
}
.fm4-navbar .nav-link:hover,
.fm4-navbar .nav-link.active {
  background: rgba(255,255,255,.18);
  color: #fff !important;
}
.fm4-navbar .dropdown-menu {
  border: none;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  border-radius: 8px;
  overflow: hidden;
}
.fm4-navbar .dropdown-item { font-size: .9rem; padding: .55rem 1.1rem; }
.fm4-navbar .dropdown-item:hover { background: #fef2f2; color: var(--fm4-rojo); }

/* Menú móvil: overlay que NO empuja el contenido */
@media (max-width: 991.98px) {
  #navMenu.collapse.show,
  #navMenu.collapsing {
    position: absolute;
    top: 56px; left: 0; right: 0;
    background: var(--fm4-rojo-osc);
    z-index: 1049;
    padding: .5rem 1rem 1rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
  }
  #navMenu .nav-item + .nav-item { border-top: 1px solid rgba(255,255,255,.1); }
  #navMenu .dropdown-menu { background: rgba(0,0,0,.2); box-shadow: none; border-radius: 6px; margin-top: .25rem; }
  #navMenu .dropdown-item { color: rgba(255,255,255,.85); }
  #navMenu .dropdown-item:hover { background: rgba(255,255,255,.15); color: #fff; }
}

/* ── Avatar ── */
.fm4-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.25); color: #fff;
  font-size: .8rem; font-weight: 700;
  border: 2px solid rgba(255,255,255,.4);
}

.fm4-main { min-height: calc(100vh - 56px); }

/* ── Cards ── */
.card { border: none; border-radius: 12px; box-shadow: var(--fm4-sombra); }
.card-header {
  background: var(--fm4-blanco);
  border-bottom: 2px solid var(--fm4-rojo);
  border-radius: 12px 12px 0 0 !important;
  font-weight: 600; padding: 1rem 1.25rem;
}
.card-header .bi { color: var(--fm4-rojo); }

/* ── Botones ── */
.btn-fm4, .btn-danger {
  background: var(--fm4-rojo) !important;
  border-color: var(--fm4-rojo) !important;
  color: #fff !important;
}
.btn-fm4:hover, .btn-danger:hover {
  background: var(--fm4-rojo-osc) !important;
  border-color: var(--fm4-rojo-osc) !important;
}
.btn-outline-fm4, .btn-outline-danger {
  border-color: var(--fm4-rojo) !important;
  color: var(--fm4-rojo) !important;
}
.btn-outline-fm4:hover, .btn-outline-danger:hover {
  background: var(--fm4-rojo) !important;
  color: #fff !important;
}

/* ── Tablas ── */
.table thead th {
  background: var(--fm4-rojo); color: #fff;
  font-weight: 600; font-size: .85rem;
  border: none; white-space: nowrap;
}
.table tbody tr:hover { background: #fff5f5; }
.table-responsive { border-radius: 8px; overflow: hidden; }

/* ── Login ── */
.fm4-login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--fm4-rojo) 0%, #7b241c 60%, #1a1a2e 100%);
  display: flex; align-items: center; justify-content: center; padding: 2rem;
}
.fm4-login-card {
  width: 100%; max-width: 420px; background: #fff;
  border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: hidden;
}
.fm4-login-header { background: var(--fm4-rojo); padding: 2.5rem 2rem 2rem; text-align: center; }
.fm4-login-header img { height: 60px; }
.fm4-login-body { padding: 2rem; }
.fm4-login-body .form-label {
  font-weight: 600; font-size: .85rem; color: var(--fm4-gris);
  text-transform: uppercase; letter-spacing: .04em;
}
.fm4-login-body .form-control:focus {
  border-color: var(--fm4-rojo); box-shadow: 0 0 0 .2rem rgba(192,57,43,.2);
}
.fm4-login-body .btn-login {
  background: var(--fm4-rojo); border: none; color: #fff;
  width: 100%; padding: .75rem; border-radius: 8px;
  font-weight: 600; font-size: 1rem; transition: background .2s;
}
.fm4-login-body .btn-login:hover { background: var(--fm4-rojo-osc); }

/* ── Stats dashboard ── */
.fm4-stat {
  border-radius: 12px; padding: 1.25rem 1.5rem;
  color: #fff; position: relative; overflow: hidden;
}
.fm4-stat::after {
  content: ''; position: absolute; right: -20px; top: -20px;
  width: 100px; height: 100px; border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.fm4-stat .stat-icon { font-size: 2rem; opacity: .8; }
.fm4-stat .stat-valor { font-size: 2.2rem; font-weight: 700; line-height: 1; }
.fm4-stat .stat-label { font-size: .85rem; opacity: .85; }
.fm4-stat-rojo    { background: linear-gradient(135deg, #C0392B, #e74c3c); }
.fm4-stat-naranja { background: linear-gradient(135deg, #d35400, #e67e22); }
.fm4-stat-verde   { background: linear-gradient(135deg, #1e8449, #27ae60); }
.fm4-stat-azul    { background: linear-gradient(135deg, #1a5276, #2980b9); }
.fm4-stat-gris    { background: linear-gradient(135deg, #566573, #7f8c8d); }

/* ── Badges ── */
.badge { font-size: .78rem; padding: .35em .65em; border-radius: 6px; }

/* ── Formularios ── */
.form-control:focus, .form-select:focus {
  border-color: var(--fm4-rojo); box-shadow: 0 0 0 .2rem rgba(192,57,43,.15);
}
.form-check-input:checked { background-color: var(--fm4-rojo); border-color: var(--fm4-rojo); }

/* ── Títulos sección ── */
.fm4-section-title {
  display: flex; align-items: center; gap: .5rem;
  font-size: 1.2rem; font-weight: 700; color: var(--fm4-rojo);
  margin-bottom: 1.25rem; padding-bottom: .5rem;
  border-bottom: 2px solid #fde8e6;
}

/* ── Consumibles ── */
.consumible-bar { border-radius: 50px; height: 10px; background: #e9ecef; overflow: hidden; }
.consumible-bar .fill { height: 100%; border-radius: 50px; transition: width .4s; }
.fill-cian     { background: #00B5D8; }
.fill-magenta  { background: #D63384; }
.fill-amarillo { background: #FFC107; }
.fill-negro    { background: #343a40; }

/* ── Upload ── */
.fm4-upload-area {
  border: 3px dashed var(--fm4-rojo); border-radius: 12px;
  padding: 3rem 2rem; text-align: center; background: #fef9f9;
  cursor: pointer; transition: background .2s, border-color .2s;
}
.fm4-upload-area:hover, .fm4-upload-area.dragover { background: #fde8e6; border-color: var(--fm4-rojo-osc); }
.fm4-upload-area .bi { font-size: 3rem; color: var(--fm4-rojo); opacity: .6; }

/* ── Paginación ── */
.page-link { color: var(--fm4-rojo); }
.page-item.active .page-link { background: var(--fm4-rojo); border-color: var(--fm4-rojo); }

/* ── Spinner ── */
.fm4-spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(192,57,43,.3); border-top-color: var(--fm4-rojo);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════
   CARD-LIST — alternativa a tabla en móvil
   ══════════════════════════════════════════════ */
.fm4-card-list { display: none; }

.fm4-list-card {
  background: #fff; border-radius: 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  padding: .9rem 1rem; margin-bottom: .55rem;
  border-left: 4px solid var(--fm4-rojo);
  text-decoration: none; color: inherit; display: block;
  transition: box-shadow .15s, transform .1s;
}
.fm4-list-card:hover {
  box-shadow: 0 3px 14px rgba(192,57,43,.2);
  transform: translateY(-1px); color: inherit;
}
.fm4-list-card .fm4-lc-title {
  font-weight: 600; font-size: .93rem; color: var(--fm4-rojo);
  margin-bottom: .2rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fm4-list-card .fm4-lc-sub { font-size: .8rem; color: var(--fm4-gris); margin-bottom: .4rem; }
.fm4-list-card .fm4-lc-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: .4rem; flex-wrap: wrap;
}
.fm4-list-card .fm4-lc-foot .badge { font-size: .72rem; padding: .28em .6em; }
.fm4-list-card .fm4-lc-meta { font-size: .75rem; color: var(--fm4-gris); }

/* ══════════════════════════════════════════════
   RESPONSIVE MÓVIL (< 768px)
   ══════════════════════════════════════════════ */
@media (max-width: 767.98px) {
  .container-fluid { padding-left: .75rem; padding-right: .75rem; }

  .fm4-section-title { font-size: 1rem; margin-bottom: .6rem; }

  /* Stats 2 columnas */
  .fm4-stat { margin-bottom: .6rem; }
  .fm4-stat .stat-valor { font-size: 1.6rem; }
  .fm4-stat .stat-label { font-size: .78rem; }

  /* Botones */
  .btn    { font-size: .82rem; padding: .38rem .7rem; }
  .btn-lg { font-size: .9rem;  padding: .5rem 1rem; }

  /* Cabecera página */
  .d-flex.justify-content-between.align-items-center.mb-4 {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: .5rem; margin-bottom: .75rem !important;
  }

  /* Ocultar tabla, mostrar card-list */
  .fm4-table-wrap { display: none !important; }
  .fm4-card-list  { display: block !important; }

  /* Detalle cards */
  .card-header { padding: .6rem .85rem; font-size: .86rem; }
  .card-body   { padding: .75rem .85rem; }
  .table-sm td, .table-sm th { font-size: .79rem; padding: .28rem .45rem; }

  /* Formularios */
  .form-control, .form-select, .form-control-sm, .form-select-sm { font-size: .85rem; }
  .form-label { font-size: .84rem; margin-bottom: .25rem; }

  /* Upload */
  .fm4-upload-area { padding: 1.5rem 1rem; }
  .fm4-upload-area .bi { font-size: 2rem; }

  /* Paginación */
  .page-link { padding: .3rem .55rem; font-size: .8rem; }
}

@media (max-width: 399px) {
  .fm4-list-card { padding: .75rem .8rem; }
  .fm4-list-card .fm4-lc-title { font-size: .85rem; }
  .fm4-list-card .fm4-lc-sub   { font-size: .73rem; }
}
