/* Forum-specific styles. Inherits the design tokens from /style.css. */

/* ============================================================
   Reset / base tweaks scoped to forum pages
   ============================================================ */

body {
    /* Slight bg so cards pop on light glass surfaces */
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(99, 102, 241, 0.06), transparent 60%),
        radial-gradient(900px 500px at -10% 10%, rgba(14, 165, 233, 0.05), transparent 60%),
        #ffffff;
    min-height: 100vh;
}

/* ============================================================
   Header
   ============================================================ */
.forum-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
}

.forum-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    gap: 0.75rem;
}

.forum-brand-group {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 1;
    min-width: 0;
}

.forum-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.forum-back:hover {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.04);
}

.forum-back i { width: 1rem; height: 1rem; }

.brand-separator {
    color: var(--text-muted);
    opacity: 0.4;
    font-weight: 300;
    flex-shrink: 0;
}

.forum-brand {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 800;
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.forum-brand i {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--primary);
}

/* Sheet back link gets a distinct color so it reads as "leave the forum" */
.mobile-sheet .sheet-back-link {
    color: var(--text-muted);
    font-weight: 500;
}

/* Desktop nav: shown on tablet+ */
.forum-nav {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}

.forum-nav a.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.35rem 0.25rem;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.forum-nav a.nav-link:hover,
.forum-nav a.nav-link.active {
    color: var(--text-main);
    border-bottom-color: var(--primary);
}

.forum-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hamburger toggle — hidden on desktop */
.menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-glass);
    background: white;
    border-radius: 0.625rem;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-main);
}

.menu-toggle:hover { background: rgba(0, 0, 0, 0.03); }
.menu-toggle i { width: 1.25rem; height: 1.25rem; }

/* Mobile sheet (collapsed by default) */
.mobile-sheet {
    display: none;
    border-top: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
}

.mobile-sheet.open { display: block; }

.mobile-sheet-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.mobile-sheet a,
.mobile-sheet button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 0.9rem;
    border-radius: 0.625rem;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 1rem;
    background: transparent;
    border: none;
    text-align: left;
    width: 100%;
    cursor: pointer;
}

.mobile-sheet a:hover,
.mobile-sheet button:hover {
    background: rgba(0, 0, 0, 0.04);
}

.mobile-sheet .sheet-divider {
    height: 1px;
    background: var(--border-glass);
    margin: 0.5rem 0;
}

.mobile-sheet a.primary-cta {
    background: var(--primary);
    color: white;
    justify-content: center;
}

.mobile-sheet a.primary-cta:hover {
    background: var(--primary-hover);
}

.mobile-sheet .sheet-user-summary {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0.25rem 0.9rem 0.5rem;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.2rem;
    min-height: 42px;
    border-radius: 0.625rem;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, box-shadow 0.18s, transform 0.05s;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.2;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset,
                0 4px 12px -4px rgba(99, 102, 241, 0.45);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset,
                0 6px 16px -4px rgba(99, 102, 241, 0.55);
}

.btn-secondary {
    background: white;
    color: var(--text-main);
    border-color: var(--border-glass);
}

.btn-secondary:hover { background: rgba(0, 0, 0, 0.04); }

.btn-danger {
    background: transparent;
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.2);
}

.btn-danger:hover { background: rgba(220, 38, 38, 0.08); }

.btn-sm {
    padding: 0.5rem 0.9rem;
    min-height: 36px;
    font-size: 0.85rem;
}

.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-block { width: 100%; }

/* ============================================================
   Layout
   ============================================================ */
.forum-main {
    max-width: 920px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.page-title {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.4rem;
    line-height: 1.2;
}

.page-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

/* ============================================================
   Toolbar / filters
   ============================================================ */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 0.25rem;
    margin: 0 -0.25rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.filter-chip {
    padding: 0.4rem 0.95rem;
    border-radius: 999px;
    border: 1px solid var(--border-glass);
    background: white;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.2;
}

.filter-chip:hover { color: var(--text-main); }

.filter-chip.active {
    color: white;
    background: var(--primary);
    border-color: var(--primary);
}

/* ============================================================
   Question list
   ============================================================ */
.question-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.question-card {
    display: block;
    padding: 1.25rem 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border-glass);
    background: white;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}

.question-card:hover {
    border-color: rgba(var(--primary-rgb), 0.4);
    box-shadow: var(--shadow-sm);
}

.question-card:active { transform: translateY(1px); }

.question-card .title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    line-height: 1.4;
}

.question-card .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 0.85rem;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.meta .dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.4;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.18rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.3;
}

.badge-open       { background: rgba(14, 165, 233, 0.12); color: #0284c7; }
.badge-answered   { background: rgba(34, 197, 94, 0.12);  color: #16a34a; }
.badge-closed     { background: rgba(100, 116, 139, 0.12); color: #475569; }
.badge-admin      { background: rgba(217, 70, 239, 0.12); color: #a21caf; }

/* ============================================================
   Question detail
   ============================================================ */
.question-detail {
    border: 1px solid var(--border-glass);
    border-radius: 1rem;
    padding: 1.75rem;
    background: white;
    margin-bottom: 2rem;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.question-detail h1 {
    font-size: 1.65rem;
    margin-bottom: 1rem;
    line-height: 1.35;
    word-wrap: break-word;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.back-link:hover { color: var(--text-main); }
.back-link i { width: 1rem; height: 1rem; }

.author-line {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
}

.author-line .name {
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.95rem;
}

.avatar {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.markdown-body {
    line-height: 1.75;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    font-family: var(--font-heading);
    margin: 1.5rem 0 0.75rem;
}

.markdown-body h1 { font-size: 1.4rem; }
.markdown-body h2 { font-size: 1.2rem; }
.markdown-body h3 { font-size: 1.05rem; }
.markdown-body p { margin: 0.5rem 0; }

.markdown-body code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.15rem 0.4rem;
    border-radius: 0.3rem;
    font-size: 0.9em;
    word-break: break-word;
}

.markdown-body pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 1rem 0;
    font-size: 0.85rem;
    -webkit-overflow-scrolling: touch;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    word-break: normal;
}

.markdown-body blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
    color: var(--text-muted);
    margin: 1rem 0;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 1rem 0;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.markdown-body table {
    border-collapse: collapse;
    margin: 1rem 0;
    width: 100%;
    font-size: 0.92rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid var(--border-glass);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.markdown-body th {
    background: rgba(0, 0, 0, 0.02);
    font-weight: 700;
}

/* ============================================================
   Attachments
   ============================================================ */
.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.attachment-thumb {
    width: 96px;
    height: 96px;
    border-radius: 0.5rem;
    border: 1px solid var(--border-glass);
    object-fit: cover;
    background: rgba(0, 0, 0, 0.02);
}

.attachment-pdf {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-glass);
    background: white;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9rem;
}

.attachment-pdf:hover { border-color: var(--primary); }

/* ============================================================
   Answers
   ============================================================ */
.answers-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.answers-header h2 { font-size: 1.2rem; }

.answer {
    border: 1px solid var(--border-glass);
    border-radius: 1rem;
    padding: 1.5rem;
    background: white;
    margin-bottom: 1rem;
    position: relative;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.answer.is-best {
    border-color: #16a34a;
    box-shadow: 0 0 0 1px #16a34a inset, var(--shadow-sm);
}

.best-ribbon {
    position: absolute;
    top: -10px;
    left: 1rem;
    background: #16a34a;
    color: white;
    padding: 0.18rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* ============================================================
   Forms
   ============================================================ */
.form-card {
    border: 1px solid var(--border-glass);
    border-radius: 1rem;
    padding: 1.75rem;
    background: white;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-row label {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-main);
}

.form-row input,
.form-row select,
.form-row textarea {
    padding: 0.7rem 0.9rem;
    min-height: 44px; /* touch target */
    border: 1px solid var(--border-glass);
    border-radius: 0.55rem;
    font-family: inherit;
    font-size: 1rem; /* prevents iOS zoom on focus */
    background: white;
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
}

.form-row select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2364748b' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.25rem;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.form-row input:disabled {
    background: #f8fafc;
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-row textarea {
    min-height: 12rem;
    resize: vertical;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.92rem;
    line-height: 1.6;
}

.form-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.field-help {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
    padding: 0.85rem 1rem;
    border-radius: 0.55rem;
    font-size: 0.92rem;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.alert-error   { background: rgba(220, 38, 38, 0.08);  color: #b91c1c; border: 1px solid rgba(220, 38, 38, 0.2); }
.alert-success { background: rgba(34, 197, 94, 0.08);  color: #166534; border: 1px solid rgba(34, 197, 94, 0.25); }
.alert-info    { background: rgba(99, 102, 241, 0.08); color: #3730a3; border: 1px solid rgba(99, 102, 241, 0.2); }

/* ============================================================
   Auth pages
   ============================================================ */
.auth-wrap {
    max-width: 440px;
    margin: 4rem auto;
    padding: 0 1.5rem;
}

.auth-wrap .form-card { padding: 2.25rem 2rem; }

.auth-wrap h1 {
    font-size: 1.75rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-wrap p.lead {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.75rem;
    font-size: 0.95rem;
    line-height: 1.6;
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.7;
}

.auth-switch a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

/* ============================================================
   Empty / loading states
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
}

.empty-state .icon-bubble {
    display: inline-flex;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.empty-state .icon-bubble i { width: 1.75rem; height: 1.75rem; }

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem;
}

/* ============================================================
   Upload widget
   ============================================================ */
.upload-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.upload-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.04);
    font-size: 0.85rem;
    word-break: break-all;
}

.upload-item button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.25rem;
    min-height: 24px;
}

.upload-item button:hover { color: #dc2626; }

/* ============================================================
   Responsive
   ============================================================ */

/* Tablet — collapse the desktop nav and reveal hamburger */
@media (max-width: 768px) {
    .forum-nav { display: none; }
    .menu-toggle { display: inline-flex; }
    .forum-header .container { padding: 0.65rem 1rem; }

    /* Compact brand group — hide the "KNX & DALI Hub" text, keep the back
       arrow as an icon-only button so the brand fits on narrow phones. */
    .brand-back-text { display: none; }
    .forum-back { padding: 0.35rem; }
    .brand-separator { display: none; }

    .forum-main { padding: 1.5rem 1rem 3.5rem; }

    .page-title { font-size: 1.55rem; }
    .page-subtitle { font-size: 0.9rem; margin-bottom: 1.5rem; }

    .question-detail { padding: 1.25rem; }
    .question-detail h1 { font-size: 1.35rem; }

    .answer { padding: 1.25rem; }

    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar > .btn { width: 100%; }

    .form-card { padding: 1.25rem; }
    .auth-wrap { margin: 1.75rem auto; }
    .auth-wrap .form-card { padding: 1.5rem 1.25rem; }

    .author-line { font-size: 0.85rem; }
    .question-card { padding: 1rem 1.15rem; }
    .question-card .title { font-size: 1rem; }

    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
}

/* Small phone — tighten further */
@media (max-width: 420px) {
    .forum-header .container { padding: 0.5rem 0.85rem; gap: 0.5rem; }
    .forum-brand { font-size: 1rem; }
    .forum-main { padding: 1.25rem 0.85rem 3rem; }
    .page-title { font-size: 1.4rem; }
    .question-detail { padding: 1rem; }
    .question-detail h1 { font-size: 1.2rem; }
    .answer { padding: 1rem; }
    .form-card { padding: 1rem; }
}

/* Pointer:fine (mouse) keeps hovers feeling crisp; pointer:coarse lifts
   tap targets a touch. */
@media (pointer: coarse) {
    .btn { min-height: 44px; }
    .filter-chip { padding: 0.55rem 1rem; }
}
