/* Plugin: Planificador de Mantenimiento de Vehículo - Estilos */

#mv-app {
  font-family: Arial, sans-serif;
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 0 0;
  box-sizing: border-box;
}

#mv-app * {
  box-sizing: border-box;
}

.mv-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 12px;
  margin-bottom: 1.25rem;
  overflow: visible;
}
.mv-form-grid--full {
  grid-template-columns: 1fr;
  margin-bottom: 8px;
}

.mv-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mv-field label {
  font-size: 13px;
  color: #666;
  font-weight: normal;
}

.mv-field input,
.mv-field select {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: #1a1a1a;
  width: 100%;
  height: 40px;
  box-sizing: border-box;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  line-height: normal;
}

/* iOS: forzar mismo alto en inputs de fecha */
.mv-field input[type="month"],
.mv-field input[type="date"] {
  height: 40px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  font-size: 14px;
}

/* Restaurar flecha nativa solo en select */
.mv-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.mv-sep {
  border: none;
  border-top: 1px solid #eee;
  margin: 1rem 0 .75rem;
}

.mv-slbl {
  font-size: 11px;
  font-weight: 600;
  color: #999;
  letter-spacing: .07em;
  text-transform: uppercase;
  margin-bottom: .6rem;
  display: block;
}

.mv-btn {
  width: 100%;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  margin-top: 4px;
  display: block;
  transition: opacity 0.15s;
}

.mv-btn:hover {
  background: #f5f5f5;
}



/* Botones de fondo oscuro */
.mv-btn[style*="background:#1a1a1a"]:hover,
#mv-generar-btn:hover,
#mv-modal-confirmar:hover {
  opacity: 0.85;
  background: #1a1a1a !important;
}

/* Resultado */
#mv-resultado {
  display: none;
  margin-top: 1.25rem;
}

/* Alertas */
.mv-alert {
  padding: 11px 14px;
  font-size: 13px;
  margin-bottom: 1rem;
  border-left: 3px solid;
  margin-top: .5rem;
}

/* Cuando la alerta está en el flex container junto al botón */
#mv-alerts > div > .mv-alert {
  margin-bottom: 0;
  margin-top: 0;
}

.mv-alert-red {
  background: #fdecea;
  color: #c0392b;
  border-color: #c0392b;
}

.mv-alert-amb {
  background: #fef5e7;
  color: #e67e22;
  border-color: #e67e22;
}

.mv-alert-grn {
  background: #eafaf1;
  color: #1e8449;
  border-color: #27ae60;
}

/* Resumen */
.mv-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 1.25rem;
  margin-top: 1rem;
}

.mv-metric {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 11px 13px;
}

.mv-metric p {
  margin: 0;
  padding: 0;
}

.mv-val {
  font-size: 19px;
  font-weight: 600;
  color: #1a1a1a;
}

.mv-val.mv-red,
p.mv-val.mv-red {
  color: #c0392b;
}

.mv-val.mv-amb,
p.mv-val.mv-amb {
  color: #e67e22;
}

.mv-lbl {
  font-size: 12px;
  color: #888;
  margin-top: 1px;
}

/* Paquetes */
.mv-pkg {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  margin-bottom: 11px;
  overflow: hidden;
}

.mv-pkg-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 15px;
  border-bottom: 1px solid #f0f0f0;
}

.mv-pkg-l {
  display: flex;
  align-items: center;
  gap: 9px;
}

.mv-pkg-ico {
  width: 29px;
  height: 29px;
  border-radius: 6px;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.mv-pkg-name {
  font-weight: 600;
  font-size: 14px;
  color: #1a1a1a;
}

/* Badges */
.mv-badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}

.mv-badge-red {
  background: #fdecea;
  color: #c0392b;
}

.mv-badge-amb {
  background: #fef5e7;
  color: #e67e22;
}

.mv-badge-grn {
  background: #eafaf1;
  color: #27ae60;
}

/* Tabla de tareas — usa <table> real para anchos fijos garantizados */
.mv-tasks { padding: 0; }

#mv-app .mv-table,
.mv-table {
  width: 100%;
  border-collapse: collapse !important;
  border-spacing: 0 !important;
  table-layout: fixed;
  border: none !important;
}

/* Forzar sin bordes por encima del tema Astra */
#mv-app .mv-table td,
#mv-app .mv-table th,
#mv-app .mv-table tr {
  border-left: none !important;
  border-right: none !important;
  border-top: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.mv-table thead tr { background: #fafafa; }

.mv-table thead th {
  font-size: 11px;
  color: #aaa;
  font-weight: 400;
  padding: 6px 8px;
  text-align: right;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
  overflow: hidden;
}
/* Anchos fijos por columna — solo funcionan con table-layout:fixed */
.mv-table th:nth-child(1) { width: auto;  text-align: left; padding-left: 15px; }
.mv-table th:nth-child(2) { width: 82px;  }
.mv-table th:nth-child(3) { width: 74px;  }
.mv-table th:nth-child(4) { width: 82px;  }
.mv-table th:nth-child(5) { width: 106px; }
.mv-table th:nth-child(6) { width: 90px;  }


.mv-table tbody tr { border-bottom: 1px solid #f5f5f5; }
.mv-table tbody tr:last-child { border-bottom: none; }
.mv-table tbody tr.mv-unknown { background: #fff; }
.mv-table tbody tr.mv-caducada { background: #fff; }

.mv-table tbody td {
  padding: 9px 4px;
  vertical-align: middle;
  font-size: 13px;
  color: #1a1a1a;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
}
.mv-table tbody td:first-child {
  white-space: normal;
  word-break: break-word;
}

.mv-table tbody td:first-child { text-align: left; padding-left: 15px; white-space: normal; word-break: break-word; }
.mv-table tbody td:last-child  { padding-right: 15px; }

.mv-col-name      { width: auto; min-width: 120px; max-width: 220px; }
.mv-col-int       { min-width: 72px; width: 72px; font-size: 12px; color: #888; }
.mv-col-int-km    { min-width: 75px; width: 75px; }
.mv-col-int-mes   { min-width: 75px; width: 75px; }
.mv-col-int-km input,
.mv-col-int-mes input { width: 100%; max-width: 100%; }
.mv-col-last-km   { min-width: 80px; width: 80px; }
.mv-col-last-fecha{ min-width: 105px; width: 105px; }
.mv-col-last      { min-width: 80px; width: 80px; }
.mv-col-next      { min-width: 100px; width: 100px; font-size: 12px; font-weight: 600; }

.mv-subtask-list {
  font-size: 11px;
  color: #999;
  margin-top: 3px;
  line-height: 1.5;
}

/* Input km */
.mv-km-input {
  font-size: 11px;
  border: none;
  background: transparent;
  color: #888;
  text-align: right;
  width: 100%;
  outline: none;
  padding: 0 2px;
  font-family: inherit;
  -moz-appearance: textfield;
}

.mv-km-input::-webkit-inner-spin-button,
.mv-km-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.mv-km-input::placeholder {
  color: #ccc;
}

.mv-km-input:hover,
.mv-km-input:focus {
  color: #1a1a1a;
  border-bottom: 1px solid #3498db;
}

/* Pill sin revisar */
.mv-pill-unknown {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #c0392b;
  background: #fdecea;
  border: 1px dashed #c0392b;
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* Colores de fechas */
.mv-due-s { color: #c0392b; }
.mv-due-m { color: #e67e22; }
.mv-due-o { color: #27ae60; }

/* ── Barra sticky de descarga ────────────────────────────────────────────── */
#mv-sticky-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: #fff;
  border-top: 3px solid #e5e5e5;
  box-shadow: 0 -2px 16px rgba(0,0,0,.07);
  transition: border-color 0.3s, background 0.3s;
}

/* Estado rojo */
#mv-sticky-bar.mv-sticky-red {
  border-top-color: #c0392b;
  background: #fff9f9;
}

/* Estado ámbar */
#mv-sticky-bar.mv-sticky-amb {
  border-top-color: #e67e22;
  background: #fffcf7;
}

/* Estado verde */
#mv-sticky-bar.mv-sticky-grn {
  border-top-color: #27ae60;
  background: #f8fff9;
}

.mv-sticky-msg {
  font-size: 13px;
  color: #444;
  flex: 1;
}

.mv-btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  background: #1a1a1a;
  color: #fff;
  border: 1px solid #1a1a1a;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.mv-btn-download:hover {
  opacity: 0.82;
}

/* Espacio inferior para que la barra sticky no tape el contenido */
#mv-resultado {
  padding-bottom: 80px; /* espacio para barra sticky */
}

.mv-sticky-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.mv-sticky-msg {
  font-size: 13px;
  font-weight: 500;
  color: #1a1a1a;
}

.mv-sticky-disclaimer {
  font-size: 10px;
  color: #aaa;
  line-height: 1.4;
}

/* ── Sticky bar scroll behaviour ─────────────────────────────────────────── */
#mv-sticky-bar {
  transition: transform 0.28s cubic-bezier(.4,0,.2,1), opacity 0.28s;
}
#mv-sticky-bar.mv-sticky-hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

/* ── Grid de tareas (móvil) ──────────────────────────────────────────────── */
.mv-task-grid {
  display: none;
}

@media (max-width: 640px) {

  /* Ocultar barra sticky en móvil */
  #mv-sticky-bar { display: none !important; }

  /* Ocultar vista escritorio en móvil, mostrar grid */
  .mv-pkg         { display: none !important; }
  .mv-task-grid   { display: block; }

  /* Tarjeta de tarea */
  .mv-task-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 8px;
    border: 1.5px solid #e8e8e8;
    border-radius: 14px;
    background: #fff;
    cursor: pointer;
    text-align: center;
    transition: border-color .18s, background .18s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }
  .mv-task-card:active { background: #f5f5f5; }
  .mv-task-card.mv-card-urgente   { border-color: #f8d7da; }
  .mv-task-card.mv-card-importante { border-color: #fde8c8; }
  .mv-task-card.mv-card-recomendado { border-color: #e8e8e8; }

  .mv-task-card-icon { font-size: 28px; line-height: 1; }
  .mv-task-card-name { font-size: 12px; color: #1a1a1a; font-weight: 500; line-height: 1.3; }

  /* Badge de estado en la tarjeta */
  .mv-task-card-badge {
    position: absolute;
    top: 6px; right: 6px;
    width: 10px; height: 10px;
    border-radius: 50%;
  }
  .mv-badge-red   { background: #c0392b; }
  .mv-badge-amber { background: #f39c12; }
  .mv-badge-green { background: #27ae60; }
  .mv-badge-grey  { background: #ccc; }

  /* Panel deslizante de detalle */
  .mv-task-panel-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99998;
  }
  .mv-task-panel-overlay.active { display: block; }
  .mv-task-panel {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 0 20px 32px;
    z-index: 99999;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    max-height: 85vh;
    overflow-y: auto;
  }
  .mv-task-panel.active { transform: translateY(0); }

  .mv-task-panel-handle {
    width: 40px; height: 4px;
    background: #ddd; border-radius: 2px;
    margin: 12px auto 16px;
  }
  .mv-task-panel-title {
    font-size: 17px; font-weight: 700;
    color: #1a1a1a; margin: 0 0 18px;
    display: flex; align-items: center; gap: 8px;
  }
  .mv-task-panel-field {
    margin-bottom: 14px;
  }
  .mv-task-panel-field label {
    display: block; font-size: 12px;
    color: #888; margin-bottom: 4px; font-weight: 500;
  }
  .mv-task-panel-field input {
    width: 100%; padding: 10px 12px;
    border: 1.5px solid #e0e0e0; border-radius: 10px;
    font-size: 15px; box-sizing: border-box;
    -webkit-appearance: none; appearance: none;
  }
  .mv-task-panel-field input:focus {
    border-color: #1a1a1a; outline: none;
  }
  .mv-panel-next-rev {
    background: #f5f5f5; border-radius: 10px;
    padding: 12px; font-size: 13px; color: #555;
    margin-bottom: 16px;
  }

  /* Campo fecha igual que campo número en el panel de tarea */
  .mv-panel-date-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    box-sizing: border-box;
    background: #fff;
    color: #1a1a1a;
    -webkit-appearance: none;
    appearance: none;
    height: 44px;
  }
  .mv-panel-date-input:focus {
    border-color: #1a1a1a;
    outline: none;
  }

  .mv-panel-guardar {
    width: 100%; padding: 13px;
    background: #1a1a1a; color: #fff;
    border: none; border-radius: 12px;
    font-size: 15px; font-weight: 600;
    cursor: pointer; margin-top: 6px;
  }
  .mv-panel-eliminar {
    width: 100%; padding: 11px;
    background: none; color: #c0392b;
    border: 1.5px solid #f8d7da; border-radius: 12px;
    font-size: 14px; font-weight: 500;
    cursor: pointer; margin-top: 8px;
  }

  /* Cabecera colapsable de paquete */
  .mv-grid-pkg-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 14px;
    border-radius: 12px;
    background: #f5f5f5;
    cursor: pointer;
    margin-bottom: 2px;
    -webkit-tap-highlight-color: transparent;
  }
  .mv-grid-pkg-hdr-left  { display:flex; align-items:center; gap:8px; }
  .mv-grid-pkg-hdr-right { display:flex; align-items:center; gap:8px; }
  .mv-grid-pkg-hdr-icon  { font-size:18px; }
  .mv-grid-pkg-hdr-title { font-size:14px; font-weight:700; color:#1a1a1a; }
  .mv-grid-pkg-chevron   { font-size:20px; color:#aaa; transition:transform .2s; line-height:1; }
  .mv-grid-pkg-hdr--open .mv-grid-pkg-chevron { transform: rotate(90deg); }

  /* Etiqueta de estado en la cabecera */
  .mv-grid-pkg-estado {
    font-size:11px; font-weight:700; padding:3px 8px;
    border-radius:20px; white-space:nowrap;
  }
  .mv-grid-pkg-estado--red  { background:#fde8e8; color:#c0392b; }
  .mv-grid-pkg-estado--amb  { background:#fde8c8; color:#e67e22; }
  .mv-grid-pkg-estado--grn  { background:#eafaf1; color:#1e8449; }
  .mv-grid-pkg-estado--grey { background:#f0f0f0; color:#888; }

  /* Cabecera urgente con borde */
  .mv-grid-pkg-hdr--red  { background:#fef2f2; border:1.5px solid #f8d7da; }
  .mv-grid-pkg-hdr--amb  { background:#fffbf0; border:1.5px solid #fde8c8; }
  .mv-grid-pkg-hdr--grn  { background:#f8fffe; border:1.5px solid #eee; }
  .mv-grid-pkg-hdr--grey { background:#f5f5f5; border:1.5px solid #eee; }

  /* Contenedor de tarjetas colapsable */
  .mv-grid-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px 0 14px;
    overflow: hidden;
    max-height: 2000px;
    transition: max-height .3s ease, padding .3s ease, opacity .25s;
    opacity: 1;
  }
  .mv-grid-cards--collapsed {
    max-height: 0 !important;
    padding: 0 !important;
    opacity: 0;
    pointer-events: none;
  }

  /* Botón añadir tarea custom: misma forma que tarjeta */
  .mv-grid-add-custom {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 8px;
    border: 1.5px dashed #ccc;
    border-radius: 14px;
    background: #fafafa;
    color: #aaa;
    font-size: 22px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    min-height: 90px;
  }


  /* Fecha de próxima revisión en la tarjeta */
  .mv-task-card-date {
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    border-radius: 20px;
    padding: 2px 7px;
    margin-top: 2px;
    max-width: 90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mv-date-red   { background:#fde8e8; color:#c0392b; }
  .mv-date-amber { background:#fde8c8; color:#b7700a; }
  .mv-date-green { background:#eafaf1; color:#1e8449; }
  .mv-date-grey  { display:none; }

  /* Botón "Guardar y recibir recordatorios" */
  .mv-mobile-save-btn {
    display: flex; align-items:center; justify-content:center;
    padding: 15px;
    background:#1a1a1a; color:#fff;
    border-radius: 14px; font-size:15px; font-weight:700;
    cursor:pointer; margin-top:16px;
    -webkit-tap-highlight-color: transparent;
  }

  /* Ajustes formulario en móvil */
  .mv-form-grid { grid-template-columns: 1fr 1fr !important; overflow: visible; }
  /* Campo Próxima ITV mismo tamaño que los demás */
  #mv-app .mv-field:has(#mv-fechaITV) { grid-column: auto; overflow: visible; }
  #mv-app .mv-field #mv-fechaITV {
    width: 100%;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
  }

  /* Ocultar columnas de tabla que no caben en móvil */
  .mv-pkg-header, .mv-pkg-container { overflow-x: auto; }
}

/* ── Banner de avisos ───────────────────────────────────────────────────────── */
.mv-alert-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.4;
}
.mv-alert-banner--red {
  background: #fef2f2;
  border-left: 4px solid #c0392b;
  color: #7b1d1d;
}
.mv-alert-banner--amb {
  background: #fffbf0;
  border-left: 4px solid #e67e22;
  color: #78450b;
}
.mv-alert-banner--grn {
  background: #f0fdf4;
  border-left: 4px solid #27ae60;
  color: #1a5c38;
}
.mv-alert-banner-msg { flex: 1; min-width: 0; }
.mv-alert-banner-cta {
  white-space: nowrap;
  font-weight: 600;
  font-size: 13px;
  color: #1a1a1a;
  text-decoration: none;
  border-bottom: 1px solid #1a1a1a;
  padding-bottom: 1px;
}
.mv-alert-banner-cta:hover { opacity: 0.7; }

/* ── Calculadora km/año ───────────────────────────────────────────────────── */
.mv-help-btn {
  background: none; border: none; cursor: pointer;
  color: #aaa; font-size: 15px; padding: 0 2px;
  vertical-align: middle; line-height: 1;
}
.mv-help-btn:hover { color: #555; }
/* .mv-calc-panel migrado a modal inline */
.mv-calc-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 8px;
}
.mv-calc-row label { font-size: 13px; color: #555; flex: 1; }
.mv-calc-row input {
  width: 110px; padding: 6px 10px;
  border: 1px solid #ccc; border-radius: 8px;
  font-size: 13px; text-align: right; flex-shrink: 0;
}
.mv-calc-result {
  font-size: 20px; font-weight: 700; color: #1a1a1a;
  text-align: center; padding: 12px 0 8px;
}
.mv-calc-apply {
  width: 100%; margin-top: 4px;
}
