/* ==========================================================================
   Curia Help Framework - Component Styles
   Prefix: .ch- (Curia Help)
   Z-index budget: FAB=1050, Panel=1100, Tip popover=1200
   ========================================================================== */

/* ==========================================================================
   1. HELP PANEL (right slide-out)
   ========================================================================== */

.ch-panel {
    position: fixed;
    top: 0;
    right: -340px;
    width: 320px;
    height: 100vh;
    background: #ffffff;
    border-left: 1px solid #e5e7eb;
    box-shadow: none;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    transition: right 250ms ease, box-shadow 250ms ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ch-panel--open {
    right: 0;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
}

.ch-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.ch-panel-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin: 0;
    line-height: 1.3;
}

.ch-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: 6px;
    color: #6b7280;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
    padding: 0;
    flex-shrink: 0;
}

.ch-panel-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.ch-panel-close:focus-visible {
    outline: 2px solid var(--cdt-primary, #438eb9);
    outline-offset: -2px;
}

/* Panel Search */
.ch-panel-search {
    position: relative;
    padding: 12px 20px;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
}

input[type="text"].ch-panel-search-input {
    width: 100%;
    height: 36px !important;
    padding: 0 32px 0 12px !important;
    font-size: 13px !important;
    color: #374151 !important;
    background: #f9fafb !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 6px !important;
    outline: none !important;
    transition: border-color 150ms ease, box-shadow 150ms ease !important;
    box-sizing: border-box;
}

.ch-panel-search-input::placeholder {
    color: #9ca3af;
}

.ch-panel-search-input:focus {
    border-color: var(--cdt-primary, #438eb9);
    box-shadow: 0 0 0 3px rgba(67, 142, 185, 0.12);
    background: #ffffff;
}

.ch-panel-search-clear {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    border-radius: 4px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    transition: color 150ms ease, background 150ms ease;
}

.ch-panel-search-clear:hover {
    color: #6b7280;
    background: #e5e7eb;
}

/* Panel Body */
.ch-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    -webkit-overflow-scrolling: touch;
}

.ch-panel-body::-webkit-scrollbar {
    width: 5px;
}

.ch-panel-body::-webkit-scrollbar-track {
    background: transparent;
}

.ch-panel-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* Panel Footer */
.ch-panel-footer {
    border-top: 1px solid #e5e7eb;
    padding: 16px 20px;
    flex-shrink: 0;
}

/* Panel Overlay (mobile only) */
.ch-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1099;
    display: none;
    opacity: 0;
    transition: opacity 250ms ease;
}

.ch-panel-overlay--visible {
    display: block;
    opacity: 1;
}

/* ==========================================================================
   2. TOPICS
   ========================================================================== */

.ch-topics-heading {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px 0;
    padding: 0;
}

.ch-topics-heading:not(:first-child) {
    margin-top: 20px;
}

.ch-topic-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 150ms ease;
}

.ch-topic-item:hover {
    background: #f3f4f6;
}

.ch-topic-item--expanded {
    background: #f9fafb;
}

.ch-topic-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: var(--cdt-primary-light, #e8f0fe);
    color: var(--cdt-primary, #438eb9);
    border-radius: 6px;
    flex-shrink: 0;
    margin-top: 1px;
}

.ch-topic-icon svg {
    width: 14px;
    height: 14px;
}

.ch-topic-info {
    flex: 1;
    min-width: 0;
}

.ch-topic-title {
    font-size: 13px;
    font-weight: 500;
    color: #111827;
    line-height: 1.4;
    margin: 0;
}

.ch-topic-content {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.5;
    margin: 6px 0 0 0;
    display: none;
}

.ch-topic-item--expanded .ch-topic-content {
    display: block;
}

.ch-topic-expand-btn {
    font-size: 11px;
    font-weight: 500;
    color: var(--cdt-primary, #438eb9);
    background: none;
    border: none;
    padding: 4px 0;
    cursor: pointer;
    margin-top: 4px;
}

.ch-topic-expand-btn:hover {
    text-decoration: underline;
}

/* Search Results */
.ch-search-results {
    padding: 0;
    margin: 0;
    list-style: none;
}

.ch-search-empty {
    text-align: center;
    padding: 32px 16px;
    color: #9ca3af;
    font-size: 13px;
}

.ch-search-empty svg {
    display: block;
    margin: 0 auto 12px;
    color: #d1d5db;
}

.ch-search-highlight {
    background: rgba(67, 142, 185, 0.15);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* ==========================================================================
   3. TOUR PROGRESS (panel footer)
   ========================================================================== */

.ch-tour-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ch-tour-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ch-tour-label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin: 0;
}

.ch-tour-status {
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
    padding: 2px 8px;
    background: #f3f4f6;
    border-radius: 10px;
}

.ch-tour-status--complete {
    background: #d1fae5;
    color: #065f46;
}

.ch-tour-status--progress {
    background: #dbeafe;
    color: #1e40af;
}

.ch-tour-progress-bar {
    width: 100%;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.ch-tour-progress-fill {
    height: 100%;
    background: var(--cdt-primary, #438eb9);
    border-radius: 2px;
    transition: width 300ms ease;
}

.ch-tour-start-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 36px;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    background: var(--cdt-primary, #438eb9);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 150ms ease, box-shadow 150ms ease;
}

.ch-tour-start-btn:hover {
    background: var(--cdt-primary-hover, #367ba3);
    box-shadow: 0 2px 6px rgba(67, 142, 185, 0.3);
}

.ch-tour-start-btn:focus-visible {
    outline: 2px solid var(--cdt-primary, #438eb9);
    outline-offset: 2px;
}

.ch-tour-start-btn svg {
    width: 14px;
    height: 14px;
}

/* ==========================================================================
   4. HELP BUTTON
   ========================================================================== */

/* In-header button (for pages with .ath-header-actions) */
.ch-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 150ms ease;
    white-space: nowrap;
}

.ch-header-btn:hover {
    background: #f9fafb;
    color: #374151;
    border-color: #d1d5db;
}

.ch-header-btn[aria-expanded="true"] {
    background: var(--cdt-primary-light, #e8f0fe);
    color: var(--cdt-primary, #438eb9);
    border-color: var(--cdt-primary, #438eb9);
}

.ch-header-btn:focus-visible {
    outline: 2px solid var(--cdt-primary, #438eb9);
    outline-offset: 2px;
}

.ch-header-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Floating action button (fallback for pages without header actions) */
.ch-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cdt-primary, #438eb9);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 1050;
    transition: transform 150ms ease, box-shadow 150ms ease;
}

.ch-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.ch-fab:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.ch-fab[aria-expanded="true"] {
    background: #374151;
}

.ch-fab svg {
    width: 22px;
    height: 22px;
}

/* Pulse animation for first-visit prompt */
@keyframes ch-pulse {
    0% { box-shadow: 0 0 0 0 rgba(67, 142, 185, 0.5); }
    70% { box-shadow: 0 0 0 12px rgba(67, 142, 185, 0); }
    100% { box-shadow: 0 0 0 0 rgba(67, 142, 185, 0); }
}

.ch-btn--pulse {
    animation: ch-pulse 1.5s ease-out 3;
}

/* ==========================================================================
   5. TIP POPOVERS
   ========================================================================== */

/* Inline info icon trigger */
.ch-tip-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: none;
    border: none;
    border-radius: 50%;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    margin-left: 4px;
    vertical-align: middle;
    transition: color 150ms ease, background 150ms ease;
    flex-shrink: 0;
}

.ch-tip-trigger:hover {
    color: var(--cdt-primary, #438eb9);
    background: rgba(67, 142, 185, 0.1);
}

.ch-tip-trigger:focus-visible {
    outline: 2px solid var(--cdt-primary, #438eb9);
    outline-offset: 1px;
}

.ch-tip-trigger svg {
    width: 14px;
    height: 14px;
}

/* Floating popover */
.ch-tip-popover {
    position: fixed;
    z-index: 1200;
    width: 260px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 14px 16px;
    animation: ch-tipFadeIn 150ms ease-out;
}

@keyframes ch-tipFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.ch-tip-popover-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 6px;
}

.ch-tip-popover-title {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
    margin: 0;
    flex: 1;
}

.ch-tip-popover-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    border-radius: 4px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    margin: -4px -4px 0 8px;
    flex-shrink: 0;
    transition: background 150ms ease, color 150ms ease;
}

.ch-tip-popover-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.ch-tip-popover-close svg {
    width: 14px;
    height: 14px;
}

.ch-tip-popover-content {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.5;
    margin: 0;
}

/* ==========================================================================
   6. DARK THEME
   ========================================================================== */

[data-theme="dark"] .ch-panel {
    background: #1e293b;
    border-left-color: #334155;
}

[data-theme="dark"] .ch-panel-header {
    border-bottom-color: #334155;
}

[data-theme="dark"] .ch-panel-title {
    color: #f1f5f9;
}

[data-theme="dark"] .ch-panel-close {
    color: #94a3b8;
}

[data-theme="dark"] .ch-panel-close:hover {
    background: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .ch-panel-search {
    border-bottom-color: #334155;
}

[data-theme="dark"] .ch-panel-search-input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .ch-panel-search-input::placeholder {
    color: #64748b;
}

[data-theme="dark"] .ch-panel-search-input:focus {
    background: #0f172a;
}

[data-theme="dark"] .ch-panel-footer {
    border-top-color: #334155;
}

[data-theme="dark"] .ch-topics-heading {
    color: #64748b;
}

[data-theme="dark"] .ch-topic-item:hover {
    background: #334155;
}

[data-theme="dark"] .ch-topic-item--expanded {
    background: #0f172a;
}

[data-theme="dark"] .ch-topic-icon {
    background: rgba(67, 142, 185, 0.15);
}

[data-theme="dark"] .ch-topic-title {
    color: #e2e8f0;
}

[data-theme="dark"] .ch-topic-content {
    color: #94a3b8;
}

[data-theme="dark"] .ch-tour-label {
    color: #e2e8f0;
}

[data-theme="dark"] .ch-tour-status {
    background: #334155;
    color: #94a3b8;
}

[data-theme="dark"] .ch-tour-progress-bar {
    background: #334155;
}

[data-theme="dark"] .ch-tip-popover {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .ch-tip-popover-title {
    color: #f1f5f9;
}

[data-theme="dark"] .ch-tip-popover-content {
    color: #94a3b8;
}

[data-theme="dark"] .ch-header-btn {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

[data-theme="dark"] .ch-header-btn:hover {
    background: #334155;
    color: #e2e8f0;
}

/* ==========================================================================
   7. RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .ch-panel {
        width: 100vw;
        right: -100vw;
    }

    .ch-panel-overlay--visible {
        display: block;
    }

    .ch-fab {
        bottom: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
    }

    .ch-fab svg {
        width: 20px;
        height: 20px;
    }

    .ch-header-btn span {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ch-panel {
        transition: none;
    }

    .ch-tip-popover {
        animation: none;
    }

    .ch-btn--pulse {
        animation: none;
    }
}
