@font-face {
    font-family: Poppins;
    src: url(Poppins-Regular.ttf) format("truetype");
    font-weight: 400;
    font-style: normal;
}

:root {
    --bg-color: #f3eae1;
    --main-content-bg: #ffffff;
    --text-color: #222;
    --border-color: #e5e5e5;
    --accent-color: #f4aec3;
    --reason-color: #e73a67;
    --placeholder-color: #8e8ea0;
    --max-width: 800px;
    --font-family: "Poppins", "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", "Lucida Sans", Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.hidden { display: none !important; }

.poc-banner {
    background-color: #fffbe6;
    color: #5d4c0c;
    padding: 12px 20px;
    text-align: center;
    border-bottom: 1px solid #f0e4b8;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}
.close-banner-btn {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #5d4c0c;
}

header {
    background-color: none;
    border: none;
    width: 100%;
}
.header-content {
    padding: 10px 20px;
    display: flex;
    align-items: center;
}
.header-logo {
    width: 80px;
    position: fixed;
    margin-top: 32px;
}
#header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-grow: 1;
    padding-left: 80px;
}
#header-links a {
    color: var(--text-color);
    text-decoration: none;
    margin: 0 15px;
    font-size: .75rem;
}
#header-links a:hover { text-decoration: underline; }
.header-btn {
    background-color: #f4aec3;
    color: #fff;
    border: 1px solid #f4aec3;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
}
.header-btn:hover {
    background-color: #f4aec3cc;
    border-color: #f4aec3cc;
}

main {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}
#initial-view {
    max-width: var(--max-width);
    margin: 40px auto;
    text-align: center;
}
.center-logo { width: 400px; margin-bottom: 24px; }
.welcome-text h1 { font-size: 2.5rem; margin-bottom: 1rem; }
.welcome-text p { margin-bottom: 1rem; line-height: 1.6; }
.welcome-text .question-prompt { margin-top: 2rem; font-weight: 500; }
.welcome-text ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}
.welcome-text ul li {
    background-color: #75c6cd33;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}
.welcome-text ul li:hover {
    background-color: #75c6cd;
}

#conversation-container {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    padding: 15px;
    border-radius: 16px;
    line-height: 1.6;
    width: 100%;
}
.user-message {
    background-color: #75c6cd33;
    border-right: 1px solid #75c6cd;
    align-self: flex-end;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    text-align: right;
}
.ai-message {
    background-color: #f4aec333;
    border-left: 1px solid #f4aec3;
    align-self: flex-start;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    animation: fadeIn 1s ease-in-out;
}
.processing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--placeholder-color);
    font-style: italic;
    align-self: flex-start;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sources-container {
    margin-top: 15px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}
.sources-toggle {
    background: none;
    border: none;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    text-align: left;
    padding: 5px 0;
}
.sources-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.source-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    background-color: #0099cc08;
    padding: 12px;
    border-radius: 8px;
}
.source-score-meter { font-size: 20px; }
.source-details { flex-grow: 1; }
.source-details strong { font-weight: 700; color: #036;}
.source-details .meta-info {
    font-style: italic;
    color: #6c757d;
    font-size: 13px;
    margin: 4px 0;
}
.source-details .reason {
    color: var(--reason-color);
    font-size: 14px;
    margin-top: 5px;
}
.source-link a {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 20px;
}

#chat-footer {
    padding: 10px 20px 20px 20px;
    width: 100%;
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}
#chat-footer.initial-pos {
    max-width: var(--max-width);
    margin: 0 auto;
}
#chat-footer.fixed-bottom {
    position: sticky;
    bottom: 0;
    border-top: none;
    background: none;
}

.chat-form {
    width: var(--max-width);
    margin: 0 auto;
    position: relative;
    background-color: var(--main-content-bg);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
#query-input {
    width: 100%;
    border: none;
    background: none;
    padding: 20px 60px 20px 20px;
    font-size: 16px;
    font-family: var(--font-family);
    resize: none;
    outline: none;
    max-height: 200px;
    overflow-y: auto;
}
#send-button {
    position: absolute;
    bottom: 28px;
    right: 12px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background-color: var(--accent-color);
    color: white;
    cursor: pointer;
    font-size: 20px;
}
#send-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}
.footer-note {
    text-align: center;
    font-size: 12px;
    color: var(--placeholder-color);
    margin-top: 10px;
    width: var(--max-width);
    align-self: center;
}

.sources-header {
    display: flex;
    align-items: center;
    gap: 20px;
}

.sources-header>button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 16px;
}

.sources-header>button>img {
    height: 40px;
}

.sources-header>button.active, .sources-header>button:hover {
    background: #fff;
}

.sources-list-container {
    padding-top: 16px;
    display: flex;
    flex-direction: column;
}

.sources-list-container a {
    flex-direction: column;
    display: flex;
    gap: 8px;
    font-size: .9rem;
    text-decoration: none;
    color: #000;
    padding: 10px;
    border-radius: 16px;
}

.illustrazioni-container a {
    flex-direction: row;
}

.illustrazioni-container a>div:last-child {
    display: flex;
    flex-direction: column;
}

.illustrazioni-container, .cicliillustrativi-container {
    display: grid;
    grid-template-columns: auto auto auto;
}

.cicliillustrativi-container {
    display: grid;
    grid-template-columns: auto auto auto auto auto auto;
}

.sources-list-container a:hover {
    background: #fff;
}

@media (max-width: 600px) {
    #header-links { display: none; }
    .welcome-text h1 { font-size: 2rem; }
    .welcome-text ul { flex-direction: column; }
    .message { max-width: 95%; }
}