/* Importa il font Roboto da Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

/* Definizione delle variabili CSS */
:root {
  --primary-color: #007bff; /* Blu Bootstrap classico, vibrante */
  --secondary-color: #6c757d; /* Grigio Bootstrap standard */
  --accent-color: #74C0FC;  /* Il tuo blu attuale come accento o per elementi secondari */
  --success-color: #28a745;
  --danger-color: #dc3545;

  --text-color: #2a2f4c; /* Un grigio scuro-bluastro per il testo principale */
  --text-muted-color: #6c757d;
  --text-on-primary: #ffffff;
  --text-on-accent: #2a2f4c; /* Testo scuro su accento chiaro */

  --bg-color: #f8f9fc; /* Sfondo generale molto chiaro, tendente al grigio-blu */
  --surface-color: #ffffff; /* Per card, modali, sidebar */
  --border-color: #dfe3e8; /* Bordo più morbido */

  --border-radius-sm: 0.25rem;
  --border-radius-md: 0.375rem;
  --border-radius-lg: 0.5rem;

  --shadow-sm: 0 .125rem .25rem rgba(42,47,76,.075); /* Ombre più morbide */
  --shadow-md: 0 .5rem 1.25rem rgba(42,47,76,.1);
  --shadow-lg: 0 1rem 3rem rgba(42,47,76,.125);

  --font-family-sans-serif: 'Roboto', Arial, sans-serif;
}

/* Stile generale */
body {
  font-family: var(--font-family-sans-serif);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.65; /* Leggermente aumentata per leggibilità */
  font-size: 16px; /* Base font size */
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  color: #343a40; /* Grigio scuro per i titoli */
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}
h1 { font-size: 2.15rem; }
h3 { font-size: 1.6rem; } /* Titolo "Result" */
h4 { font-size: 1.2rem; } /* Titolo sidebar */

/* ----- Main Content Area Styling ----- */
main.col-12 > div.container { /* Applicato al container diretto dentro main */
    background-color: var(--surface-color);
    padding: 2rem 2.5rem; /* Più padding laterale */
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    margin-top: 2.5rem; /* Spazio dall'alto */
    margin-bottom: 2.5rem;
}

/* Logo e Icona Docs */
.logo {
  height: 90px;
  width: 90px;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  /* Idealmente: usa un PNG con sfondo trasparente o un SVG */
}

.pd { /* Icona Docs */
  height: 48px;
  width: 48px;
  border: 2px solid var(--accent-color);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.pd .fa-question {
  color: var(--accent-color) !important;
  font-size: 1.35rem !important;
  transition: color 0.2s ease-in-out;
}
.pd:hover {
  background-color: var(--accent-color);
  box-shadow: 0 0 12px rgba(116,192,252,0.4);
}
.pd:hover .fa-question {
  color: var(--text-on-accent) !important; /* O bianco se l'accento è scuro */
}

/* Textarea */
.custom-textarea {
  width: 100%;
  height: 220px;
  resize: vertical;
  padding: 0.85rem 1.1rem;
  border: 1px solid #adb5bd;
  border-radius: var(--border-radius-md);
  outline: none;
  font-size: 1rem;
  transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  background-color: #fdfdff; /* Sfondo leggermente diverso per l'input */
}
.custom-textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(0,123,255, 0.2);
  background-color: var(--surface-color);
}

/* Input numerico e Select */
.form-control, .form-select {
    border-radius: var(--border-radius-md);
    border-color: #adb5bd;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    background-color: #fdfdff;
    font-size: 0.95rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(0,123,255, 0.2);
  background-color: var(--surface-color);
}

/* Bottoni */
.btn {
  border-radius: var(--border-radius-md);
  padding: 0.75rem 1.5rem; /* Più padding per un aspetto "premium" */
  font-weight: 500;
  font-size: 1rem;
  transition: all 0.2s ease-in-out; /* Transizione per tutto */
  letter-spacing: 0.5px;
  text-transform: capitalize; /* Opzionale: Compute Placeholders -> Compute Placeholders */
}

.btn-secondary { /* Questo è il tuo bottone principale */
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--text-on-primary);
  box-shadow: 0 4px 6px rgba(0,123,255,.15), 0 1px 3px rgba(0,0,0,.08); /* Ombra più pronunciata */
}
.btn-secondary:hover {
  background-color: #0069d9;
  border-color: #0062cc;
  color: var(--text-on-primary);
  box-shadow: 0 7px 14px rgba(0,123,255,.1), 0 3px 6px rgba(0,0,0,.08);
  transform: translateY(-2px);
}
.btn:active, .btn-secondary:active { /* Specificità per :active */
  transform: translateY(1px) scale(0.99);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.08), 0 1px 2px rgba(0,123,255,.1);
}

/* Radio buttons */
.form-check-input {
    margin-top: 0.3em; /* Allineamento migliore con etichetta */
}
.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}
.form-check-label {
    cursor: pointer;
    color: var(--text-muted-color);
    padding-left: 0.35rem;
    font-size: 0.95rem;
}
.form-check-input:checked + .form-check-label {
    color: var(--text-color);
    font-weight: 500;
}

/* ----- Sidebar ----- */
.sidebar {
  background-color: var(--surface-color);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  border-radius: var(--border-radius-lg);
  margin-top: 2.5rem; /* Allinea con il main content */
  margin-bottom: 2.5rem;
  /* min-vh-100 è nell'HTML e va bene per la colonna */
}
.sidebar h4#title_result {
  margin-top: 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--primary-color);
}
.sidebar #sidebar { /* Contenitore delle citazioni */
    border-top: none !important;
    margin-top: 1.25rem;
}

/* Citazioni nella Sidebar */
.sidebar .alternative-cit {
  padding: 0.85rem 1rem;
  border-radius: var(--border-radius-sm);
  transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, transform 0.15s ease-out;
  display: block;
  line-height: 1.5;
  /* MODIFICATO: Testo più scuro per le citazioni non selezionate */
  color: #495057; /* Un grigio più scuro (Bootstrap's $gray-700) */
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  border: 1px solid transparent;
}
.sidebar .alternative-cit:hover {
  background-color: #eef6ff;
  color: var(--primary-color);
  border-color: rgba(0,123,255, 0.2);
  transform: translateX(3px);
}
.sidebar .alternative-cit.text-decoration-underline.fw-bold { /* Selezione */
  background-color: rgba(0,123,255, 0.12);
  color: var(--primary-color); /* Il colore primario va bene per la selezione */
  border-color: rgba(0,123,255, 0.3);
  text-decoration: none !important;
  font-weight: 700 !important;
}
.sidebar .btn-circle { /* Pulsante link nella sidebar */
    padding: 0.3rem;
    width: 34px;
    height: 34px;
    line-height: 1;
    background-color: #f1f3f5;
    border: none;
    color: var(--text-muted-color);
}
.sidebar .btn-circle:hover {
    background-color: #e9ecef;
    color: var(--primary-color);
}
.sidebar .fa-link {
    font-size: 0.9rem;
}

/* ----- Sezione Risultato nel Main Content ----- */
#textForm .text-center.my-4 h3 { /* "Result" */
    color: var(--primary-color);
    margin-bottom: 1.75rem;
}
#result .col-8 { /* Testo con [1], [2] */
    font-size: 1.05rem;
    line-height: 1.75;
}
#result .col-4 .format-logo { /* Icone APA/BibTeX */
  height: 44px;
  width: 44px;
  border-radius: var(--border-radius-md); /* Angoli arrotondati */
  border: 2px solid transparent;
  transition: all 0.2s ease-in-out;
  margin: 0 0.6rem;
  box-shadow: var(--shadow-sm);
}
#result .col-4 .format-logo:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 8px rgba(0,123,255,.15);
}

/* Placeholder [1], [2] nel testo risultato */
.cit_choice_btn {
  /* Rimuoviamo lo sfondo di default */
  background-color: transparent;
  color: var(--primary-color); /* Manteniamo il colore primario per visibilità */
  padding: 0.1em 0.2em; /* Padding ridotto */
  border-radius: var(--border-radius-sm);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: underline; /* Sottolineatura come un link */
  text-decoration-thickness: 1.5px; /* Sottolineatura leggermente più spessa */
  text-underline-offset: 2px; /* Distanza della sottolineatura dal testo */
  display: inline-block;
}
.cit_choice_btn:hover {
  color: #0056b3; /* Blu più scuro all'hover */
  text-decoration-color: #0056b3;
  background-color: rgba(0,123,255,0.08); /* Sfondo leggerissimo all'hover */
  transform: scale(1.03); /* Leggero ingrandimento */
}
.cit_choice_btn.active-placeholder-btn {
  color: #0056b3; /* Blu scuro per l'attivo */
  background-color: rgba(0,123,255,0.15); /* Sfondo leggermente più marcato per l'attivo */
  text-decoration-color: #0056b3;
  box-shadow: none; /* Rimuoviamo l'ombra precedente, non serve più */
  transform: scale(1.03);
  font-weight: 700; /* Già presente, ma per enfasi */
}

/* ----- Modali ----- */
.modal-content {
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    border: none;
}
.modal-header {
    background-color: var(--primary-color);
    color: var(--text-on-primary);
    border-bottom: none;
    padding: 1.25rem 1.5rem;
    border-top-left-radius: var(--border-radius-lg);
    border-top-right-radius: var(--border-radius-lg);
}
.modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    padding: 0.75rem; /* Area cliccabile più grande */
}
.modal-title {
    font-weight: 500;
    font-size: 1.25rem;
}
.modal-body {
    padding: 1.5rem;
    font-size: 0.95rem;
}
.modal-footer {
    padding: 1rem 1.5rem;
    background-color: #f8f9fa; /* Sfondo leggermente diverso per il footer */
    border-top: 1px solid var(--border-color);
    border-bottom-left-radius: var(--border-radius-lg);
    border-bottom-right-radius: var(--border-radius-lg);
}
.modal-footer .btn { /* Bottoni nel modale */
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
}

/* ----- Utility ----- */
.button-disabled {
    opacity: 0.55 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}
.loading-spinner {
    text-align: center;
    padding: 2.5rem;
}
.loading-spinner .spinner-border {
    width: 3rem;
    height: 3rem;
    color: var(--primary-color);
}
.loading-spinner p {
    margin-top: 1rem;
    color: var(--text-muted-color);
    font-size: 1.1rem;
}

/* ----- Responsive Adjustments (da mantenere e verificare) ----- */
@media (max-width: 767.98px) {
  main.col-12 > div.container, .sidebar {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    border-radius: var(--border-radius-md);
  }
  .logo { height: 75px; width: 75px; }
  .pd { height: 42px; width: 42px; }
  .pd .fa-question { font-size: 1.2rem !important; }
  .custom-textarea { height: 160px; }
  h1 { font-size: 1.85rem; }
  h3 { font-size: 1.45rem; }
  .btn { padding: 0.65rem 1.2rem; font-size: 0.9rem; }
  #result .col-4 .format-logo { height: 38px; width: 38px; margin: 0 0.3rem;}
  .sidebar .alternative-cit { font-size: 0.85rem; padding: 0.7rem 0.85rem;}

  #result .row > .col-8 { /* Il testo con le citazioni */
    flex: 0 0 100%; /* Occupa tutta la larghezza disponibile */
    max-width: 100%;
    order: 1; /* Mettilo per primo se necessario */
    text-align: left; /* Assicura allineamento a sinistra */
    padding-right: 0; /* Rimuovi padding se c'è conflitto con .col-4 */
    padding-left: 0;
  }
  #result .row > .col-4 { /* Le icone APA/BibTeX */
    flex: 0 0 100%; /* Occupa tutta la larghezza disponibile */
    max-width: 100%;
    order: 2; /* Mettilo dopo il testo */
    justify-content: center !important; /* Centra le icone quando sono su una riga propria */
    margin-top: 1rem; /* Aggiungi spazio sopra le icone */
    padding-left: 0;
    padding-right: 0;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) { /* Tablet */
    main.col-12 > div.container, .sidebar {
        padding: 2rem;
    }
    .custom-textarea { height: 190px; }
}

/* Desktop e oltre (992px+) - custom-textarea già a 220px da stile base */
