/**
 * Forum Single Topic Styles
 * Topic header, content, action buttons, and layout
 */

/* ============================================
   SINGLE TOPIC LAYOUT
   ============================================ */

.forum-topic {
    padding: clamp(1.5rem, 3vw, 2rem) 0 clamp(3rem, 6vw, 5rem);
    background: var(--bg-primary);
    min-height: calc(100vh - 64px);
}

/* Topic Article Container */
.forum-topic .topic {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: clamp(1.5rem, 3vw, 2rem);
    overflow: hidden;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.05),
        0 4px 12px rgba(0, 0, 0, 0.03);
    position: relative;
}

/* Accent top border for topic article */
.forum-topic .topic::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-accent);
}

html.dark .forum-topic .topic {
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.2),
        0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Topic Header within Article */
.forum-topic .topic .topic-header {
    padding: clamp(1rem, 2vw, 1.25rem) clamp(1.25rem, 2.5vw, 2rem);
    padding-top: calc(clamp(1rem, 2vw, 1.25rem) + 3px); /* Account for accent border */
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 0;
    border: none;
    box-shadow: none;
    margin-bottom: 0;
}

/* Remove duplicate accent from nested header */
.forum-topic .topic .topic-header::before {
    display: none;
}

/* Topic title within article */
.forum-topic .topic .topic-header h1 {
    margin: 0;
    font-size: clamp(1.375rem, 2.5vw + 0.5rem, 1.875rem);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

/* ============================================
   TOPIC HEADER BOX
   Enhanced card with depth effect
   ============================================ */

.topic-header {
    padding: clamp(1.25rem, 2.5vw, 2rem);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: clamp(1.5rem, 3vw, 2rem);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 4px 8px rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
}

/* Accent top border for visual appeal */
.topic-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-accent);
}

html.dark .topic-header {
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.15),
        0 4px 8px rgba(0, 0, 0, 0.1);
}

/* ============================================
   TOPIC TITLE
   ============================================ */

.topic-header h1 {
    margin: 0 0 clamp(0.75rem, 1.5vw, 1rem) 0;
    font-size: clamp(1.25rem, 2.5vw + 0.25rem, 1.75rem);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

/* ============================================
   TOPIC META
   ============================================ */

.topic-header-meta {
    display: flex;
    align-items: center;
    gap: clamp(0.75rem, 1.5vw, 1rem);
    flex-wrap: wrap;
    margin-bottom: clamp(0.75rem, 1.5vw, 1rem);
    font-size: clamp(0.8125rem, 1.25vw + 0.15rem, 0.875rem);
    color: var(--text-secondary);
}

.topic-header-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.topic-header-meta svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

.topic-header-meta a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

.topic-header-meta a:hover {
    color: var(--accent-hover);
}

/* Topic Meta in Topic Header (used in single-forum_topic.php) */
.topic-meta {
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 1vw, 0.75rem);
    flex-wrap: wrap;
    font-size: clamp(0.8125rem, 1.25vw + 0.1rem, 0.875rem);
    color: var(--text-secondary);
}

.topic-meta-avatar {
    width: clamp(28px, 4vw, 36px);
    height: clamp(28px, 4vw, 36px);
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    flex-shrink: 0;
}

.topic-meta-separator {
    color: var(--text-muted);
}

.topic-meta-views,
.topic-meta-replies {
    color: var(--text-secondary);
}

/* ============================================
   TOPIC CONTENT
   ============================================ */

.topic-content {
    padding: 0 clamp(1.25rem, 2.5vw, 2rem) clamp(0.75rem, 1.5vw, 1rem);
    margin-top: -1.25rem;
    line-height: 1.6;
    color: var(--text-primary);
    font-size: clamp(0.9375rem, 1.25vw + 0.25rem, 1.0625rem);
    background: var(--bg-secondary);
}

/* Topic content within article (single topic page) */
.forum-topic .topic .topic-content {
    border-bottom: 1px solid var(--border);
}

/* Ensure proper spacing for plain text content without p tags */
.topic-content:not(:has(p)) {
    white-space: pre-line;
}

.topic-content p {
    margin: 0 0 clamp(0.875rem, 1.5vw, 1rem) 0;
}

.topic-content p:last-child {
    margin-bottom: 0;
}

.topic-content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.topic-content a:hover {
    border-bottom-color: var(--accent);
}

/* Code blocks in topic content */
.topic-content code {
    padding: 0.125rem 0.375rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
}

.topic-content pre {
    padding: clamp(0.75rem, 1.5vw, 1rem);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: clamp(0.875rem, 1.5vw, 1rem) 0;
}

.topic-content pre code {
    padding: 0;
    background: none;
}

/* Lists in topic content */
.topic-content ul,
.topic-content ol {
    margin: 0 0 clamp(0.875rem, 1.5vw, 1rem) 0;
    padding-left: 1.5rem;
}

.topic-content li {
    margin-bottom: 0.375rem;
}

/* ============================================
   TOPIC ACTION BUTTONS
   Consistent height and alignment
   ============================================ */

.topic-actions {
    margin-top: 0;
    padding: clamp(1rem, 2vw, 1.25rem) clamp(1.25rem, 2.5vw, 2rem);
    border-top: none;
    background: var(--bg-tertiary);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: clamp(0.5rem, 1vw, 0.75rem);
}

/* Topic actions within article (single topic page) */
.forum-topic .topic .topic-actions {
    background: var(--bg-tertiary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.topic-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 40px;
    padding: 0 clamp(0.875rem, 1.5vw, 1rem);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: clamp(0.8125rem, 1.25vw + 0.1rem, 0.875rem);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.topic-action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.topic-action-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.topic-action-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Danger variant (delete) */
.topic-action-btn--danger {
    color: var(--error);
    border-color: rgba(var(--error-rgb), 0.3);
}

.topic-action-btn--danger:hover {
    background: var(--error-bg);
    border-color: var(--error);
    color: var(--error);
}

/* Primary variant (edit) */
.topic-action-btn--primary {
    color: var(--accent);
    border-color: rgba(var(--accent-rgb), 0.3);
}

.topic-action-btn--primary:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* Success variant (mark solved) */
.topic-action-btn--success {
    color: var(--success);
    border-color: rgba(var(--success-rgb), 0.3);
}

.topic-action-btn--success:hover {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
}

/* Follow button in topic actions */
.topic-actions .topic-follow-btn {
    height: 40px;
    padding: 0 clamp(0.875rem, 1.5vw, 1rem);
}

/* Light mode shadow adjustments */
html.light .topic-header {
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.05),
        0 4px 8px rgba(0, 0, 0, 0.05);
}

html.light .topic-action-btn {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* ============================================
   TOPIC BADGES IN HEADER
   ============================================ */

.topic-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: clamp(0.75rem, 1.5vw, 1rem);
}

.topic-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: clamp(0.75rem, 1.1vw + 0.1rem, 0.8125rem);
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.topic-badge--pinned {
    background: var(--accent-light);
    color: var(--accent);
}

.topic-badge--solved {
    background: var(--success-bg);
    color: var(--success);
}

.topic-badge--locked {
    background: var(--warning-bg);
    color: var(--warning);
}

.topic-badge svg {
    width: 14px;
    height: 14px;
}

/* ============================================
   TOPIC AUTHOR INFO (Optional enhanced display)
   ============================================ */

.topic-author {
    display: flex;
    align-items: center;
    gap: clamp(0.75rem, 1.5vw, 1rem);
    margin-bottom: clamp(1rem, 2vw, 1.25rem);
    padding-bottom: clamp(1rem, 2vw, 1.25rem);
    border-bottom: 1px solid var(--border);
}

.topic-author-avatar {
    width: clamp(44px, 6vw, 56px);
    height: clamp(44px, 6vw, 56px);
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    flex-shrink: 0;
}

.topic-author-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.topic-author-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: clamp(0.9375rem, 1.5vw + 0.15rem, 1rem);
}

.topic-author-name a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.topic-author-name a:hover {
    color: var(--accent);
}

.topic-author-date {
    font-size: clamp(0.8125rem, 1.25vw + 0.1rem, 0.875rem);
    color: var(--text-muted);
}

/* ============================================
   TOPIC STATS ROW (Optional)
   ============================================ */

.topic-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(1rem, 2vw, 1.5rem);
    padding: clamp(1rem, 2vw, 1.25rem);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-top: clamp(1rem, 2vw, 1.25rem);
}

.topic-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-width: 60px;
}

.topic-stat-value {
    font-size: clamp(1.125rem, 2vw + 0.25rem, 1.5rem);
    font-weight: 700;
    color: var(--text-primary);
}

.topic-stat-label {
    font-size: clamp(0.6875rem, 1vw + 0.1rem, 0.75rem);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================
   TOPIC EDIT FORM
   ============================================ */

.topic-edit-form {
    margin-top: clamp(1rem, 2vw, 1.25rem);
}

.topic-edit-form .form-group {
    margin-bottom: clamp(0.875rem, 1.5vw, 1rem);
}

.topic-edit-form .form-group:last-of-type {
    margin-bottom: 0;
}

.topic-edit-form .form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: clamp(0.875rem, 1.25vw + 0.15rem, 0.9375rem);
}

.topic-edit-form .form-input,
.topic-edit-form .form-textarea {
    width: 100%;
    padding: clamp(0.625rem, 1.25vw, 0.75rem) clamp(0.75rem, 1.5vw, 1rem);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: clamp(0.9375rem, 1.25vw + 0.2rem, 1rem);
    font-family: inherit;
    transition: all 0.2s ease;
}

.topic-edit-form .form-input:focus,
.topic-edit-form .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.topic-edit-form .form-input:disabled,
.topic-edit-form .form-textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.topic-edit-form .form-textarea {
    min-height: clamp(120px, 20vw, 180px);
    resize: vertical;
    line-height: 1.6;
}

.topic-edit-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: clamp(0.5rem, 1vw, 0.75rem);
    margin-top: clamp(0.875rem, 1.5vw, 1rem);
    padding-top: clamp(0.875rem, 1.5vw, 1rem);
    border-top: 1px solid var(--border);
}

/* ============================================
   TOPIC FOLLOW BUTTON
   ============================================ */

.topic-follow-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: clamp(0.8125rem, 1.25vw + 0.1rem, 0.875rem);
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 32px;
}

.topic-follow-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.topic-follow-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.topic-follow-btn--following {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-light);
}

.topic-follow-btn--following:hover {
    background: rgba(var(--accent-rgb), 0.15);
    color: var(--accent-hover);
    border-color: var(--accent-hover);
}

.topic-follow-btn svg {
    width: 16px;
    height: 16px;
}
