/* ============================================================================
   Help Widget - Floating help documentation for admins
   ============================================================================ */

/* Floating Help Button (below patch notes button) */
.help-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--wme-blue);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
    z-index: 1000;
}

/* Shift help button up when upload dialog/progress is visible */
.help-button.shifted-up {
    bottom: 100px;
}

/* Shift help button further up when progress panel is expanded */
.help-button.shifted-up-expanded {
    bottom: 400px;
}

.help-button:hover {
    background: var(--wme-accent);
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.help-button:active {
    transform: scale(0.95);
}

/* Help Button Tooltip/Chat Bubble */
.help-tooltip {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: white;
    color: #333;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}

/* Shift tooltip up when help button is shifted */
.help-tooltip.shifted-up {
    bottom: 170px;
}

/* Shift tooltip further up when progress panel is expanded */
.help-tooltip.shifted-up-expanded {
    bottom: 470px;
}

.help-tooltip::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 18px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid white;
}

.help-tooltip.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.help-tooltip.hide {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
}

/* Backdrop Overlay */
.help-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1001;
}

.help-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Help Panel */
.help-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--bg);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
    transition: right 0.3s ease;
    z-index: 1002;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.help-panel.active {
    right: 0;
}

/* Panel Header */
.help-header {
    background: var(--wme-blue);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.help-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.help-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.help-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Search Box */
.help-search {
    padding: 16px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

.help-search input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.help-search input:focus {
    outline: none;
    border-color: var(--wme-blue);
    box-shadow: 0 0 0 3px rgba(20, 99, 184, 0.1);
}

.help-search-wrapper {
    position: relative;
}

.help-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 14px;
    pointer-events: none;
}

/* Content Area */
.help-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.help-content::-webkit-scrollbar {
    width: 8px;
}

.help-content::-webkit-scrollbar-track {
    background: var(--bg-alt);
}

.help-content::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 4px;
}

.help-content::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

/* Section */
.help-section {
    margin-bottom: 8px;
}

.help-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-alt);
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.help-section-header:hover {
    background: var(--line);
    border-color: var(--wme-blue);
}

.help-section-header.active {
    background: var(--wme-blue);
    border-color: var(--wme-blue);
    color: white;
}

.help-section-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.help-section-title {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
}

.help-section-toggle {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.help-section-header.active .help-section-toggle {
    transform: rotate(180deg);
}

/* Section Items */
.help-section-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 4px;
}

.help-section-items.active {
    max-height: 2000px; /* Large enough for content */
}

/* Item */
.help-item {
    padding: 10px 12px;
    margin: 6px 0;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.help-item:hover {
    background: var(--bg-alt);
    border-color: var(--wme-blue);
}

.help-item.active {
    background: var(--bg-alt);
    border-color: var(--wme-blue);
}

.help-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-item-title i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.help-item.active .help-item-title i {
    transform: rotate(180deg);
}

.help-item-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    color: var(--ink);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.help-item.active .help-item-content {
    max-height: 2000px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.help-item-content strong {
    font-weight: 600;
    color: var(--ink);
}

[data-theme="dark"] .help-item-content strong {
    color: var(--wme-blue);
    font-weight: 600;
}

/* Internal Links */
.help-internal-link {
    color: var(--wme-blue);
    text-decoration: none;
    border-bottom: 1px dotted var(--wme-blue);
    cursor: pointer;
    transition: all 0.2s ease;
}

.help-internal-link:hover {
    color: var(--wme-accent);
    border-bottom-style: solid;
    border-bottom-color: var(--wme-accent);
}

[data-theme="dark"] .help-internal-link {
    color: #64b5f6;
    border-bottom-color: #64b5f6;
}

[data-theme="dark"] .help-internal-link:hover {
    color: #90caf9;
    border-bottom-color: #90caf9;
}

/* Highlighted Search Results */
.help-highlight {
    background: #ffeb3b;
    color: #000;
    padding: 2px 4px;
    border-radius: 2px;
}

[data-theme="dark"] .help-highlight {
    background: #fbc02d;
    color: #000;
}

/* No Results */
.help-no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}

.help-no-results i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

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

/* Loading State */
.help-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--muted);
}

.help-loading i {
    font-size: 32px;
    animation: spin 1s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .help-panel {
        right: -100%;
        width: 100%;
    }

    .help-panel.active {
        right: 0;
    }

    .help-button {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
        font-size: 22px;
    }
}

/* Dark Mode Specific Adjustments */
[data-theme="dark"] .help-button {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .help-panel {
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .help-search input {
    background: var(--bg-alt);
}

[data-theme="dark"] .help-section-header {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .help-section-header:hover {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .help-item {
    background: rgba(255, 255, 255, 0.02);
}

[data-theme="dark"] .help-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Screenshot Thumbnails */
.help-screenshot-container {
    margin: 4px 0;
    text-align: center;
    display: block;
}

.help-screenshot-thumb {
    max-width: 320px;
    width: 100%;
    height: auto;
    border: 2px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    margin: 0 auto;
}

.help-screenshot-thumb:hover {
    border-color: var(--wme-blue);
    box-shadow: 0 4px 12px rgba(20, 99, 184, 0.2);
    transform: scale(1.02);
}

[data-theme="dark"] .help-screenshot-thumb {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .help-screenshot-thumb:hover {
    border-color: var(--wme-blue);
    box-shadow: 0 4px 12px rgba(100, 181, 246, 0.3);
}

.help-screenshot-caption {
    display: none;
}

/* Image Modal */
.help-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    box-sizing: border-box;
}

.help-image-modal.active {
    display: flex;
}

.help-image-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    animation: modalZoomIn 0.3s ease;
}

@keyframes modalZoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.help-image-modal img {
    max-width: 100%;
    max-height: 85vh;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.help-image-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s ease;
}

.help-image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.help-image-modal-caption {
    position: absolute;
    bottom: -35px;
    left: 0;
    right: 0;
    text-align: center;
    color: white;
    font-size: 14px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Responsive Modal */
@media (max-width: 768px) {
    .help-image-modal {
        padding: 10px;
    }

    .help-image-modal img {
        max-height: 80vh;
    }

    .help-image-modal-close {
        top: 10px;
        right: 10px;
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .help-image-modal-caption {
        bottom: 10px;
        font-size: 12px;
    }
}

/* Print Hide */
@media print {
    .help-button,
    .help-panel,
    .help-backdrop,
    .help-image-modal {
        display: none !important;
    }
}
