/* ==========================================================
   Developer QA Plugin - Frontend Styles
   ========================================================== */

/* ---------- Reset & Container ---------- */
.devqa-container {
    font-family: var(--devqa-font, 'Inter', sans-serif);
    color: var(--devqa-text, #1e293b);
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* prevent any child from causing horizontal scroll */
    overflow-x: hidden;
    width: 100%;
}

.devqa-container *,
.devqa-container *::before,
.devqa-container *::after {
    box-sizing: border-box;
}

/* ==========================================================
   TOP BAR  — search input (left) + category dropdown (right)
   Always visible on ALL screen sizes.
   On desktop the sidebar also shows; dropdown is hidden there.
   ========================================================== */
.devqa-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: nowrap;
}

/* Search form stretches to fill available space */
.devqa-topbar-search {
    flex: 1;
    min-width: 0;
}

/* ---------- Search Box ---------- */
.devqa-search-box {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: var(--devqa-radius, 12px);
    padding: 6px 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    width: 100%;
}

.devqa-search-box:focus-within {
    border-color: var(--devqa-primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12), 0 4px 12px rgba(99, 102, 241, 0.08);
}

.devqa-search-icon {
    color: #94a3b8;
    flex-shrink: 0;
    margin-right: 8px;
}

.devqa-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    color: var(--devqa-text, #1e293b);
    background: transparent;
    padding: 6px 0;
    min-width: 0;
}

.devqa-search-input::placeholder {
    color: #94a3b8;
}

/* Search button — hidden by default (live search only) */
.devqa-search-btn {
    display: none;
}

/* ---------- Category Dropdown (top bar) ----------
   DEFAULT = hidden. Only shown on mobile via media query below.
   ---------------------------------------------------------- */
.devqa-cat-dropdown-wrap {
    display: none;           /* hidden on desktop — sidebar is used instead */
    position: relative;
    flex-shrink: 0;
    max-width: 45%;          /* never push layout wider than half the bar */
}

.devqa-cat-select {
    appearance: none;
    -webkit-appearance: none;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: var(--devqa-radius, 12px);
    padding: 10px 32px 10px 12px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    color: var(--devqa-text, #1e293b);
    cursor: pointer;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    width: 100%;             /* fill parent max-width */
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.devqa-cat-select:focus {
    outline: none;
    border-color: var(--devqa-primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.devqa-select-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

/* ==========================================================
   LAYOUT — sidebar (desktop) + main content
   ========================================================== */
.devqa-layout {
    display: flex;
    gap: 28px;
    align-items: flex-start;
}

.devqa-no-sidebar .devqa-main-content {
    width: 100%;
}

.devqa-with-sidebar .devqa-sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
}

.devqa-with-sidebar .devqa-main-content {
    flex: 1;
    min-width: 0;
}

/* ---------- Sidebar ---------- */
.devqa-sidebar {
    background: #ffffff;
    border-radius: var(--devqa-radius, 12px);
    box-shadow: var(--devqa-shadow, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.devqa-sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--devqa-primary, #6366f1);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(139, 92, 246, 0.06));
    border-bottom: 1px solid #e2e8f0;
}

.devqa-cat-list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.devqa-cat-list li {
    margin: 0;
    padding: 0;
}

.devqa-cat-list li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    text-decoration: none;
    color: var(--devqa-text, #1e293b);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.25s ease;
    border-left: 3px solid transparent;
}

.devqa-cat-list li a:hover {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.06), transparent);
    color: var(--devqa-primary, #6366f1);
    border-left-color: var(--devqa-primary, #6366f1);
}

.devqa-cat-list li.devqa-cat-active a {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.1), rgba(99, 102, 241, 0.02));
    color: var(--devqa-primary, #6366f1);
    border-left-color: var(--devqa-primary, #6366f1);
    font-weight: 600;
}

.devqa-cat-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.devqa-cat-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.devqa-cat-count {
    background: #f1f5f9;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
    transition: all 0.25s ease;
}

.devqa-cat-active .devqa-cat-count {
    background: var(--devqa-primary, #6366f1);
    color: #fff;
}

/* ---------- Items Header ---------- */
.devqa-items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 4px;
}

.devqa-result-count {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

.devqa-expand-controls {
    display: flex;
    gap: 8px;
}

.devqa-expand-all,
.devqa-collapse-all {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.devqa-expand-all:hover,
.devqa-collapse-all:hover {
    background: var(--devqa-primary, #6366f1);
    color: #fff;
    border-color: var(--devqa-primary, #6366f1);
}

/* ---------- Question Items ---------- */
.devqa-questions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.devqa-item {
    background: #ffffff;
    border-radius: var(--devqa-radius, 12px);
    box-shadow: var(--devqa-shadow, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
    overflow: hidden;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.devqa-item:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.08);
}

.devqa-item-highlighted {
    border-left: 4px solid var(--devqa-accent, #06b6d4);
}

.devqa-item-highlighted .devqa-question {
    background: linear-gradient(90deg, rgba(6, 182, 212, 0.04), transparent);
}

/* Question Row */
.devqa-question {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    gap: 14px;
    transition: background 0.2s ease;
    position: relative;
}

.devqa-question:hover {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.03), transparent);
}

.devqa-question:focus {
    outline: 2px solid var(--devqa-primary, #6366f1);
    outline-offset: -2px;
}

.devqa-question[aria-expanded="true"] {
    border-bottom: 1px solid #e2e8f0;
}

/* Bullets */
.devqa-bullet {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--devqa-primary, #6366f1);
    flex-shrink: 0;
    min-width: 28px;
    font-size: 14px;
}

.devqa-bullet-number {
    background: linear-gradient(135deg, var(--devqa-primary, #6366f1), var(--devqa-secondary, #8b5cf6));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 15px;
}

.devqa-bullet-circle-number {
    font-size: 20px;
    color: var(--devqa-primary, #6366f1);
}

.devqa-bullet-dot,
.devqa-bullet-square,
.devqa-bullet-diamond,
.devqa-bullet-arrow,
.devqa-bullet-star,
.devqa-bullet-check {
    color: var(--devqa-primary, #6366f1);
    font-size: 12px;
}

.devqa-bullet-hash {
    font-family: 'Source Code Pro', monospace;
    font-size: 13px;
    color: var(--devqa-accent, #06b6d4);
}

/* Question Text */
.devqa-question-text {
    flex: 1;
    font-size: var(--devqa-fs-q, 16px);
    font-weight: 500;
    color: var(--devqa-text, #1e293b);
    line-height: 1.5;
}

/* Toggle Icon */
.devqa-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.08));
    color: var(--devqa-primary, #6366f1);
    flex-shrink: 0;
    transition: all var(--devqa-speed, 300ms) ease;
}

.devqa-item.devqa-item-open .devqa-toggle-icon {
    background: linear-gradient(135deg, var(--devqa-primary, #6366f1), var(--devqa-secondary, #8b5cf6));
    color: #ffffff;
    transform: rotate(180deg);
}

/* Answer */
.devqa-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--devqa-speed, 300ms) cubic-bezier(0.4, 0, 0.2, 1);
}

.devqa-answer-inner {
    padding: 20px 24px 24px;
    font-size: var(--devqa-fs-a, 15px);
    line-height: 1.8;
    color: #475569;
    background: var(--devqa-answer-bg, #f8fafc);
    border-top: 1px solid #e2e8f0;
}

.devqa-answer-inner p {
    margin: 0 0 12px 0;
}
.devqa-answer-inner p:last-child {
    margin-bottom: 0;
}

.devqa-answer-inner ul,
.devqa-answer-inner ol {
    margin: 8px 0 12px 0;
    padding-left: 24px;
}

.devqa-answer-inner li {
    margin-bottom: 4px;
}

.devqa-answer-inner strong {
    color: var(--devqa-text, #1e293b);
    font-weight: 600;
}

.devqa-answer-inner em {
    color: var(--devqa-primary, #6366f1);
    font-style: italic;
}

.devqa-answer-inner code {
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Source Code Pro', 'Consolas', monospace;
    font-size: 0.9em;
    color: #7c3aed;
}

.devqa-answer-inner pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px 20px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 14px 0;
    line-height: 1.6;
    font-size: 13px;
    border: 1px solid #334155;
}

.devqa-answer-inner pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
    border-radius: 0;
}

.devqa-answer-inner table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 14px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.devqa-answer-inner thead {
    background: linear-gradient(135deg, var(--devqa-primary, #6366f1), var(--devqa-secondary, #8b5cf6));
    color: #fff;
}

.devqa-answer-inner th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
}

.devqa-answer-inner td {
    padding: 9px 14px;
    border-bottom: 1px solid #e2e8f0;
}

.devqa-answer-inner tbody tr:nth-child(even) {
    background: rgba(99, 102, 241, 0.02);
}

.devqa-answer-inner tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* ==========================================================
   SEARCH KEYWORD HIGHLIGHT
   ========================================================== */
mark.devqa-hl {
    background: var(--devqa-highlight, #fef08a);
    color: #1a1a1a;
    border-radius: 3px;
    padding: 0 2px;
    font-weight: 700;
    box-shadow: 0 0 0 1px rgba(202, 138, 4, 0.25);
    font-style: normal;
}

/* ==========================================================
   REALTIME SEARCH SPINNER
   ========================================================== */
.devqa-spinner {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #6366f1;
    font-size: 13px;
    font-weight: 500;
}

.devqa-spin-icon {
    animation: devqa-spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes devqa-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}


/* ---------- Pagination ---------- */
.devqa-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 28px;
    padding: 16px 0;
    flex-wrap: wrap;
}

.devqa-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    color: var(--devqa-text, #1e293b);
    background: #ffffff;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
}

.devqa-page-btn:hover {
    background: var(--devqa-primary, #6366f1);
    color: #fff;
    border-color: var(--devqa-primary, #6366f1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.devqa-page-current {
    background: linear-gradient(135deg, var(--devqa-primary, #6366f1), var(--devqa-secondary, #8b5cf6));
    color: #fff;
    border-color: transparent;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.devqa-page-current:hover {
    transform: none;
}

.devqa-page-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.devqa-page-info {
    margin-left: 12px;
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
}

/* ---------- No Results ---------- */
.devqa-no-results {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.devqa-no-results svg {
    margin-bottom: 20px;
    opacity: 0.5;
}

.devqa-no-results h3 {
    font-size: 20px;
    color: #64748b;
    margin: 0 0 8px 0;
    font-weight: 600;
}

.devqa-no-results p {
    font-size: 14px;
    margin: 0;
}

/* ---------- Animations ---------- */
@keyframes devqaSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.devqa-item {
    animation: devqaSlideIn 0.4s ease forwards;
}

.devqa-item:nth-child(1)  { animation-delay: 0.02s; }
.devqa-item:nth-child(2)  { animation-delay: 0.04s; }
.devqa-item:nth-child(3)  { animation-delay: 0.06s; }
.devqa-item:nth-child(4)  { animation-delay: 0.08s; }
.devqa-item:nth-child(5)  { animation-delay: 0.10s; }
.devqa-item:nth-child(6)  { animation-delay: 0.12s; }
.devqa-item:nth-child(7)  { animation-delay: 0.14s; }
.devqa-item:nth-child(8)  { animation-delay: 0.16s; }
.devqa-item:nth-child(9)  { animation-delay: 0.18s; }
.devqa-item:nth-child(10) { animation-delay: 0.20s; }

/* ==========================================================
   RESPONSIVE — Tablet & Mobile  (≤ 900px)
   SIDEBAR hidden → category dropdown shown in top bar
   ========================================================== */
@media screen and (max-width: 900px) {

    /* ① Hide sidebar: every possible selector to beat theme specificity */
    .devqa-container .devqa-sidebar,
    .devqa-container aside.devqa-sidebar,
    .devqa-with-sidebar .devqa-sidebar,
    .devqa-layout .devqa-sidebar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        position: absolute !important;
        visibility: hidden !important;
    }

    /* ② Show category dropdown in top bar */
    .devqa-cat-dropdown-wrap {
        display: block !important;
    }

    /* ③ Stack layout vertically, give main content full width */
    .devqa-layout,
    .devqa-with-sidebar {
        flex-direction: column !important;
    }

    .devqa-with-sidebar .devqa-main-content,
    .devqa-layout .devqa-main-content {
        width: 100% !important;
        max-width: 100% !important;
        flex: unset !important;
        min-width: 0 !important;
    }

    /* ④ Prevent horizontal overflow */
    .devqa-topbar,
    .devqa-layout,
    .devqa-main-content,
    .devqa-questions-list,
    .devqa-item,
    .devqa-question,
    .devqa-answer-inner {
        max-width: 100% !important;
        overflow-x: hidden;
        word-break: break-word;
    }
}

/* ---------- Mobile  (≤ 600px) ---------- */
@media screen and (max-width: 600px) {
    .devqa-topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    /* Both elements take full width on small screens */
    .devqa-topbar-search {
        flex: none;
        width: 100%;
        min-width: 0;
    }

    .devqa-cat-dropdown-wrap {
        flex: none;
        max-width: 100%;
        width: 100%;
    }

    .devqa-search-box {
        padding: 4px 10px;
    }

    .devqa-search-input {
        font-size: 14px;
        padding: 6px 0;
    }

    .devqa-cat-select {
        font-size: 14px;
        padding: 10px 32px 10px 12px;
        width: 100%;
    }

    .devqa-question {
        padding: 13px 12px;
        gap: 8px;
    }

    .devqa-question-text {
        font-size: 14px;
    }

    .devqa-answer-inner {
        padding: 14px 14px 18px;
        font-size: 13px;
    }

    .devqa-toggle-icon {
        width: 28px;
        height: 28px;
    }

    .devqa-items-header {
        flex-direction: row-reverse;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }

    .devqa-pagination { gap: 3px; flex-wrap: wrap; }

    .devqa-page-btn {
        min-width: 32px;
        height: 32px;
        padding: 0 7px;
        font-size: 12px;
    }

    .devqa-page-info { display: none; }
}

/* ---------- Print ---------- */
@media print {
    .devqa-topbar,
    .devqa-sidebar,
    .devqa-pagination,
    .devqa-expand-controls,
    .devqa-toggle-icon {
        display: none !important;
    }

    .devqa-answer {
        max-height: none !important;
        overflow: visible !important;
    }

    .devqa-item {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }
}
