/* Forum Styles */
.forum-breadcrumb {
    padding: 1rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.forum-breadcrumb a {
    color: var(--muted);
    text-decoration: none;
}

.forum-breadcrumb a:hover {
    text-decoration: underline;
}

.forum-breadcrumb span {
    color: var(--text);
    font-weight: bold;
}

/* Forum View Section */
.forum-view-section {
    padding: 2rem 0;
}

.forum-header {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.forum-header h1 {
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.forum-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.forum-stats {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.forum-stats span {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.forum-stats strong {
    color: var(--muted);
    font-size: 1.2rem;
}

/* Topics Table */
.topics-table {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.table-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.5fr;
    background: #1a1a1a;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    font-weight: bold;
    color: var(--muted);
}

.col-topic { grid-column: 1; }
.col-replies { grid-column: 2; text-align: center; }
.col-views { grid-column: 3; text-align: center; }
.col-lastpost { grid-column: 4; text-align: right; }

.topic-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.5fr;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.3s ease;
    align-items: center;
}

.topic-row:hover {
    background: #1a1a1a;
}

.topic-row:last-child {
    border-bottom: none;
}

.topic-row.sticky {
    background: rgba(255, 212, 59, 0.1);
    border-left: 4px solid #ffd43b;
}

.topic-row.announcement {
    background: rgba(81, 207, 102, 0.12);
    border-left: 4px solid #51cf66;
}

.topic-row.announcement:hover {
    background: rgba(81, 207, 102, 0.2);
}

.topic-row.locked {
    opacity: 0.8;
}

.topic-row.locked .topic-details h3 a {
    color: var(--text-secondary);
}

/* Topic Column */
.col-topic {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topic-status {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.sticky-icon {
    color: #ffd43b;
    font-size: 1.2rem;
}

.forum-icon .locked-icon {
    color: #ff6b6b;
    font-size: 1.2rem;
}

.topic-status .locked-icon {
    position: static;
    margin-left: 4px;
}

.normal-icon {
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.announcement-icon {
    color: #51cf66;
    font-size: 1.2rem;
}

.topic-details h3 {
    margin: 0 0 0.5rem 0;
}

.topic-details h3 a {
    color: var(--muted);
    text-decoration: none;
    font-size: 1.1rem;
}

.topic-details h3 a:hover {
    color: #ffffff;
    text-decoration: underline;
}

.topic-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.topic-meta a {
    color: var(--muted);
    text-decoration: none;
}

.topic-meta a:hover {
    text-decoration: underline;
}

/* Replies and Views Columns */
.col-replies, .col-views {
    text-align: center;
}

.count {
    display: inline-block;
    background: rgba(155, 231, 255, 0.1);
    color: var(--muted);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: bold;
    min-width: 50px;
}

/* Last Post Column */
.col-lastpost {
    text-align: right;
}

.last-post-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.last-post-info .date {
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
}

.last-post-info .author {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.last-post-info .author a {
    color: var(--muted);
    text-decoration: none;
}

.last-post-info .author a:hover {
    text-decoration: underline;
}

.no-posts {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9rem;
}

/* No Topics */
.no-topics {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.no-topics p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.page-numbers {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    flex: 1;
}

.page-link {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
    min-width: 40px;
    text-align: center;
}

.page-link:hover {
    background: var(--muted);
    color: #000;
    border-color: var(--muted);
}

.page-link.current {
    background: var(--muted);
    color: #000;
    border-color: var(--muted);
    font-weight: bold;
}

.page-link.prev,
.page-link.next {
    background: transparent;
    border: none;
    color: var(--muted);
    font-weight: bold;
}

.page-link.prev:hover,
.page-link.next:hover {
    color: #ffffff;
    text-decoration: underline;
}

/* Forum Actions */
.forum-actions {
    text-align: center;
    padding: 2rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.forum-actions p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.forum-actions a {
    color: var(--muted);
    text-decoration: none;
}

.forum-actions a:hover {
    text-decoration: underline;
}

/* Forum Index */
.forum-index-section {
    padding: 2rem 0;
}

.forum-index-section h1 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--muted);
}

.forum-index-section .forum-description {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 2rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.6;
}

/* Forum Stats Overview */
.forum-stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-item {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
}

.stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    display: block;
    color: var(--muted);
    font-size: 1.5rem;
    font-weight: bold;
}

/* Forum Search */
.forum-search {
    margin-bottom: 2rem;
}

.forum-search-form {
    max-width: 600px;
    margin: 0 auto;
}

.search-input-group {
    display: flex;
    gap: 0.5rem;
}

.search-input-group input[type="search"] {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
}

.search-input-group input[type="search"]:focus {
    outline: none;
    border-color: var(--muted);
}

/* Forum Section Card (stile identico a index.php) */
.forum-section-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.section-header {
    background: #1a1a1a;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.section-header h2 {
    color: var(--muted);
    margin: 0 0 0.5rem 0;
    font-size: 1.3rem;
}

.section-description {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.95rem;
}

/* Forums List (stile identico a index.php) */
.forums-list {
    padding: 0;
}

.forum-item {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.3s ease;
    gap: 1rem;
}

.forum-item:hover {
    background: #1a1a1a;
}

.forum-item:last-child {
    border-bottom: none;
}

.forum-icon {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(155, 231, 255, 0.1);
    border-radius: 50%;
    position: relative;
}

.forum-icon .icon {
    font-size: 1.8rem;
}

.locked-icon {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: #333;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.forum-details {
    flex: 1;
    min-width: 0; /* Per gestire l'overflow */
}

.forum-details h3 {
    margin: 0 0 0.5rem 0;
}

.forum-details h3 a {
    color: var(--muted);
    text-decoration: none;
    font-size: 1.2rem;
    transition: color 0.3s ease;
}

.forum-details h3 a:hover {
    color: #ffffff;
    text-decoration: underline;
}

.forum-description {
    color: var(--text-secondary);
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
}

.forum-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.meta-item .icon {
    font-size: 0.9rem;
}

/* Forum Last Post (stile identico a index.php) */
.forum-last-post {
    flex-shrink: 0;
    width: 250px;
    text-align: right;
}

.last-post-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.last-post-title {
    margin-bottom: 0.25rem;
}

.last-post-title a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.last-post-title a:hover {
    color: var(--muted);
    text-decoration: underline;
}

.last-post-date {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.last-post-user {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.last-post-user a {
    color: var(--muted);
    text-decoration: none;
}

.last-post-user a:hover {
    text-decoration: underline;
}

.no-posts {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9rem;
}

/* No Content States */
.no-forums, .no-sections {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.no-sections {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Online Users */
.online-users {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    margin-top: 2rem;
}

.online-users h3 {
    color: var(--muted);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.users-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.user-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.5rem 1rem;
    color: var(--muted);
    text-decoration: none;
    transition: all 0.3s ease;
}

.user-link:hover {
    background: var(--muted);
    color: #000;
    border-color: var(--muted);
}

.role-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-weight: bold;
}

.role-badge.admin {
    background: #ff6b6b;
    color: #000;
}

.role-badge.uploader {
    background: #51cf66;
    color: #000;
}

.no-users {
    color: var(--text-secondary);
    font-style: italic;
}

/* Alert Styling */
.forum-alert {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 300px;
    max-width: 500px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: slideInRight 0.3s ease;
}

.forum-alert.alert-success {
    background: var(--success);
    color: #000;
    border: 1px solid rgba(0,0,0,0.2);
}

.forum-alert.alert-error {
    background: var(--error);
    color: #000;
    border: 1px solid rgba(0,0,0,0.2);
}

.forum-alert.alert-warning {
    background: var(--warning);
    color: #000;
    border: 1px solid rgba(0,0,0,0.2);
}

.forum-alert.alert-info {
    background: var(--info);
    color: #000;
    border: 1px solid rgba(0,0,0,0.2);
}

.forum-alert .alert-message {
    flex: 1;
    margin-right: 1rem;
}

.forum-alert .alert-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    transition: opacity 0.3s;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.forum-alert .alert-close:hover {
    opacity: 1;
}

/* Loading States */
.loading {
    position: relative;
    opacity: 0.7;
    min-height: 200px;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid var(--muted);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Search Results */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.search-result-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.3s;
}

.search-result-item:hover {
    background: #1a1a1a;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    font-weight: bold;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.search-result-snippet {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0.25rem 0;
}

.search-result-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Subscription Buttons */
.subscribe-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.subscribe-btn:hover {
    border-color: var(--muted);
    color: var(--muted);
}

.subscribe-btn[data-subscribed="1"] {
    background: rgba(255, 212, 59, 0.2);
    color: #ffd43b;
    border-color: #ffd43b;
}

.subscribe-btn[data-subscribed="1"]:hover {
    background: rgba(255, 212, 59, 0.3);
}

/* Topic Read State */
.topic-row.read {
    opacity: 0.7;
}

.topic-row.read .topic-details h3 a {
    font-weight: normal;
}

.topic-row.read .topic-details h3 a:visited {
    color: var(--text-secondary);
}

/* Quick Reply */
.quick-reply {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.quick-reply textarea {
    min-height: 150px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* BBCode Toolbar */
.bbcode-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.bbcode-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.bbcode-btn:hover {
    background: var(--muted);
    color: #000;
    border-color: var(--muted);
}

/* Topic View Styles - per viewtopic() */
.topic-view-section {
    padding: 2rem 0;
}

.topic-header {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.topic-header h1 {
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.topic-stats {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.topic-stats span {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.topic-stats strong {
    color: var(--muted);
    font-size: 1.2rem;
}

.posts-list {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.post-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    border-bottom: 1px solid var(--border);
    transition: background 0.3s ease;
}

.post-row:hover {
    background: #1a1a1a;
}

.post-row:last-child {
    border-bottom: none;
}

.post-author {
    padding: 1.5rem;
    border-right: 1px solid var(--border);
    background: rgba(0,0,0,0.2);
}

.author-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 1rem;
    background: rgba(155, 231, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--muted);
}

.author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.author-info {
    text-align: center;
}

.author-name {
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.author-name a {
    color: inherit;
    text-decoration: none;
}

.author-name a:hover {
    text-decoration: underline;
}

.author-role {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.author-role.admin {
    background: #ff6b6b;
    color: #000;
}

.author-role.uploader {
    background: #51cf66;
    color: #000;
}

.author-role.member {
    background: #339af0;
    color: #000;
}

.author-stats {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.post-content {
    padding: 1.5rem;
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.post-number {
    color: var(--muted);
    font-weight: bold;
}

.post-date {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.post-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-edit, .btn-delete {
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    text-decoration: none;
    border-radius: 4px;
}

.btn-edit {
    background: rgba(139, 195, 74, 0.1);
    color: #8bc34a;
    border: 1px solid #8bc34a;
}

.btn-delete {
    background: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
    border: 1px solid #ff6b6b;
}

.post-body {
    line-height: 1.6;
    margin-bottom: 1rem;
}

.post-signature {
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

.topic-actions {
    text-align: center;
    padding: 2rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.topic-actions p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* New Topic/Post Form Styles */
.new-topic-section, .new-post-section {
    padding: 2rem 0;
}

.topic-form, .post-form {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    margin-top: 2rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Stili per la modifica dei post */
.edit-textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    resize: vertical;
}

.edit-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.edit-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-left: 0.5rem;
}

/* Paginazione specifica per i post */
.post-pagination {
    margin-top: 2rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

/* Stili per i post bloccati */
.post-row.locked .post-body {
    opacity: 0.7;
    filter: grayscale(0.5);
    position: relative;
}

.post-row.locked .post-body::before {
    content: '🔒 Post bloccato';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    z-index: 1;
}

.post-row.locked .post-actions {
    display: none;
}

/* Badge per i nuovi messaggi */
.new-post-badge {
    background: var(--muted);
    color: #000;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: bold;
    margin-left: 0.5rem;
}

/* Animazioni per i nuovi post */
@keyframes highlightNew {
    0% { background-color: rgba(155, 231, 255, 0.3); }
    100% { background-color: transparent; }
}

.post-row.new-post {
    animation: highlightNew 2s ease;
}

/* Quick reply migliorato */
.quick-reply .bbcode-toolbar {
    background: var(--bg);
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}

.quick-reply textarea {
    border-radius: 0 0 4px 4px;
    min-height: 150px;
}

/* Topic Status Indicators */
.topic-status-indicators {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.sticky-badge {
    background: rgba(255, 212, 59, 0.2);
    color: #ffd43b;
    border: 1px solid #ffd43b;
}

.announcement-badge {
    background: rgba(81, 207, 102, 0.2);
    color: #51cf66;
    border: 1px solid #51cf66;
}

.locked-badge {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
    border: 1px solid #ff6b6b;
}

/* Topic Locked Message */
.topic-locked-message {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid #ff6b6b;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    text-align: center;
    margin: 2rem 0;
    color: #ff6b6b;
}

.topic-locked-message i {
    margin-right: 0.5rem;
}

/* Latest Topics (solo per index.php) */
.latest-topics {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    margin-top: 2rem;
}

.latest-topics h3 {
    color: var(--muted);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.topics-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.topic-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: all 0.3s ease;
    gap: 1rem;
}

.topic-item:hover {
    border-color: var(--muted);
    transform: translateY(-2px);
}

.topic-status {
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}

.sticky-icon, .locked-icon, .normal-icon {
    font-size: 1.2rem;
}

.sticky-icon {
    color: #ffd43b;
}

.locked-icon {
    color: #ff6b6b;
}

.normal-icon {
    color: var(--text-secondary);
}

.topic-details {
    flex: 1;
    min-width: 0;
}

.topic-details h4 {
    margin: 0 0 0.5rem 0;
}

.topic-details h4 a {
    color: var(--text);
    text-decoration: none;
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

.topic-details h4 a:hover {
    color: var(--muted);
    text-decoration: underline;
}

.topic-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.topic-last-post {
    flex-shrink: 0;
    width: 60px;
    text-align: right;
}

.last-post-date {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.view-all-topics {
    text-align: center;
    margin-top: 1.5rem;
}

/* BBCode Preview */
.bbcode-preview {
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1rem;
    margin-top: 1rem;
    line-height: 1.6;
}

.bbcode-preview h1, .bbcode-preview h2, .bbcode-preview h3, .bbcode-preview h4 {
    color: var(--muted);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.bbcode-preview p {
    margin-bottom: 0.5rem;
}

.bbcode-preview ul, .bbcode-preview ol {
    padding-left: 2rem;
    margin-bottom: 0.5rem;
}

.bbcode-preview code {
    background: rgba(155, 231, 255, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: monospace;
}

.bbcode-preview blockquote {
    border-left: 3px solid var(--muted);
    padding-left: 1rem;
    margin-left: 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* BBCode Dropdown Styles */
.bbcode-dropdown {
    position: relative;
    display: inline-block;
}

.bbcode-dropdown .dropdown-menu {
    display: none !important;
    position: absolute;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    z-index: 1000;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    margin-top: 0.25rem;
    left: 0;
    top: 100%;
}

.bbcode-dropdown .dropdown-menu.show {
    display: block !important;
    animation: fadeIn 0.2s ease;
}

.color-palette, .emoji-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.color-row, .emoji-row {
    display: flex;
    justify-content: space-between;
    gap: 0.25rem;
}

.color-btn {
    width: 30px;
    height: 30px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.color-btn:hover {
    border-color: var(--text);
    transform: scale(1.1);
}

.emoji-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0.25rem;
    transition: all 0.2s;
}

.emoji-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border);
    transform: scale(1.1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stili BBCode avanzati */
.bbcode-quote {
    background: var(--bg-secondary);
    border-left: 4px solid var(--border);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.bbcode-quote .quote-header {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.bbcode-quote .quote-content {
    font-style: italic;
}

.bbcode-code {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 4px;
    margin: 1rem 0;
    overflow: hidden;
}

.bbcode-code .code-header {
    background: #2d2d2d;
    color: #ccc;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid #333;
    font-family: monospace;
}

.bbcode-code pre {
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
}

.bbcode-code code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    color: #d4d4d4;
    background: transparent;
}

.bbcode-list {
    margin: 1rem 0 1rem 1.5rem;
    padding: 0;
}

.bbcode-list li {
    margin-bottom: 0.25rem;
}

.bbcode-spoiler {
    margin: 1rem 0;
}

.bbcode-spoiler .spoiler-toggle {
    background: var(--btn-bg);
    color: var(--btn-text);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    transition: all 0.3s;
}

.bbcode-spoiler .spoiler-toggle:hover {
    background: var(--btn-hover);
}

.bbcode-spoiler .spoiler-content {
    display: none;
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 4px;
    border: 1px dashed var(--border);
}

.bbcode-image {
    margin: 1rem 0;
    text-align: center;
}

.bbcode-image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    cursor: zoom-in;
    transition: transform 0.3s;
}

.bbcode-image img:hover {
    transform: scale(1.02);
}

.bbcode-link {
    color: var(--link-color);
    text-decoration: underline;
}

.bbcode-link:hover {
    color: var(--link-hover);
}

.bbcode-email {
    color: var(--link-color);
    text-decoration: none;
}

.bbcode-email:hover {
    text-decoration: underline;
}

.bbcode-hr {
    margin: 1.5rem 0;
    border: none;
    height: 1px;
    background: var(--border);
}

/* Stili per la sintassi del codice */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #6a9955;
}

.token.punctuation {
    color: #d4d4d4;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
    color: #b5cea8;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: #ce9178;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
    color: #d4d4d4;
}

.token.atrule,
.token.attr-value,
.token.keyword {
    color: #569cd6;
}

.token.function,
.token.class-name {
    color: #dcdcaa;
}

.token.regex,
.token.important,
.token.variable {
    color: #d16969;
}

/* Custom Tooltip */
.custom-tooltip {
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

/* Preview Modal */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.preview-modal.fade-out {
    animation: fadeOut 0.3s ease;
}

.preview-content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: auto;
    padding: 2rem;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.preview-header h3 {
    color: var(--muted);
    margin: 0;
}

.close-preview {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
}

.close-preview:hover {
    opacity: 0.8;
}

.preview-body {
    line-height: 1.6;
}

.preview-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: right;
}

/* Image Lightbox Modal */
.image-lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.lightbox-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

/* Form Groups */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text);
    font-weight: bold;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--muted);
}

.form-text {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Alert Styles */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.alert-error {
    background: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
    border: 1px solid #ff6b6b;
}

.alert-success {
    background: rgba(81, 207, 102, 0.1);
    color: #51cf66;
    border: 1px solid #51cf66;
}

.alert-warning {
    background: rgba(255, 212, 59, 0.1);
    color: #ffd43b;
    border: 1px solid #ffd43b;
}

.alert-info {
    background: rgba(51, 154, 240, 0.1);
    color: #339af0;
    border: 1px solid #339af0;
}

/* Button Styles */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    cursor: pointer;
    border: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--muted);
    color: #000;
}

.btn-primary:hover {
    background: #ffffff;
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--muted);
}

.btn-secondary:hover {
    background: var(--muted);
    color: #000;
}

.btn-info {
    background: transparent;
    color: #339af0;
    border: 1px solid #339af0;
}

.btn-info:hover {
    background: #339af0;
    color: #000;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .forum-alert {
        left: 10px;
        right: 10px;
        min-width: auto;
        max-width: none;
    }
    
    .preview-content {
        width: 95% !important;
        padding: 1rem !important;
    }
    
    .edit-controls {
        flex-direction: column;
    }
    
    .edit-controls button {
        width: 100%;
    }
    
    .dropdown-menu {
        position: fixed !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%);
        width: 90%;
        max-width: 300px;
    }
    
    .bbcode-toolbar {
        justify-content: center;
    }
    
    .forum-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem;
    }
    
    .forum-icon {
        align-self: flex-start;
        width: 50px;
        height: 50px;
    }
    
    .forum-details {
        width: 100%;
    }
    
    .forum-last-post {
        width: 100%;
        text-align: left;
    }
    
    .topic-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .topic-status {
        align-self: flex-start;
    }
    
    .topic-details {
        width: 100%;
    }
    
    .topic-last-post {
        width: 100%;
        text-align: left;
    }
    
    .forum-stats {
        gap: 1rem;
    }
    
    .stat-item {
        flex: 1;
        min-width: 100px;
    }
    
    .table-header {
        display: none;
    }
    
    .topic-row {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }
    
    .col-topic {
        grid-column: 1;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .col-replies,
    .col-views,
    .col-lastpost {
        grid-column: 1;
        text-align: left;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 0;
        border-top: 1px solid #333;
    }
    
    .col-replies::before {
        content: "Risposte:";
        color: var(--text-secondary);
    }
    
    .col-views::before {
        content: "Visite:";
        color: var(--text-secondary);
    }
    
    .col-lastpost::before {
        content: "Ultimo post:";
        color: var(--text-secondary);
    }
    
    .pagination {
        flex-direction: column;
        gap: 1rem;
    }
    
    .forum-stats-overview {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .forum-stats {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .post-row {
        grid-template-columns: 1fr;
    }
    
    .post-author {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    .post-row {
        grid-template-columns: 1fr;
    }
    
    .post-author {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding-bottom: 1rem;
    }
    
    .post-content {
        padding: 1rem;
    }
    
    .post-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .post-actions {
        width: 100%;
        justify-content: flex-start;
        margin-top: 0.5rem;
    }
}

@media (max-width: 480px) {
    .forum-stats-overview {
        grid-template-columns: 1fr;
    }
    
    .page-numbers {
        gap: 0.25rem;
    }
    
    .page-link {
        padding: 0.5rem;
        min-width: 35px;
    }
    
    .forum-meta, .topic-meta {
        gap: 0.5rem;
    }
    
    .meta-item {
        font-size: 0.8rem;
    }
    
    .status-badge {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }
    
    .topic-status-indicators {
        justify-content: center;
    }
    
    .color-btn {
        width: 25px;
        height: 25px;
    }
    
    .emoji-btn {
        font-size: 1.2rem;
    }
}

/* Fade out animation for alerts */
.forum-alert.fade-out {
    animation: slideOutRight 0.3s ease;
}

/* Azioni admin per i topic */
.topic-admin-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.btn-admin-sticky,
.btn-admin-lock,
.btn-admin-announcement {
    background: rgba(155, 231, 255, 0.1);
    border: 1px solid rgba(155, 231, 255, 0.3);
    color: var(--muted);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.btn-admin-sticky:hover,
.btn-admin-lock:hover,
.btn-admin-announcement:hover {
    background: rgba(155, 231, 255, 0.2);
    border-color: var(--muted);
}

.btn-admin-sticky:active,
.btn-admin-lock:active,
.btn-admin-announcement:active {
    transform: scale(0.95);
}

.btn-admin-sticky.btn-small,
.btn-admin-lock.btn-small,
.btn-admin-announcement.btn-small {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
}

/* Admin options nel form nuovo topic */
.admin-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(155, 231, 255, 0.05);
    border: 1px solid rgba(155, 231, 255, 0.1);
    border-radius: 4px;
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text);
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
}

.checkbox-label span {
    font-size: 0.9rem;
}

/* Responsive per bottoni admin */
@media (max-width: 768px) {
    .topic-admin-actions {
        justify-content: flex-start;
    }
    
    .btn-admin-sticky,
    .btn-admin-lock,
    .btn-admin-announcement {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .topic-admin-actions {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .btn-admin-sticky,
    .btn-admin-lock,
    .btn-admin-announcement {
        width: 100%;
        text-align: left;
    }
}

/* CORREZIONE ALLINEAMENTO ICONE TOPIC */
.topic-status {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-right: 1rem;
    font-size: 1.2rem;
}

/* STILI PER ANNUNCI GLOBALI */
.topic-row.global-announcement {
    background-color: rgba(33, 150, 243, 0.1);
    border-left: 3px solid #2196f3;
}

.global-announcement-badge {
    background: rgba(33, 150, 243, 0.2);
    color: #2196f3;
    border: 1px solid rgba(33, 150, 243, 0.3);
}

.global-badge {
    display: inline-block;
    background: rgba(33, 150, 243, 0.2);
    color: #2196f3;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* OPCIONES ADMIN PARA ANUNCIOS GLOBALES */
.admin-options .checkbox-label span {
    font-size: 0.9rem;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .forum-item {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .forum-last-post {
        flex: 0 0 auto;
        width: 100%;
        text-align: center;
    }
}