/* PALETA DE COLOR BIZKAIBUS */
:root {
  --primary: #006837;          /* Verde corporativo Bizkaibus */
  --primary-hover: #004d28;    /* Verde más oscuro para botones al pasar el ratón */
  --primary-light: #e6f3eb;    /* Verde muy suave para resaltados */
  --bg-color: #f0f4f1;         /* Fondo de pantalla suave y descansado */
  --card-bg: #ffffff;          /* Fondo blanco limpio para tarjetas */
  --text-main: #0f172a;        /* Texto principal (casi negro para legibilidad) */
  --text-muted: #526058;      /* Texto secundario */
  --border-color: #d1e2d7;     /* Bordes finos verdosos */

  /* Variable de alerta / rojo que faltaba */
  --danger: #dc2626;
  
  /* Colores de badges de turno */
  --badge-azul: #0284c7;
  --badge-azul-claro: #38bdf8;
  --badge-verde: #16a34a;
  --badge-rojo: #dc2626;
  --badge-amarillo: #d97706;
  --badge-morado: #9333ea;
}

body { 
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
  margin: 0; 
  padding: 15px; 
  background-color: var(--bg-app); 
  color: var(--text-main); 
  -webkit-tap-highlight-color: transparent;
}

h1 { font-size: 1.5rem; margin: 5px 0 15px 0; color: var(--text-main); letter-spacing: -0.5px; }
h2, h3 { font-size: 1.2rem; margin-top: 0; color: var(--text-main); }

.tabs-container {
  position: sticky;
  top: 0;
  background-color: var(--bg-app);
  padding: 5px 0 15px 0;
  z-index: 1000;
}

/* Barra independiente del menú principal */
.barra-menu {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
}

/* Botón de menú de tres líneas */
.btn-menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: #ffffff;
  color: var(--primary);
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.btn-menu:hover {
  background-color: var(--primary-light);
}

/* Menú desplegable principal */
.barra-menu {
  position: relative;
}

.menu-desplegable {
  position: absolute;
  top: 100%;
  left: 12px;
  z-index: 1100;
  min-width: 210px;
  padding: 6px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.menu-desplegable[hidden] {
  display: none;
}

.menu-desplegable button {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  font-size: 15px;
  cursor: pointer;
}

.menu-desplegable button:hover {
  background: var(--primary-light);
}

.tabs { 
  display: flex; 
  gap: 6px; 
  border-bottom: 2px solid var(--border-color); 
  padding-bottom: 8px; 
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn { 
  padding: 8px 14px; 
  font-size: 0.9rem; 
  cursor: pointer; 
  border: none; 
  background: #e2e8f0; 
  color: var(--text-muted);
  border-radius: 8px; 
  font-weight: 600; 
  white-space: nowrap;
  transition: all 0.2s ease;
}
.tab-btn.active { 
  background: var(--primary); 
  color: white; 
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Desplazamiento interno en las demás pestañas */
#tab-graficos,
#tab-conductores,
#tab-ajustes {
  max-height: 72vh;
  overflow-y: auto;
  padding-right: 4px;
  box-sizing: border-box;
  scroll-behavior: smooth;
}

.selector-container { 
  margin-bottom: 15px; 
  background: var(--card-bg); 
  padding: 20px; 
  border-radius: 12px; 
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); 
  max-width: 600px; 
  box-sizing: border-box;
  border: 1px solid var(--border-color);
}

select, input { 
  padding: 10px 14px; 
  font-size: 1rem; 
  border-radius: 8px; 
  border: 1px solid var(--border-color); 
  width: 100%; 
  box-sizing: border-box; 
  margin-top: 6px; 
  background-color: #fff;
  color: var(--text-main);
  outline: none;
}

.form-group-p1 { margin-bottom: 15px; }
.form-group-p1 label { display: block; font-weight: 600; font-size: 0.9rem; color: var(--text-muted); }

.contenedor-dias { 
  display: flex; 
  flex-direction: column; 
  gap: 12px; 
  max-width: 600px; 
  max-height: 72vh; 
  overflow-y: auto; 
  padding-right: 4px;
  scroll-behavior: smooth;
}

.tarjeta-dia { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  padding: 14px 18px; 
  background-color: var(--card-bg); 
  border-radius: 12px; 
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03); 
  flex-shrink: 0; 
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.tarjeta-dia:active {
  transform: scale(0.98);
}

.tarjeta-hoy { 
  background-color: var(--primary-light) !important; 
  border: 2px solid var(--primary) !important; 
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.15) !important;

/* Desactiva el ajuste/salto automático de scroll en el contenedor y en la tarjeta */

  scroll-margin: 0 !important;
  scroll-align: none !important;
}

/* Si tu lista de 7 días está dentro de un contenedor con scroll, mantén el scroll en la parte superior */
.contenedor-dias, .cuadrante-container, .dias-container {
  scroll-behavior: auto !important;
  overflow-anchor: none !important; /* Evita que el navegador reajuste la posición del scroll */
}

.tarjeta-pasada {
  opacity: 0.65;
}

.texto-rojo { color: var(--danger); font-weight: 700; }

.tarjeta-festivo-domingo { 
  border-left: 5px solid var(--danger); 
}

.badge-hora { 
  background: #f1f5f9; 
  color: var(--text-main); 
  padding: 3px 7px; 
  border-radius: 6px; 
  font-size: 0.75rem; 
  font-weight: 600; 
  margin-left: 8px; 
  display: inline-block;
  margin-top: 3px;
}

.badge-relevo { 
  background: var(--success-light); 
  color: var(--success); 
  padding: 5px 10px; 
  border-radius: 6px; 
  font-size: 0.85rem; 
  font-weight: 600; 
  margin-left: 8px; 
  display: inline-block;
  margin-top: 4px;
}

.badge-grafico { 
  padding: 6px 12px; 
  border-radius: 8px; 
  font-size: 1rem; 
  font-weight: 700; 
  color: white; 
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.bg-azul { background-color: #1e88e5; }
.bg-verde { background-color: #2e7d32; }
.bg-rojo { background-color: #e53935; }
.bg-azul-claro { background-color: #00acc1; }
.bg-amarillo { background-color: #fbc02d; color: #1e293b; }
.bg-morado { background-color: #8e24aa; }

.graficos-layout { display: flex; gap: 15px; max-width: 1000px; flex-wrap: wrap; }
.lista-graficos { width: 35%; min-width: 240px; background: var(--card-bg); padding: 15px; border-radius: 12px; border: 1px solid var(--border-color); max-height: 55vh; overflow-y: auto; }
.detalle-grafico { width: 58%; min-width: 280px; background: var(--card-bg); padding: 20px; border-radius: 12px; border: 1px solid var(--border-color); }

.grafico-item { 
  padding: 12px 10px; 
  cursor: pointer; 
  border-bottom: 1px solid var(--border-color); 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  border-radius: 6px;
}
.grafico-item.seleccionado { background: var(--primary-light); font-weight: bold; color: var(--primary); }

.btn { 
  background: var(--primary); 
  color: white; 
  border: none; 
  padding: 10px 18px; 
  border-radius: 8px; 
  cursor: pointer; 
  font-size: 1rem; 
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(25, 118, 210, 0.2);
}
.btn-secondary { background: #64748b; }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }

.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; color: var(--text-muted); }

.tabla-incidencias { width: 100%; border-collapse: collapse; margin-top: 10px; }
.tabla-incidencias th, .tabla-incidencias td { border: 1px solid var(--border-color); padding: 8px 12px; text-align: left; }
.tabla-incidencias th { background-color: #f1f5f9; font-weight: 600; font-size: 0.85rem; color: var(--text-muted); }

/* CABECERA CORPORATIVA BIZKAIBUS */
.bizkaibus-header {
  background: linear-gradient(135deg, #006837 0%, #004d28 100%);
  color: #ffffff;
  padding: 16px 20px;
  border-bottom: 4px solid #ffcc00; /* Franja amarilla característica */
  margin-bottom: 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 1.8rem;
}

.logo-area h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0;
  color: #ffffff;
}

.logo-area h1 span {
  color: #ffcc00; /* Texto destacado en amarillo */
  font-weight: 400;
}

.header-badge {
  background-color: rgba(255, 255, 255, 0.15);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* RESALTAR ENCABEZADOS Y BORDES DE TARJETAS */
h2, h3 {
  color: #006837;
}

.card, .tarjeta {
  border-top: 3px solid #006837;
}

/* TAMAÑO Y AJUSTE DE LA IMAGEN EN LA CABECERA */
.logo-img {
  height: 55px;            /* Altura adaptada a la cabecera */
  width: auto;             /* Mantiene la proporción de la foto */
  object-fit: contain;
  border-radius: 4px;      /* Un leve redondeado elegante si lo requiere */
}

/* RESALTAR DOMINGOS Y FESTIVOS EN ROJO (PESTAÑA 2) */
.festivo, 
.domingo, 
.dia-festivo,
.tarjeta-festivo {
  color: #dc2626 !important; /* Rojo vivo para el texto */
}

/* Si llevan un fondo, etiqueta o borde destacado */
.festivo .badge, 
.domingo .badge, 
.badge-festivo, 
.badge-domingo {
  background-color: #dc2626 !important;
  color: #ffffff !important;
}

/* Si la tarjeta entera del festivo/domingo se pintaba de rojo suave */
.tarjeta.festivo, 
.tarjeta.domingo {
  border-left: 4px solid #dc2626 !important;
  background-color: #fef2f2 !important; /* Fondo rojo muy claro para destacar */
}

/* Estilos de la ventana flotante (Modal) */
.modal-calendario {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6); /* Fondo oscuro transparente */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal-contenido {
  background: #ffffff;
  padding: 25px;
  border-radius: 12px;
  width: 90%;
  max-width: 750px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  position: relative;
}

.cerrar-modal {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
  color: #666;
  cursor: pointer;
}

.cerrar-modal:hover {
  color: #000;
}

.controles-mes {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 15px 0;
}

.btn-flecha, .btn-pdf, .btn-gestion-calendario {
  background-color: #0a5c36;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
}

.btn-flecha:hover, .btn-pdf:hover, .btn-gestion-calendario:hover {
  background-color: #074226;
}

.acciones-modal {
  margin-top: 20px;
  text-align: right;
}

/* Cuadrícula del mes */
.grid-calendario-mes {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.cabecera-dia {
  font-weight: bold;
  text-align: center;
  background-color: #f0f0f0;
  padding: 6px;
  border-radius: 4px;
}

.casilla-dia {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px 4px;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  background-color: #ffffff;
}

.casilla-dia.vacia {
  background-color: transparent;
  border: none;
}

.num-dia {
  font-size: 12px;
  font-weight: bold;
  color: #444;
  align-self: flex-start;
}

.etiqueta-turno {
  font-weight: bold;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
}

/* Colores según la lógica descrita */
.turno-d .etiqueta-turno {
  background-color: #5bb4e5; /* Azul D */
}

.turno-dh .etiqueta-turno {
  background-color: #36c5c8; /* Turquesa DH */
}

.turno-par .etiqueta-turno {
  background-color: #e53935; /* Rojo para Par (ej. 2204) */
}

.turno-impar .etiqueta-turno {
  background-color: #4caf50; /* Verde para Impar */
}

.turno-defecto .etiqueta-turno {
  background-color: #888888;
}

/* Esta clase es la que usaremos para imprimir con forma rectangular vertical */
/* Estilo nativo rectangular para cuando se imprima */
@media print {
      /* Mantener los colores al imprimir o guardar como PDF */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Ocultamos todo lo demás */
    body > *:not(.modal-calendario), .container, header, nav, form, button, .no-print {
        display: none !important;
    }

    
    /* Forzamos el contenedor a ocupar toda la hoja A4 vertical */
        .modal-calendario, .modal-contenido-calendario, .modal-contenido {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }

     /* Calendario mensual: siete columnas y seis filas */
        .grid-calendario-mes {
        display: grid !important;
        grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
        grid-template-rows: 28px repeat(6, minmax(0, 1fr)) !important;
        gap: 2px !important;
        width: 100% !important;
        height: 225mm !important;
        box-sizing: border-box !important;
        overflow: visible !important;
    }

    .grid-calendario-mes .cabecera-dia {
        min-width: 0 !important;
        text-align: center !important;
        overflow: hidden !important;
    }

    /* Creamos una cuadrícula que obliga a las 6 semanas a ocupar el 100% del alto de la hoja */
    .calendario-grid, .mes-cuadricula {
    display: grid !important;
    grid-template-rows: 28px repeat(6, minmax(0, 1fr)) !important;
    height: auto !important;
    width: 100% !important;
}

    /* Forzamos a cada celda de los días a ser un rectángulo alto y amplio */
        /* Calendario mensual: casillas altas para escribir */
    .grid-calendario-mes .casilla-dia {
        min-height: 0 !important;
        height: auto !important;
        padding: 2px 5px !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: flex-start !important;
        align-items: flex-start !important;
        gap: 6px !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
        break-inside: avoid !important;
    }

    /* Número del día dentro de su propio recuadro */
    .grid-calendario-mes .num-dia {
        display: inline-block !important;
        border: 1px solid #777 !important;
        padding: 3px 5px !important;
        flex-shrink: 0 !important;
    }

    /* Turno a la derecha del número */
    .grid-calendario-mes .etiqueta-turno {
        display: inline-block !important;
        margin-top: 3px !important;
    }

    .calendario-grid > div, .mes-cuadricula > div {
        height: 100% !important;
        min-height: 0 !important; /* Anula cualquier límite cuadrado anterior */
        border: 1px solid #999 !important;
        padding: 8px !important;
    }
}
.forzar-rectangular {
    grid-template-rows: 28px repeat(6, minmax(0, 1fr)) !important;
    height: 225mm !important;
}

    /* Preparar la impresión en A4 vertical */
    @page {
        size: A4 portrait;
        margin: 8mm;
    }

    /* Ocultar completamente la etiqueta de los días C */
.etiqueta-turno.turno-en-blanco {
    display: none !important;
}
/* Huecos de los meses anterior y siguiente */
.grid-calendario-mes .casilla-dia.vacia {
    background-color: #f2f2f2 !important;
    border-color: #e5e5e5 !important;
}
/* Días de los meses anterior y siguiente */
.grid-calendario-mes .casilla-dia.dia-otro-mes {
    background-color: #f0f0f0 !important;
    border-color: #e2e2e2 !important;
}

/* Días de los meses anterior y siguiente */
.grid-calendario-mes .casilla-dia.dia-otro-mes {
    background-color: #f0f0f0 !important;
    border-color: #e2e2e2 !important;
}

/* Atenuar el número y el gráfico de los meses vecinos */
.grid-calendario-mes .casilla-dia.dia-otro-mes .num-dia,
.grid-calendario-mes .casilla-dia.dia-otro-mes .etiqueta-turno {
    opacity: 0.35;
}

/* Ajustar la cabecera de BusApp en móviles */
@media screen and (max-width: 600px) {
    .bizkaibus-header {
        padding: 12px;
        box-sizing: border-box;
    }

    .header-container {
        flex-wrap: wrap;
        gap: 12px;
    }

    .logo-area {
        min-width: 0;
        flex: 1;
    }

    .logo-area h1 {
        font-size: 1.2rem;
    }

    .logo-img {
        height: 42px;
    }

    .btn-gestion-calendario {
        margin: 0;
        flex-shrink: 0;
    }
}

  /* Ocultar la antigua barra horizontal de pestañas */
.tabs {
  display: none;
}

/* Tarjetas de conductores */
.tarjeta-conductor {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 6px;
  border: 1px solid #cccccc;
  border-radius: 6px;
  box-sizing: border-box;
}

.datos-conductor {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.telefono-conductor {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #555555;
  overflow-wrap: anywhere;
}

/* Título principal de la sección */
.titulo-seccion-ajustes {
  background: var(--primary);
  color: #ffffff;
  padding: 14px 16px;
  margin: 0 0 18px;
  border-radius: 8px;
  font-size: 1.4rem;
  font-weight: 700;
}

/* Desplegable: fondo claro, sin verde oscuro */
.encabezado-ajustes {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.titulo-ajustes {
  margin: 0;
  color: var(--primary);
  font-size: 1.05rem;
  font-weight: 700;
}

#iconoAjustesPersonalizacion {
  color: var(--primary);
  flex-shrink: 0;
}

/* Título interior */
.subtitulo-configuracion {
  margin: 0 0 16px;
  padding: 12px 14px;
  background: var(--primary-light);
  color: var(--primary);
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  font-size: 1.05rem;
  font-weight: 700;
}

/* Botón de acceso directo al cuadrante */
.btn-cuadrante-directo {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-cuadrante-directo:hover {
  background: var(--primary-hover);
}

/* Firma de autoría de KwenApp */
.firma-app {
  text-align: center;
  font-size: 12px;
  color: #777;
  padding: 12px 10px;
  margin-top: 20px;
  border-top: 1px solid #ddd;
}