:root {
  --primary-color: #4a6da7;
  --secondary-color: #e6e6e6;
  --text-color: #333;
  --border-color: #ccc;
  --highlight-color: #f5f5f5;
  --font-family: 'Arial', sans-serif;
}

/* Tema Classic */
.theme-classic {
  --primary-color: #4a6da7;
  --secondary-color: #e6e6e6;
  --text-color: #333;
  --border-color: #ccc;
  --highlight-color: #f5f5f5;
}

/* Tema Modern */
.theme-modern {
  --primary-color: #3498db;
  --secondary-color: #f0f0f0;
  --text-color: #2c3e50;
  --border-color: #ddd;
  --highlight-color: #ecf0f1;
}

/* Tema Colorful */
.theme-colorful {
  --primary-color: #9b59b6;
  --secondary-color: #e8daef;
  --text-color: #34495e;
  --border-color: #d6b5e5;
  --highlight-color: #f4ecf7;
}

/* Tema BW */
.theme-bw {
  --primary-color: #333;
  --secondary-color: #f9f9f9;
  --text-color: #222;
  --border-color: #888;
  --highlight-color: #eee;
}

/* Tema Fun */
.theme-fun {
  --primary-color: #e74c3c;
  --secondary-color: #fdedec;
  --text-color: #2e4053;
  --border-color: #f5b7b1;
  --highlight-color: #fcf3cf;
}

/* Estils generals */
.contenidor-planificador {
  max-width: 1200px;
  margin: 0 auto;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 20px;
  font-family: var(--font-family);
  color: var(--text-color);
}

.titol-planificador {
  color: var(--primary-color);
  margin-bottom: 20px;
  text-align: center;
}

/* Pestanyes de navegació */
.pestanyes {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--primary-color);
}

.pestanya {
  padding: 10px 20px;
  background-color: var(--secondary-color);
  cursor: pointer;
  margin-right: 5px;
  border-radius: 5px 5px 0 0;
}

.pestanya.activa {
  background-color: var(--primary-color);
  color: white;
}

.contingut-pestanya {
  display: none;
}

.contingut-pestanya.activa {
  display: block !important;
}

/* Formularis */
h2, h3, h4 {
  color: var(--primary-color);
  margin-bottom: 15px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
}

input, select, textarea {
  width: 100%;
  padding: 8px;
  margin-bottom: 15px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-family: var(--font-family);
}

button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 16px;
  margin-right: 10px;
  margin-bottom: 10px;
}

button:hover {
  opacity: 0.9;
}

/* Estructura del formulari */
.grup-formulari {
  margin-bottom: 20px;
}

.fila-formulari {
  display: flex;
  gap: 20px;
  margin-bottom: 15px;
}

.columna-formulari {
  flex: 1;
}

.previsualitzacio-logotip {
  max-width: 100px;
  max-height: 100px;
  margin-top: 10px;
  border: 1px solid var(--border-color);
}

/* Configuració de franges */
.configuracio-franges {
  margin-bottom: 20px;
  padding: 15px;
  background-color: var(--highlight-color);
  border-radius: 5px;
}

.dies-franges {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.dia-franja {
  flex: 1;
  min-width: 200px;
  padding: 10px;
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: 5px;
}

.franja-config {
  margin-bottom: 10px;
}

.franja-nombre {
  width: 60px;
}

/* Taula */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  table-layout: fixed;
}

table, th, td {
  border: 1px solid var(--border-color);
}

th {
  background-color: var(--primary-color);
  color: white;
  padding: 10px;
  text-align: center;
}

.columna-franja {
  width: 15%;
  background-color: var(--secondary-color);
}

td {
  padding: 0;
  vertical-align: top;
  height: 90px;
}

tr:nth-child(even) {
  background-color: var(--highlight-color);
}

.columna-franja-cel {
  background-color: var(--secondary-color);
  font-weight: bold;
  padding: 10px;
  text-align: center;
}

/* Cel·les de la taula de planificació */
.cel-dia {
  padding: 0;
  position: relative;
  min-height: 90px;
}

.capçalera-assignatura {
  background-color: var(--secondary-color);
  padding: 5px;
  font-weight: bold;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9em;
  min-height: 20px;
}

.capçalera-assignatura[data-placeholder]:empty:before {
  content: attr(data-placeholder);
  color: #888;
  font-style: italic;
}

.contingut-activitat {
  padding: 8px;
  min-height: 60px;
}

.contingut-activitat[data-placeholder]:empty:before {
  content: attr(data-placeholder);
  color: #888;
  font-style: italic;
}

.editable {
  min-height: 30px;
  border: 1px dashed transparent;
}

.editable:hover {
  border-color: var(--border-color);
  background-color: var(--highlight-color);
}

/* Previsualització */
.previsualitzacio-planificador {
  margin-top: 30px;
  padding: 20px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background-color: white;
  display: block !important; /* Assegurem que sempre sigui visible */
}

.capçalera-planificador {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-color);
}

.titol-previsualitzacio {
  margin: 0;
  font-size: 1.5em;
}

.meta-previsualitzacio {
  display: flex;
  gap: 20px;
  margin-top: 10px;
}

.logotip-previsualitzacio {
  max-height: 60px;
  max-width: 100px;
}

/* Previsualització de capçalera i activitat */
.capçalera-assignatura-preview {
  background-color: var(--secondary-color);
  padding: 5px;
  font-weight: bold;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9em;
  min-height: 20px;
}

.contingut-activitat-preview {
  padding: 8px;
  min-height: 60px;
}

/* Selector de tema */
.selector-tema {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.opcio-tema {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
}

.opcio-tema.seleccionat {
  border-color: var(--primary-color);
}

.opcio-tema-classic {
  background-color: #4a6da7;
}

.opcio-tema-modern {
  background-color: #3498db;
}

.opcio-tema-colorful {
  background-color: #9b59b6;
}

.opcio-tema-bw {
  background-color: #333;
}

.opcio-tema-fun {
  background-color: #e74c3c;
}

/* Instruccions */
.instruccions {
  margin: 20px 0;
  padding: 15px;
  background-color: var(--highlight-color);
  border: 1px solid var(--border-color);
  border-radius: 5px;
}

.instruccions ul {
  margin-left: 20px;
}

/* Reduir alçada de les files PATI i MIGDIA */
.etiqueta-pati, .etiqueta-pati-preview {
    background-color: var(--highlight-color);
    text-align: center;
    padding: 2px !important; 
    height: 20px !important; /* Alçada reduïda */
    line-height: 20px !important; /* Centra verticalment el text */
    border-top: 1px dashed var(--border-color);
    border-bottom: 1px dashed var(--border-color);
    font-style: italic;
    font-weight: bold;
    color: #666;
}

/* Classe per a les files de PATI i MIGDIA */
tr.fila-baixa {
    height: 20px !important;
    max-height: 20px !important;
}

/* Estils d'impressió */
@media print {
  .contenidor-planificador {
    box-shadow: none;
    padding: 0;
  }
  
  .pestanyes, .contingut-pestanya:not(.previsualitzacio-pestanya), button, .selector-tema {
    display: none !important;
  }
  
  .contingut-pestanya.previsualitzacio-pestanya {
    display: block !important;
  }
  
  body {
    background-color: white;
    padding: 0;
  }
  
  h2:not(.titol-previsualitzacio) {
    display: none;
  }
}

/* Estils específics per a la impressió */
@media print {
  /* Estils generals d'impressió */
  .contenidor-planificador {
    box-shadow: none;
    padding: 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
  }
  
  .pestanyes, .contingut-pestanya:not(.previsualitzacio-pestanya), button, .selector-tema {
    display: none !important;
  }
  
  .contingut-pestanya.previsualitzacio-pestanya {
    display: block !important;
    padding: 0;
    margin: 0;
  }
  
  body {
    background-color: white;
    padding: 0;
    margin: 0;
    font-family: Arial, sans-serif;
  }
  
  h2:not(.titol-previsualitzacio) {
    display: none;
  }
  
  /* Estils específics per a la capçalera */
  .previsualitzacio-planificador {
    margin: 0;
    padding: 10mm;
    border: none;
  }
  
  .capçalera-planificador {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10mm;
    padding-bottom: 3mm;
    border-bottom: 1px solid #4a6da7;
  }
  
  .titol-previsualitzacio {
    margin: 0;
    font-size: 18pt;
    color: #4a6da7;
  }
  
  .meta-previsualitzacio {
    display: flex;
    gap: 20px;
    margin-top: 5mm;
    font-size: 12pt;
  }
  
  .logotip-previsualitzacio {
    max-height: 80px;
    max-width: 120px;
  }
  
  /* Estils per a la taula */
  #taula-previsualitzacio {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
  }
  
  #taula-previsualitzacio th {
    background-color: #4a6da7 !important;
    color: white !important;
    padding: 8px;
    text-align: center;
    font-weight: bold;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  #taula-previsualitzacio .columna-franja-cel {
    background-color: #e6e6e6 !important;
    font-weight: bold;
    text-align: center;
    width: 15%;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  #taula-previsualitzacio td {
    padding: 0;
    vertical-align: top;
    height: 70px;
    border: 1px solid #ccc;
  }
  
  .capçalera-assignatura-preview {
    background-color: #e6e6e6 !important;
    padding: 5px;
    font-weight: bold;
    border-bottom: 1px solid #ccc;
    font-size: 10pt;
    min-height: 15px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  .contingut-activitat-preview {
    padding: 6px;
    min-height: 40px;
    font-size: 9pt;
  }
  
  .etiqueta-pati-preview {
    background-color: #f5f5f5 !important;
    text-align: center;
    padding: 3px !important;
    height: 20px !important;
    line-height: 20px !important;
    border-top: 1px dashed #ccc;
    border-bottom: 1px dashed #ccc;
    font-style: italic;
    color: #666;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Ajustar paginació */
  @page {
    size: landscape;
    margin: 10mm;
  }
}

/* Estilos para la tabla de configuración de franjas */
.taula-config-franges {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    background-color: white;
}

.taula-config-franges th,
.taula-config-franges td {
    padding: 10px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.taula-config-franges th {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
}

.taula-config-franges tr:nth-child(even) {
    background-color: var(--highlight-color);
}

.taula-config-franges td:first-child {
    text-align: left;
    background-color: var(--secondary-color);
    width: 20%;
}

.taula-config-franges input[type="number"] {
    width: 50px;
    padding: 5px;
    text-align: center;
    margin: 0;
}

/* Botones de exportación */
.botons-exportacio {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

.botons-exportacio button {
    flex: 1;
    max-width: 200px;
    padding: 10px 15px;
}

/* Botones del planificador */
.botons-planificador {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.botons-planificador button {
    flex: 1;
    max-width: 200px;
    padding: 12px 15px;
    font-size: 1em;
    transition: background-color 0.2s, transform 0.1s;
}

.botons-planificador button:hover {
    background-color: var(--primary-color);
    opacity: 0.9;
    transform: translateY(-2px);
}

#descarregar-pdf-planner {
    background-color: #e74c3c;
}

#descarregar-pdf-planner:hover {
    background-color: #c0392b;
}

/* Estils per a noms de franges editables */
.nom-franja-editable {
    width: 100%;
    min-height: 20px;
    padding: 5px;
    outline: none;
    cursor: text;
    font-weight: bold;
    transition: background-color 0.2s ease;
    text-align: center;
}

.nom-franja-editable:hover {
    background-color: rgba(255, 255, 255, 0.5);
}

.nom-franja-editable:focus {
    background-color: #fff;
    box-shadow: inset 0 0 2px var(--primary-color);
    border: 1px dashed var(--primary-color);
    border-radius: 3px;
}

/* Mostrar un petit indicador visual quan es posi el cursor sobre el nom */
.columna-franja-cel:hover .nom-franja-editable::after {
    content: "✏️";
    font-size: 0.8em;
    margin-left: 5px;
    opacity: 0.5;
}

/* Estils per a la columna de franja */
.columna-franja-cel {
    background-color: var(--secondary-color);

/* Mejoras para la visualización en móviles */
@media (max-width: 768px) {
    .botons-planificador {
        flex-direction: column;
        align-items: stretch;
    }
    
    .botons-planificador button {
        max-width: none;
        margin-bottom: 5px;
    }

    .taula-config-franges {
        font-size: 0.9em;
    }
    
    .taula-config-franges th,
    .taula-config-franges td {
        padding: 6px;
    }
    
    .taula-config-franges input[type="number"] {
        width: 40px;
        padding: 3px;
    }
}