/* ============================================
   FORUM CSS
   ============================================ */

/* Breadcrumbs */
.forum-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.forum-breadcrumb a {
    color: #3498db;
    text-decoration: none;
}
.forum-breadcrumb a:hover {
    text-decoration: underline;
}
.forum-breadcrumb .sep {
    color: #ccc;
}

/* Page header */
.forum-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.forum-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    color: #1a2332;
}
.forum-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: #1a2332;
}

/* Stats bar */
.forum-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    padding: 14px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 14px;
    color: #495057;
}
.forum-stats .stat-value {
    font-weight: 700;
    color: #1a2332;
}

/* ============================================
   CATEGORIE GRID
   ============================================ */
.forum-categories {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}
.forum-cat-row {
    display: grid;
    grid-template-columns: 1fr 80px 80px 200px;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}
.forum-cat-row:hover {
    background: #f8f9fa;
}
.forum-cat-header {
    display: grid;
    grid-template-columns: 1fr 80px 80px 200px;
    gap: 12px;
    padding: 10px 20px;
    background: #1a2332;
    color: white;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.forum-cat-info {
    display: flex;
    align-items: center;
    gap: 14px;
}
.forum-cat-icon {
    font-size: 28px;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f4f8;
    border-radius: 8px;
}
.forum-cat-text h3 {
    margin: 0 0 2px 0;
    font-size: 15px;
    font-weight: 600;
    color: #1a2332;
}
.forum-cat-text p {
    margin: 0;
    font-size: 13px;
    color: #6c757d;
}
.forum-cat-count {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}
.forum-cat-last {
    font-size: 12px;
    color: #6c757d;
    min-width: 0;
}
.forum-cat-last .last-title {
    color: #3498db;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 180px;
}
.forum-cat-last .last-meta {
    color: #999;
    margin-top: 2px;
}

/* ============================================
   THREAD LIST
   ============================================ */
.forum-threads {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}
.forum-thread-header {
    display: grid;
    grid-template-columns: 1fr 80px 80px 140px;
    gap: 12px;
    padding: 10px 20px;
    background: #1a2332;
    color: white;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.forum-thread-row {
    display: grid;
    grid-template-columns: 1fr 80px 80px 140px;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: white;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}
.forum-thread-views {
    text-align: center;
    font-size: 13px;
    color: #999;
}
.forum-thread-row:hover {
    background: #f8f9fa;
}
.forum-thread-row.pinned {
    background: #fffcf0;
    border-left: 3px solid #f39c12;
}
.forum-thread-row.chiuso {
    opacity: 0.65;
}
.forum-thread-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.forum-thread-title h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1a2332;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.forum-thread-title .thread-meta {
    font-size: 12px;
    color: #999;
    margin-top: 2px;
}
.forum-thread-badges {
    display: flex;
    gap: 6px;
    align-items: center;
}
.badge-pinned, .badge-chiuso {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-pinned {
    background: #fff3cd;
    color: #856404;
}
.badge-chiuso {
    background: #f8d7da;
    color: #721c24;
}
.forum-thread-replies {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}
.forum-thread-last {
    font-size: 12px;
    color: #6c757d;
}
.forum-thread-last .last-author {
    font-weight: 500;
    color: #495057;
}

/* ============================================
   POSTS
   ============================================ */
.forum-posts {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.forum-post {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}
.forum-post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-size: 13px;
}
.forum-post-author {
    display: flex;
    align-items: center;
    gap: 10px;
}
.forum-post-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #3498db;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.forum-post-avatar.admin {
    background: #e74c3c;
}
.forum-post-author-info .author-name {
    font-weight: 600;
    color: #1a2332;
}
.forum-post-author-info .author-badge {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    background: #e74c3c;
    color: white;
    margin-left: 6px;
    font-weight: 600;
}
.forum-post-author-info .author-date {
    display: block;
    font-size: 11px;
    color: #999;
    margin-top: 1px;
}
.forum-post-actions {
    display: flex;
    gap: 8px;
}
.forum-post-actions button,
.forum-post-actions a {
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    color: #6c757d;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.forum-post-actions button:hover,
.forum-post-actions a:hover {
    background: #e9ecef;
    color: #495057;
}
.forum-post-actions .btn-danger {
    color: #e74c3c;
    border-color: #f5c6cb;
}
.forum-post-actions .btn-danger:hover {
    background: #f8d7da;
}
.forum-post-body {
    padding: 16px;
    font-size: 14px;
    line-height: 1.65;
    color: #333;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.forum-post-body p {
    margin: 0 0 10px 0;
}
.forum-post-body p:last-child {
    margin-bottom: 0;
}
.forum-post-body blockquote {
    margin: 10px 0;
    padding: 10px 16px;
    border-left: 3px solid #3498db;
    background: #f8f9fa;
    color: #555;
    border-radius: 0 4px 4px 0;
}
.forum-post-body a {
    color: #3498db;
    text-decoration: underline;
}
.forum-post-body ul, .forum-post-body ol {
    margin: 8px 0;
    padding-left: 24px;
}
.forum-post-orig-lang {
    padding: 0 16px 8px;
    font-size: 11px;
}
.forum-post-orig-lang a {
    color: #999;
    text-decoration: none;
    border-bottom: 1px dashed #ccc;
}
.forum-post-orig-lang a:hover {
    color: #3498db;
    border-color: #3498db;
}
.forum-post-edited {
    font-size: 11px;
    color: #999;
    font-style: italic;
    margin-top: 10px;
}

/* Quote box */
.forum-quote-box {
    margin: 0 16px 12px;
    padding: 10px 14px;
    background: #f0f4f8;
    border-left: 3px solid #3498db;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    color: #555;
}
.forum-quote-box .quote-author {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}
.forum-quote-box .quote-text {
    max-height: 80px;
    overflow: hidden;
}

/* ============================================
   REPLY / NEW THREAD FORM
   ============================================ */
.forum-reply-form {
    margin-top: 24px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}
.forum-reply-form h3 {
    margin: 0;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-size: 15px;
    font-weight: 600;
}
.forum-reply-form .form-body {
    padding: 16px;
}
.forum-reply-form .form-group {
    margin-bottom: 14px;
}
.forum-reply-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
}
.forum-reply-form input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    box-sizing: border-box;
}
.forum-reply-form input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}
.forum-editor-wrap {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
}
.forum-editor-wrap:focus-within {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}
.forum-editor-wrap .ql-toolbar {
    border: none !important;
    border-bottom: 1px solid #dee2e6 !important;
    background: #fafafa;
}
.forum-editor-wrap .ql-container {
    border: none !important;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    min-height: 150px;
}
.forum-editor-wrap .ql-editor {
    min-height: 150px;
    padding: 12px;
}
.forum-editor-wrap .ql-editor.ql-blank::before {
    font-style: normal;
    color: #adb5bd;
}
.forum-reply-form .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}

/* Buttons */
.btn-forum {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.btn-forum-primary {
    background: #3498db;
    color: white;
}
.btn-forum-primary:hover {
    background: #2980b9;
}
.btn-forum-secondary {
    background: #f0f0f0;
    color: #333;
}
.btn-forum-secondary:hover {
    background: #e0e0e0;
}
.btn-forum-sm {
    padding: 5px 12px;
    font-size: 12px;
}

/* Pagination */
.forum-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 24px;
}
.forum-pagination a,
.forum-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 13px;
    color: #495057;
    text-decoration: none;
    transition: all 0.15s;
}
.forum-pagination a:hover {
    background: #e9ecef;
}
.forum-pagination .active {
    background: #3498db;
    border-color: #3498db;
    color: white;
}

/* Empty state */
.forum-empty {
    text-align: center;
    padding: 48px 20px;
    color: #999;
}
.forum-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}
.forum-empty p {
    font-size: 15px;
    margin: 0 0 16px 0;
}

/* Thread status bar */
.forum-thread-status {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.forum-thread-status.closed {
    background: #f8d7da;
    color: #721c24;
}

/* Admin bar */
.forum-admin-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.forum-admin-bar form {
    display: inline;
}
.forum-admin-bar .btn-forum {
    padding: 6px 14px;
    font-size: 12px;
}

/* Login prompt */
.forum-login-prompt {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 24px;
    font-size: 14px;
    color: #555;
}
.forum-login-prompt a {
    color: #3498db;
    font-weight: 600;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .forum-cat-header,
    .forum-thread-header {
        display: none;
    }
    .forum-cat-row {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 14px 16px;
    }
    .forum-cat-count,
    .forum-cat-last {
        display: none;
    }
    .forum-thread-row {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 12px 16px;
    }
    .forum-thread-replies,
    .forum-thread-views,
    .forum-thread-last {
        display: none;
    }
    .forum-thread-title .thread-meta {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }
    .forum-thread-title .thread-replies-mobile {
        display: inline;
    }
    .forum-stats {
        flex-direction: column;
        gap: 8px;
    }
    .forum-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .forum-post-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    .forum-post-actions {
        width: 100%;
    }
    .forum-admin-bar {
        flex-direction: column;
    }
}

/* Hide on desktop, show on mobile */
.thread-replies-mobile {
    display: none;
}
@media (max-width: 768px) {
    .thread-replies-mobile {
        display: inline;
    }
}

/* Modifica post - textarea nascosta */
.forum-edit-overlay {
    display: none;
    padding: 16px;
    border-top: 1px solid #e9ecef;
}
.forum-edit-overlay.active {
    display: block;
}

/* Language switcher inline nel breadcrumb */
.forum-lang-switcher {
    display: inline-flex;
    gap: 4px;
    margin-left: auto;
    align-items: center;
}
.forum-lang-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 22px;
    border-radius: 3px;
    border: 1px solid transparent;
    opacity: 0.5;
    transition: all 0.15s;
    text-decoration: none;
}
.forum-lang-btn:hover {
    opacity: 0.85;
    border-color: #dee2e6;
}
.forum-lang-btn.active {
    opacity: 1;
    border-color: #3498db;
    background: #f0f7ff;
}

/* Barra traduzione post */
.forum-post-translate {
    padding: 6px 16px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}
.translate-lang-badge {
    background: #e8eef4;
    color: #5a6c7d;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.btn-translate {
    background: none;
    border: 1px solid #3498db;
    color: #3498db;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-translate:hover {
    background: #3498db;
    color: #fff;
}
.btn-translate.active {
    background: #3498db;
    color: #fff;
}
.translate-pending {
    color: #999;
    font-style: italic;
}
.forum-post-translated {
    display: none;
}

/* Info admin (email + IP) */
.admin-info {
    display: block;
    font-size: 11px;
    color: #e67e22;
    font-family: monospace;
    margin-top: 2px;
    opacity: 0.85;
}
.admin-ip {
    color: #999;
}

/* Dropdown menzioni @utente */
.forum-mention-dropdown {
    position: absolute;
    z-index: 9999;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    max-height: 200px;
    overflow-y: auto;
    min-width: 180px;
}
.mention-item {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.15s;
}
.mention-item:hover,
.mention-item.active {
    background: #f0f7ff;
    color: #3498db;
}
.mention-item:first-child {
    border-radius: 6px 6px 0 0;
}
.mention-item:last-child {
    border-radius: 0 0 6px 6px;
}

/* Immagini nei post */
.forum-post-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 8px 0;
    cursor: pointer;
    transition: opacity 0.2s;
}
.forum-post-body img:hover {
    opacity: 0.9;
}

/* Popup dimensione immagine (admin) */
.forum-img-size-popup {
    position: absolute;
    z-index: 9999;
    display: flex;
    gap: 4px;
    background: #1a2332;
    padding: 6px 8px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.forum-img-size-popup button {
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.forum-img-size-popup button:hover {
    background: rgba(255,255,255,0.15);
}
.forum-img-size-popup button.active {
    background: #3498db;
    border-color: #3498db;
}
.forum-img-size-popup::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #1a2332;
}

/* Pulsante elimina nel popup dimensione */
.forum-img-size-popup .img-delete-btn {
    background: #e74c3c !important;
    border-color: #e74c3c !important;
    font-size: 16px;
    line-height: 1;
    padding: 4px 10px;
    margin-left: 4px;
}
.forum-img-size-popup .img-delete-btn:hover {
    background: #c0392b !important;
}

/* Lightbox per immagini nei post */
.forum-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    align-items: center;
    justify-content: center;
}
.forum-lightbox.active {
    display: flex;
}
.forum-lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    cursor: zoom-out;
}
.forum-lightbox-content {
    position: relative;
    z-index: 1;
    max-width: 92vw;
    max-height: 92vh;
}
.forum-lightbox-content img {
    max-width: 92vw;
    max-height: 90vh;
    display: block;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}
.forum-lightbox-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    border: none;
    font-size: 20px;
    line-height: 32px;
    text-align: center;
    cursor: pointer;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s;
}
.forum-lightbox-close:hover {
    transform: scale(1.1);
}

/* Immagini nei post - cursore zoom */
.forum-post-body img {
    cursor: zoom-in;
}

/* Pulsante Source HTML */
.ql-source-btn {
    float: right !important;
    font-family: monospace;
    font-size: 13px !important;
    font-weight: 700;
    color: #666 !important;
    padding: 2px 8px !important;
    margin-left: 8px !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 22px;
}
.ql-source-btn:hover {
    background: #f0f0f0 !important;
    color: #333 !important;
}
.ql-source-btn.active {
    background: #1a2332 !important;
    color: #7fdbca !important;
    border-color: #1a2332 !important;
}

/* Textarea source editor */
.forum-source-editor {
    width: 100%;
    min-height: 250px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 0 0 6px 6px;
    background: #1a2332;
    color: #d6deeb;
    resize: vertical;
    tab-size: 2;
    box-sizing: border-box;
}
.forum-source-editor:focus {
    outline: none;
    border-color: #3498db;
}

/* Immagini nell'editor Quill */
.ql-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    cursor: pointer;
}
