/* ===================================== */
/* SEZIONE COMMENTI - TEMA CHIARO PREMIUM con NESTING */
/* ===================================== */

:root {
    --color-background: #f8f9fa;
    --color-surface: #ffffff;
    --color-primary: #212529;
    --color-secondary: #6c757d;
    --color-accent: #007bff;
    --color-accent-hover: #0056b3;
    --color-border: #dee2e6;
    --color-error: #dc3545;
    --font-body: 'Inter', sans-serif;
}

.comments-section {
    background-color: var(--color-background);
    padding: 4rem 1rem;
    font-family: var(--font-body);
}

.comments-container {
    max-width: 750px;
    margin: 0 auto;
}

/* --- FORM COMMENTI --- */
.comment-form-wrapper {
    background: var(--color-surface);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    margin-bottom: 3rem;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.05);
}

.form-title {
    text-align: center;
    font-size: 1.8rem;
    color: var(--color-primary);
    margin: 0 0 2rem 0;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}
@media (min-width: 600px) {
    .form-row { grid-template-columns: 1fr 1fr; }
}

.form-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 10px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-primary);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

/* Floating Labels */
.floating-label label {
    position: absolute;
    top: 13px;
    left: 10px;
    color: var(--color-secondary);
    pointer-events: none;
    transition: all 0.2s ease;
    background-color: var(--color-surface); /* Maschera il bordo dell'input */
    padding: 0 5px;
}

.floating-label input:focus + label,
.floating-label input:not(:placeholder-shown) + label,
.floating-label textarea:focus + label,
.floating-label textarea:not(:placeholder-shown) + label {
    top: -10px;
    left: 8px;
    font-size: 0.8rem;
    color: var(--color-accent);
}

.error-message {
    display: block;
    font-size: 0.8rem;
    color: var(--color-error);
    margin-top: 5px;
    min-height: 1em;
}

.form-group input.error,
.form-group textarea.error {
    border-color: var(--color-error);
}

.g-recaptcha {
    margin: 1rem 0;
}

.replying-to-notice {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    background: #e6f2ff;
    border: 1px solid var(--color-accent);
    border-radius: 6px;
    margin-bottom: 1.5rem;
    color: var(--color-primary);
}
.replying-to-notice a {
    color: var(--color-accent);
    text-decoration: underline;
    margin-left: 10px;
}

.comment-success-message {
    text-align: center;
    padding: 1rem;
    background-color: #e6f7ff;
    border: 1px solid var(--color-accent);
    color: #004085;
    border-radius: 8px;
    margin-bottom: 3rem;
}


/* --- LISTA COMMENTI E STILI DI ANNIDAMENTO --- */
.comments-main-title {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-primary);
}

.comment-thread {
    position: relative;
}

.comment {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.comment-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: var(--color-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
}
.comment-thread:nth-child(3n+1) .comment-avatar { background-color: #6f42c1; }
.comment-thread:nth-child(3n+2) .comment-avatar { background-color: #28a745; }

.comment-content {
    flex-grow: 1;
}

.comment-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 0.5rem;
}

.comment-author {
    font-weight: 600;
    color: var(--color-primary);
}

.comment-date {
    font-size: 0.8rem;
    color: var(--color-secondary);
}

.comment-body {
    line-height: 1.7;
    color: var(--color-primary);
    word-wrap: break-word;
}
.comment-body p { margin: 0; }

.comment-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 1.5rem;
}

.comment-actions a {
    color: var(--color-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.comment-actions a:hover {
    color: var(--color-accent);
}

/* --- LOGICA CSS PER L'ANNIDAMENTO --- */
.replies-container {
    display: none; /* Nascondi le risposte di default */
    padding-left: 20px; /* Spazio per la linea di connessione */
    margin-left: 20px; /* Indentazione rispetto all'avatar padre */
    position: relative;
}

.replies-container.open {
    display: block; /* Mostra le risposte quando la classe 'open' è aggiunta */
}

/* Linea di connessione verticale */
.replies-container::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-border);
}

/* Riduci leggermente la dimensione degli avatar nelle risposte */
.replies-container .comment-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
}

/* Adegua la posizione e l'indentazione per i livelli successivi */
.replies-container .replies-container {
    margin-left: 28px; /* Aumenta l'indentazione */
    padding-left: 12px;
}

/* --- BOTTONI E SPINNER --- */
.cta-button, .cta-button-outline {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 12px 28px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 1rem;
    border: 2px solid var(--color-accent);
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 300px;
    margin: 1rem auto 0;
}

.cta-button {
    background: var(--color-accent);
    color: #fff;
}
.cta-button:hover:not(:disabled) {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
}

.cta-button-outline {
    background: transparent;
    color: var(--color-accent);
}
.cta-button-outline:hover:not(:disabled) {
    background: var(--color-accent);
    color: #fff;
}

.cta-button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.spinner {
    display: inline-block;
    width: 1.2em;
    height: 1.2em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-rotation 0.7s linear infinite;
    vertical-align: middle;
}

@keyframes spinner-rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}