/* ============================================================
   ORVO Help — Stylesheet
   Theme: Dark, Outfit font, Teal accent (#188796)
   Matches admin.css design tokens
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400&display=swap');

/* --- Reset & Base --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scrollbar-gutter: stable;
    overflow-y: scroll;
    touch-action: pan-x pan-y;
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    font-size: 16px;
    background: #000000;
    color: #FFFFFF;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    animation: pageIn 0.3s ease-out 0.05s forwards;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.page-exit {
    animation: pageOut 0.2s ease-in forwards;
}

a { color: #188796; text-decoration: none; }
a:hover { color: #73D1DE; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: #111111; border-radius: 5px; }
::-webkit-scrollbar-thumb { background: #444444; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #666666; }

/* --- Header --- */
.header {
    background: #0a0a0a;
    border-bottom: 1px solid #333333;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: #FFFFFF;
    flex-shrink: 0;
}

.logo img {
    height: 28px;
    filter: brightness(0) invert(1) opacity(0.9);
}

.logo-label {
    font-size: 14px;
    font-weight: 400;
    color: #888888;
    letter-spacing: 0.05em;
}

.header-center {
    flex: 1;
    max-width: 480px;
    margin: 0 24px;
    position: relative;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-icon {
    background: none;
    border: none;
    color: #888888;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}

.btn-icon:hover {
    color: #FFFFFF;
    background: #1a1a1a;
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

/* --- Search --- */
.search-wrap {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    background: #171717;
    border: 1px solid #333333;
    border-radius: 20px;
    padding: 8px 16px 8px 40px;
    font-size: 14px;
    font-family: inherit;
    color: #FFFFFF;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

.search-input::placeholder {
    color: #666666;
}

.search-input:focus {
    border-color: #188796;
    background: #1a1a1a;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #666666;
    pointer-events: none;
}

.search-icon svg {
    width: 16px;
    height: 16px;
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #171717;
    border: 1px solid #333333;
    border-radius: 10px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 200;
    display: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.search-results.active {
    display: block;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid #222222;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #1a1a1a;
}

.search-result-title {
    font-size: 14px;
    color: #FFFFFF;
    font-weight: 500;
}

.search-result-summary {
    font-size: 12px;
    color: #888888;
    margin-top: 2px;
}

.search-result-badge {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.search-result-badge.staff {
    background: rgba(12, 171, 65, 0.15);
    color: #0CAB41;
}

.search-result-badge.owner {
    background: rgba(24, 135, 150, 0.15);
    color: #188796;
}

.search-result-badge.admin {
    background: rgba(183, 72, 31, 0.15);
    color: #B7481F;
}

.search-no-results {
    padding: 20px 16px;
    text-align: center;
    color: #666666;
    font-size: 14px;
}

/* --- Help Layout --- */
.help-layout {
    display: flex;
    padding-top: 80px;
    min-height: 100vh;
}

/* --- Sidebar --- */
.help-sidebar {
    width: 280px;
    position: fixed;
    top: 80px;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    background: #0a0a0a;
    border-right: 1px solid #222222;
    padding: 24px 0;
    z-index: 50;
    transition: transform 0.25s ease;
}

.sidebar-section {
    margin-bottom: 8px;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #888888;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 12px 24px 6px;
}

.sidebar-link {
    display: block;
    font-size: 14px;
    color: #888888;
    padding: 7px 24px 7px 28px;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: color 0.15s, background 0.1s, border-color 0.15s;
    line-height: 1.4;
}

.sidebar-link:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-link.active {
    color: #188796;
    border-left-color: #188796;
    background: rgba(24, 135, 150, 0.05);
}

/* --- Main Content --- */
.help-content {
    flex: 1;
    margin-left: 280px;
    padding: 24px 48px 100px;
    max-width: 960px;
}

/* --- Article Sections --- */
.article-section {
    padding-bottom: 48px;
    margin-bottom: 48px;
    border-bottom: 1px solid #1a1a1a;
    scroll-margin-top: 96px;
}

.article-section h3[id] {
    scroll-margin-top: 96px;
}

.article-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* Article typography */
.article-section h2 {
    font-size: 24px;
    font-weight: 700;
    color: #FFFFFF;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #222222;
}

.article-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: #CCCCCC;
    margin-top: 32px;
    margin-bottom: 12px;
}

.article-section h4 {
    font-size: 15px;
    font-weight: 600;
    color: #AAAAAA;
    margin-top: 24px;
    margin-bottom: 8px;
}

.article-section p {
    font-size: 15px;
    color: #CCCCCC;
    line-height: 1.7;
    margin-bottom: 16px;
}

.article-section ul,
.article-section ol {
    margin: 0 0 16px 24px;
    color: #CCCCCC;
    font-size: 15px;
    line-height: 1.7;
}

.article-section li {
    margin-bottom: 6px;
}

.article-section li::marker {
    color: #188796;
}

.article-section code {
    font-family: 'JetBrains Mono', monospace;
    background: #222222;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
    color: #73D1DE;
}

.article-section pre {
    background: #111111;
    border: 1px solid #333333;
    border-radius: 8px;
    padding: 16px 20px;
    overflow-x: auto;
    max-width: 100%;
    margin-bottom: 16px;
}

.article-section pre code {
    background: none;
    padding: 0;
    font-size: 13px;
    color: #CCCCCC;
    line-height: 1.6;
}

.article-section img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid #333333;
    margin: 12px 0;
}

/* Tables inside articles */
.article-section table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    background: #171717;
    border: 1px solid #333333;
    border-radius: 8px;
    overflow: hidden;
}

.article-section th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #888888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid #333333;
    background: #111111;
}

.article-section td {
    padding: 10px 16px;
    font-size: 14px;
    color: #CCCCCC;
    border-bottom: 1px solid #222222;
}

.article-section tr:last-child td {
    border-bottom: none;
}

/* Callout boxes */
.callout {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.6;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.callout-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
}

.callout-tip {
    background: rgba(12, 171, 65, 0.08);
    border: 1px solid rgba(12, 171, 65, 0.2);
    color: #CCCCCC;
}

.callout-tip .callout-icon { color: #0CAB41; }

.callout-warning {
    background: rgba(183, 72, 31, 0.08);
    border: 1px solid rgba(183, 72, 31, 0.2);
    color: #CCCCCC;
}

.callout-warning .callout-icon { color: #B7481F; }

.callout-info {
    background: rgba(24, 135, 150, 0.08);
    border: 1px solid rgba(24, 135, 150, 0.2);
    color: #CCCCCC;
}

.callout-info .callout-icon { color: #188796; }

/* Keyboard shortcut display */
kbd {
    background: #222222;
    border: 1px solid #444444;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #CCCCCC;
    box-shadow: 0 1px 0 #333333;
}

/* --- Feedback Widget --- */
.feedback-widget {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    margin-top: 24px;
}

.feedback-label {
    font-size: 14px;
    color: #888888;
}

.feedback-btn {
    background: #171717;
    border: 1px solid #333333;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-family: inherit;
    color: #888888;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.feedback-btn:hover {
    background: #222222;
    border-color: #444444;
    color: #FFFFFF;
}

.feedback-btn.selected {
    border-color: #188796;
    color: #188796;
}

.feedback-btn svg {
    width: 16px;
    height: 16px;
}

.feedback-comment {
    margin-top: 12px;
    display: none;
}

.feedback-comment.active {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 400px;
}

.feedback-comment textarea {
    width: 100%;
    max-width: 400px;
    background: #222222;
    color: #FFFFFF;
    border: 1px solid #444444;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.15s;
}

.feedback-comment textarea::placeholder {
    color: #666666;
}

.feedback-comment textarea:focus {
    border-color: #188796;
}

.feedback-comment .feedback-submit {
    margin-top: 8px;
    background: #188796;
    color: #FFFFFF;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.feedback-comment .feedback-submit:hover {
    background: #146d79;
}

.feedback-thanks {
    font-size: 14px;
    color: #0CAB41;
    padding: 16px 0;
    margin-top: 24px;
}

/* --- Chat Widget --- */
.chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    background: #188796;
    border: none;
    border-radius: 50%;
    color: #FFFFFF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    box-shadow: 0 4px 16px rgba(24, 135, 150, 0.4);
    transition: background 0.15s, transform 0.15s;
}

.chat-toggle:hover {
    background: #1a9dae;
    transform: scale(1.05);
}

.chat-toggle svg {
    width: 24px;
    height: 24px;
}

.chat-panel {
    position: fixed;
    bottom: 88px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: #171717;
    border: 1px solid #333333;
    border-radius: 12px;
    z-index: 900;
    display: none;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.chat-panel.active {
    display: flex;
    animation: chatIn 0.2s ease-out;
}

@keyframes chatIn {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-header {
    background: #111111;
    border-bottom: 1px solid #333333;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 15px;
    font-weight: 600;
    color: #FFFFFF;
}

.chat-header-subtitle {
    font-size: 11px;
    color: #888888;
    margin-top: 1px;
}

.chat-close {
    background: none;
    border: none;
    color: #888888;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.chat-close:hover {
    color: #FFFFFF;
}

.chat-close svg {
    width: 18px;
    height: 18px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-msg-user {
    align-self: flex-end;
    background: #222222;
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
}

.chat-msg-assistant {
    align-self: flex-start;
    background: #0a0a0a;
    color: #CCCCCC;
    border: 1px solid #222222;
    border-bottom-left-radius: 4px;
}

.chat-msg-assistant code {
    font-family: 'JetBrains Mono', monospace;
    background: #171717;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
    color: #73D1DE;
}

.chat-msg-system {
    align-self: center;
    color: #666666;
    font-size: 12px;
    padding: 4px;
}

.chat-typing {
    align-self: flex-start;
    color: #666666;
    font-size: 13px;
    padding: 8px 0;
    display: none;
}

.chat-typing.active {
    display: block;
}

.chat-input-wrap {
    border-top: 1px solid #333333;
    padding: 12px;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    background: #111111;
}

.chat-input {
    flex: 1;
    background: #222222;
    border: 1px solid #444444;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: #FFFFFF;
    outline: none;
    resize: none;
    min-height: 40px;
    max-height: 100px;
    transition: border-color 0.15s;
}

.chat-input::placeholder {
    color: #666666;
}

.chat-input:focus {
    border-color: #188796;
}

.chat-send {
    background: #188796;
    border: none;
    border-radius: 8px;
    color: #FFFFFF;
    cursor: pointer;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.chat-send:hover {
    background: #1a9dae;
}

.chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-send svg {
    width: 18px;
    height: 18px;
}

/* --- Toast (reused from admin) --- */
.toast-container {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    border: none;
    border-left: 4px solid;
    border-radius: 10px;
    padding: 16px 24px;
    font-size: 14px;
    font-weight: 500;
    color: #FFFFFF;
    animation: toastIn 0.3s ease-out;
    max-width: 420px;
}

.toast-icon {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
}

.toast-success {
    background: #0a3d1a;
    border-left-color: #0CAB41;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6), 0 0 24px rgba(12, 171, 65, 0.2);
}

.toast-success .toast-icon {
    background: rgba(12, 171, 65, 0.35);
    color: #4ADE80;
}

.toast-error {
    background: #3b1111;
    border-left-color: #B52B2B;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6), 0 0 24px rgba(181, 43, 43, 0.2);
}

.toast-error .toast-icon {
    background: rgba(181, 43, 43, 0.35);
    color: #F87171;
}

/* --- Footer --- */
.footer {
    border-top: 1px solid #222222;
    padding: 2rem 24px;
    text-align: center;
    margin-left: 280px;
}

.footer-logo {
    width: 80px;
    filter: brightness(0) invert(1) opacity(0.3);
    margin-bottom: 1rem;
}

.footer p {
    font-size: 0.8rem;
    color: #444444;
    font-family: 'JetBrains Mono', monospace;
    margin: 0;
}

/* --- Page Loading Bar --- */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 9999;
    pointer-events: none;
}

.page-loader-bar {
    height: 100%;
    background: #188796;
    box-shadow: 0 0 8px rgba(24, 135, 150, 0.6);
    border-radius: 0 2px 2px 0;
    width: 0;
    animation: pageLoad 1.8s ease-in-out infinite;
}

/* --- Mobile hamburger --- */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: #888888;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: color 0.15s;
}

.hamburger:hover {
    color: #FFFFFF;
}

.hamburger svg {
    width: 22px;
    height: 22px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 49;
}

/* --- Animations --- */
@keyframes pageIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes pageOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

@keyframes pageLoad {
    0%   { width: 0; margin-left: 0; }
    50%  { width: 40%; margin-left: 30%; }
    100% { width: 0; margin-left: 100%; }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-12px) scale(0.96); }
}

/* --- Print --- */
@media print {
    .help-sidebar,
    .header,
    .footer,
    .chat-toggle,
    .chat-panel,
    .feedback-widget,
    .sidebar-overlay,
    .hamburger,
    .header-center,
    .header-actions,
    .page-loader {
        display: none !important;
    }

    body {
        background: white;
        color: black;
        opacity: 1;
        animation: none;
    }

    .help-content {
        margin-left: 0;
        padding: 0;
        max-width: 100%;
    }

    .footer {
        margin-left: 0;
    }

    .article-section h2 {
        color: black;
        border-bottom-color: #ccc;
    }

    .article-section h3,
    .article-section h4 {
        color: #333;
    }

    .article-section p,
    .article-section li,
    .article-section td {
        color: #333;
    }

    .article-section code {
        background: #f0f0f0;
        color: #333;
    }

    .article-section pre {
        background: #f5f5f5;
        border-color: #ddd;
    }

    .article-section table {
        background: white;
        border-color: #ddd;
    }

    .article-section th {
        background: #f0f0f0;
        color: #333;
    }

    .callout {
        border-color: #ccc;
        background: #f9f9f9;
    }

    a { color: #333; text-decoration: underline; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    .header-center {
        display: none;
    }

    .help-sidebar {
        transform: translateX(-100%);
        width: 280px;
        z-index: 51;
    }

    .help-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .help-content {
        margin-left: 0;
        padding: 24px 16px 100px;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .footer {
        margin-left: 0;
    }

    /* Mobile search — show below header */
    .header-center.mobile-active {
        display: block;
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        padding: 12px 16px;
        background: #0a0a0a;
        border-bottom: 1px solid #333333;
        max-width: none;
        margin: 0;
        z-index: 99;
    }

    .header-center.mobile-active ~ .help-layout {
        padding-top: 120px;
    }

    .chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-height: 100dvh;
    }

    .chat-toggle {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }

    .article-section h2 { font-size: 20px; }
    .article-section h3 { font-size: 16px; }
}

@media (max-width: 480px) {
    .header { padding: 0 12px; }
    .logo img { height: 22px; }
    .help-content { padding: 20px 12px 100px; }
    .article-section p,
    .article-section li { font-size: 14px; }
}
