:root {
    --primary-color: #0077cc;
    --primary-dark: #005fa3;
    --secondary-color: #f0f0f0;
    --background-light: #f8f8f8;
    --text-color: #333;
    --card-bg: white;
    --shadow-light: rgba(0,0,0,0.1);
    --shadow-medium: rgba(0,0,0,0.2);
    --font-heading: 'Merriweather', serif;
    --font-body: 'Open Sans', sans-serif;
  }

  body {
    font-family: var(--font-body);
    margin: 0;
    padding: 20px;
    background: var(--background-light);
    color: var(--text-color);
    line-height: 1.6;
  }

  h1, h2 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 25px;
  }

  .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
  }

  .inicio-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 30px;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border-radius: 5px;
    text-decoration: none;
    transition: background 0.3s ease, transform 0.2s ease;
    font-weight: 600;
  }
  .inicio-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
  }

  .filter-container {
    text-align: center;
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }

  .filter-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    font-size: 1rem;
    font-weight: 600;
  }
  .filter-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
  }
  .filter-btn.active {
    background: var(--primary-dark);
    box-shadow: 0 2px 5px var(--shadow-medium);
  }

  .card-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 50px;
  }

  .card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 10px var(--shadow-light);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 20px var(--shadow-medium);
  }
  .card h2 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.5rem;
    text-align: left;
  }
  .card p {
    font-size: 0.95rem;
    color: #555;
  }

  .ia-container {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 10px var(--shadow-light);
    max-width: 800px;
    margin: 0 auto 60px;
  }
  .ia-container h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
  }

  .preguntas-sugeridas {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
  margin-bottom: 25px;
}

.pregunta-btn {
  background: var(--secondary-color);
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  border-radius: 20px;
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}

.pregunta-btn:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-2px);
}

  textarea {
    width: 100%;
    padding: 12px;
    border-radius: 5px;
    border: 1px solid #ddd;
    resize: vertical;
    min-height: 80px;
    font-family: var(--font-body);
    font-size: 1rem;
    box-sizing: border-box;
  }
  textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(0, 119, 204, 0.3);
  }

  .ia-button {
    margin-top: 15px;
    padding: 12px 25px;
    border: none;
    /* border-radius: 5px;  <-- Quitamos este para el ovalado */
    border-radius: 50px; /* Hacemos el botón ovalado */
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    font-size: 1.05rem;
    font-weight: 600;
    
    /* Para centrar el icono y el texto */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px; /* Espacio entre icono y texto */
  }
  .ia-button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
  }
  .ia-button:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
  }

  .ia-button svg {
    fill: white; /* Color del icono */
    width: 18px;
    height: 18px;
  }

  .loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0,0,0,.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    -webkit-animation: spin 1s ease-in-out infinite;
    margin-left: 10px;
    vertical-align: middle;
  }

  @keyframes spin {
    to { -webkit-transform: rotate(360deg); }
  }
  @-webkit-keyframes spin {
    to { -webkit-transform: rotate(360deg); }
  }

  /* Estilos para el historial de preguntas */
  .history-container {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 10px var(--shadow-light);
    max-width: 800px;
    margin: 40px auto 60px;
  }

  .history-container h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.8rem;
    color: var(--primary-color);
  }

  #historyList {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    background-color: #fdfdfd;
  }

  .history-item {
    margin-bottom: 15px;
    padding: 10px;
    background-color: var(--secondary-color);
    border-radius: 5px;
    border-left: 5px solid var(--primary-color);
    position: relative;
    padding-right: 40px;
  }

  .history-item:last-child {
    margin-bottom: 0;
  }

  .history-item p {
    margin: 0 0 5px 0;
    color: #333;
  }

  .history-item .question {
    font-weight: 600;
  }

  .history-item .answer {
    font-style: italic;
    color: #555;
    font-size: 0.95em;
  }

  .clear-history-btn {
    display: block;
    margin-top: 20px;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    background: #dc3545;
    color: white;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    font-weight: 600;
  }

  .clear-history-btn:hover {
    background: #c82333;
    transform: translateY(-2px);
  }

  .delete-item-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
    padding: 0 5px;
    transition: color 0.2s ease;
  }

  .delete-item-btn:hover {
    color: #dc3545;
  }


  /* Media Queries para responsividad */
  @media (max-width: 768px) {
    body {
      padding: 15px;
    }
    h1 {
      font-size: 2rem;
    }
    .card-container {
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 20px;
    }
    .filter-btn {
      padding: 8px 15px;
      font-size: 0.9rem;
    }
    .ia-container, .history-container {
      padding: 20px;
    }
    .ia-container h2, .history-container h2 {
      font-size: 1.5rem;
    }
  }

  @media (max-width: 480px) {
    h1 {
      font-size: 1.8rem;
    }
    .inicio-btn {
      width: 100%;
      text-align: center;
      justify-content: center;
    }
    .filter-container {
      flex-direction: column;
      gap: 8px;
    }
    .filter-btn {
      width: 100%;
      margin: 0;
    }
    .card-container {
      grid-template-columns: 1fr;
    }
    .history-item {
      padding: 10px 10px 10px 15px;
      border-left-width: 3px;
    }
    .delete-item-btn {
      font-size: 1em;
      top: 2px;
      right: 2px;
    }
  }