/**
 * MadBot Sidebar Styles
 * Extracted from fullpage.php inline styles
 * 
 * @package MadBot
 * @version 1.0.0
 */

/* ============================================
   PRELOAD STATES - Prevent flash on page load
   Applied via inline script in <head> before CSS
   ============================================ */

/* Compact preload - apply immediately without transition */
.sidebar-compact-preload .sidebar {
    width: 60px !important;
    transition: none !important;
}

.sidebar-compact-preload .sidebar .sidebar-header h2,
.sidebar-compact-preload .sidebar .sidebar-header .tagline,
.sidebar-compact-preload .sidebar .sidebar-nav .sidebar-section-title,
.sidebar-compact-preload .sidebar .sidebar-nav .char-name,
.sidebar-compact-preload .sidebar .btn-explore span,
.sidebar-compact-preload .sidebar .sidebar-footer {
    opacity: 0 !important;
    visibility: hidden !important;
    transition: none !important;
}

.sidebar-compact-preload .sidebar .char-item {
    justify-content: center !important;
    padding: 8px !important;
}

/* Compact preload - logo switching */
.sidebar-compact-preload .sidebar .logo {
    display: none !important;
}

.sidebar-compact-preload .sidebar .logo-compact {
    display: flex !important;
    margin: 0 auto !important;
}

.sidebar-compact-preload .main-content {
    margin-left: 60px !important;
    transition: none !important;
}

/* Hidden preload - apply immediately without transition */
.sidebar-hidden-preload .sidebar {
    transform: translateX(-100%) !important;
    transition: none !important;
}

.sidebar-hidden-preload .main-content {
    margin-left: 0 !important;
    transition: none !important;
}

.sidebar-hidden-preload #sidebarExpand {
    display: flex !important;
}

/* ============================================
   END PRELOAD STATES
   ============================================ */

/* Sidebar Collapse System */
.sidebar-collapse-btn,
#sidebarCollapse {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    max-width: 28px !important;
    max-height: 28px !important;
    background: rgba(255,255,255,0.05) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    border-radius: 6px !important;
    cursor: pointer;
    color: var(--gray);
    transition: all 0.2s ease;
    z-index: 10;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
}

.sidebar-collapse-btn:hover,
#sidebarCollapse:hover {
    background: rgba(255,255,255,0.1) !important;
    color: var(--light) !important;
}

/* Light mode: collapse button */
.light-mode .sidebar-collapse-btn,
.light-mode #sidebarCollapse {
    background: rgba(0,0,0,0.05) !important;
    border: 1px solid rgba(0,0,0,0.1) !important;
    color: #64748B !important;
}

.light-mode .sidebar-collapse-btn:hover,
.light-mode #sidebarCollapse:hover {
    background: rgba(0,0,0,0.1) !important;
    color: #1E293B !important;
}

.sidebar-collapse-btn svg {
    width: 16px;
    height: 16px;
}

/* Sidebar states */
.sidebar {
    position: relative;
}

.sidebar-header {
    position: relative;
}

/* Compact mode - avatars only */
.sidebar.compact {
    width: 72px;
    min-width: 72px;
    overflow: visible;
}

.sidebar.compact .sidebar-header {
    padding: 56px 12px 12px 12px;
}

.sidebar.compact .sidebar-collapse-btn,
.sidebar.compact #sidebarCollapse {
    left: 50%;
    transform: translateX(-50%);
    right: auto;
}

.sidebar.compact .characters-section {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.sidebar.compact .characters-section::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

/* Compact logo - hidden by default, shown in compact mode */
.logo-compact {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: transparent;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.logo-compact img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-compact .logo-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--gradient);
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.sidebar.compact .logo,
.sidebar.compact .credits-display,
.sidebar.compact .section-title,
.sidebar.compact .character-info,
.sidebar.compact .upgrade-btn {
    display: none;
}

/* Show compact logo in compact mode */
.sidebar.compact .logo-compact {
    display: flex;
    margin: 0 auto;
}

.sidebar.compact .character-card {
    padding: 8px;
    justify-content: center;
    margin-bottom: 8px;
    background: transparent;
    position: relative;
    border: none;
}

.sidebar.compact .character-card:hover {
    background: rgba(255,255,255,0.05);
    transform: none;
}

.sidebar.compact .character-card.active {
    background: transparent;
    border: none;
    box-shadow: none;
}

/* Light mode compact: remove pink background on active */
.light-mode .sidebar.compact .character-card.active {
    background: transparent;
    border: none;
    box-shadow: none;
}

.sidebar.compact .character-avatar {
    width: 44px;
    height: 44px;
    filter: grayscale(100%) brightness(0.5);
    transition: filter 0.3s ease;
}

/* Light mode: grayscale only, no brightness reduction */
.light-mode .sidebar.compact .character-avatar {
    filter: grayscale(100%) brightness(1);
}

.sidebar.compact .character-card:hover .character-avatar,
.sidebar.compact .character-card.active .character-avatar {
    filter: grayscale(0%) brightness(1);
}

/* Compact mode badges - same styling as expanded */
.sidebar.compact .character-status {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-width: 2px;
}

.sidebar.compact .character-badge {
    position: absolute;
    bottom: -3px;
    right: -3px;
    width: 18px;
    height: 18px;
    border-width: 2px;
}

.sidebar.compact .character-badge svg {
    width: 10px;
    height: 10px;
}

.sidebar.compact .character-badge--nsfw {
    width: 20px;
    height: 20px;
    bottom: -4px;
    right: -4px;
}

.sidebar.compact .character-badge--nsfw svg {
    width: 20px;
    height: 20px;
}

.sidebar.compact .character-avatar img {
    width: 44px;
    height: 44px;
}

/* Category styles in compact mode */
.sidebar.compact .category-header {
    padding: 8px;
    justify-content: center;
}

.sidebar.compact .category-icon {
    font-size: 20px;
    cursor: pointer;
    transition: filter 0.3s ease;
}
.sidebar.compact .category-header:not(.expanded) .category-icon { filter: grayscale(100%) brightness(0.5); }
.sidebar.compact .category-header.expanded .category-icon,
.sidebar.compact .category-header:hover .category-icon { filter: none; }
.light-mode .sidebar.compact .category-header:not(.expanded) .category-icon { filter: grayscale(100%) brightness(1); }
.light-mode .sidebar.compact .category-header.expanded .category-icon,
.light-mode .sidebar.compact .category-header:hover .category-icon { filter: none; }

.sidebar.compact .category-name,
.sidebar.compact .category-count,
.sidebar.compact .category-arrow {
    display: none;
}

.sidebar.compact .category-group {
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
}

.sidebar.compact .category-group:last-child {
    border-bottom: none;
}

/* Tooltip for compact mode - hidden, use JS tooltip instead */
.sidebar.compact .character-card::after {
    display: none;
}

/* JS Tooltip */
.compact-tooltip {
    position: fixed;
    background: var(--dark);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--light);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.compact-tooltip.visible {
    display: block !important;
    opacity: 1;
}

/* Hidden mode - completely hidden */
.sidebar.hidden {
    width: 0;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border-right: none;
}

/* Expand button when hidden */
.sidebar-expand-btn {
    display: none;
    position: fixed;
    left: 0;
    top: 12px;
    width: 28px;
    height: 28px;
    background: var(--dark);
    border: 1px solid rgba(255,255,255,0.1);
    border-left: none;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    color: var(--gray);
    transition: all 0.2s ease;
    z-index: 1001;
    align-items: center;
    justify-content: center;
}

.sidebar-expand-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--light);
    width: 36px;
}

.sidebar-expand-btn svg {
    width: 16px;
    height: 16px;
}

.sidebar.hidden ~ .sidebar-expand-btn {
    display: flex;
}

/* Show expand button via JS class */
.sidebar-expand-btn.visible {
    display: flex !important;
}

/* ==========================================================================
   PROFILE MENU (oval button - top right)
   ========================================================================== */

#profileMenuBtn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--surface-color, rgba(255,255,255,0.05));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    color: var(--text-muted, #9ca3af);
    font-size: 18px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 20px;
    transition: all 0.2s;
    z-index: 1000;
}

#profileMenuBtn:hover {
    background: var(--card-hover, rgba(255,255,255,0.1));
}

#profileMenu {
    display: none;
    position: fixed;
    top: 58px;
    right: 20px;
    background: var(--surface-color, #1a1a24);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 12px;
    padding: 4px;
    min-width: 200px;
    box-shadow: 0 8px 24px var(--shadow-color, rgba(0,0,0,0.5));
    z-index: 1001;
}

#profileMenu button,
#profileMenu a.menu-custom-link {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-color, #f3f4f6);
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    transition: background 0.2s;
    text-decoration: none;
}

#profileMenu button:hover,
#profileMenu a.menu-custom-link:hover {
    background: var(--card-hover, rgba(255,255,255,0.1));
}

/* Menu separator styles are in menu.css */

/* Light mode: Profile Menu */
.light-mode #profileMenuBtn {
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    color: #64748B;
}

.light-mode #profileMenuBtn:hover {
    background: #F1F5F9;
}

.light-mode #profileMenu {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.light-mode #profileMenu button,
.light-mode #profileMenu a.menu-custom-link {
    color: #1E293B;
}

.light-mode #profileMenu button:hover,
.light-mode #profileMenu a.menu-custom-link:hover {
    background: #F1F5F9;
}

/* Theme toggle and menu-item-current styles are in menu.css */


/* Sidebar Create Button */
.sidebar-create-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 8px 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    overflow: hidden;
}

.sidebar-create-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: rgba(255, 255, 255, 0.9) !important;
}

.sidebar-create-btn .create-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1) !important;
    border-radius: 5px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    color: rgba(255, 255, 255, 0.8) !important;
    flex-shrink: 0;
    padding-bottom: 1px;
}

.sidebar-create-btn:hover .create-icon {
    background: rgba(255, 255, 255, 0.15) !important;
    color: white !important;
}

.sidebar-create-btn .create-label {
    white-space: nowrap;
    color: inherit;
    text-decoration: none;
    transition: color 0.15s ease;
}

.sidebar-create-btn .create-label:hover {
    color: white;
}

/* Create links inside button (always visible) */
.sidebar-create-btn .create-links {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.sidebar-create-btn .create-link {
    color: rgba(255, 255, 255, 0.6);
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s ease;
}

.sidebar-create-btn .create-link:hover {
    color: white;
}

.sidebar-create-btn .create-arrow {
    color: rgba(255, 255, 255, 0.35);
    font-size: 17px;
}

.sidebar-create-btn .create-separator {
    color: rgba(255, 255, 255, 0.25);
    font-size: 16px;
}

/* Compact mode */
.sidebar.compact .sidebar-create-btn {
    justify-content: center;
    margin: 12px 8px;
    padding: 10px;
}

.sidebar.compact .sidebar-create-btn .create-label,
.sidebar.compact .sidebar-create-btn .create-links {
    display: none;
}

.sidebar.compact .sidebar-create-btn .create-icon {
    width: 26px;
    height: 26px;
    font-size: 18px;
}

/* Light mode */
.light-mode .sidebar-create-btn {
    background: rgba(0, 0, 0, 0.03) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    color: rgba(0, 0, 0, 0.6) !important;
}

.light-mode .sidebar-create-btn:hover {
    background: rgba(0, 0, 0, 0.06) !important;
    border-color: rgba(0, 0, 0, 0.12) !important;
    color: rgba(0, 0, 0, 0.8) !important;
}

.light-mode .sidebar-create-btn .create-icon {
    background: rgba(0, 0, 0, 0.06) !important;
    color: rgba(0, 0, 0, 0.6) !important;
}

.light-mode .sidebar-create-btn:hover .create-icon {
    background: rgba(0, 0, 0, 0.1) !important;
    color: rgba(0, 0, 0, 0.8) !important;
}

.light-mode .sidebar-create-btn .create-label:hover {
    color: rgba(0, 0, 0, 0.9);
}

.light-mode .sidebar-create-btn .create-link {
    color: rgba(0, 0, 0, 0.5);
}

.light-mode .sidebar-create-btn .create-link:hover {
    color: rgba(0, 0, 0, 0.9);
}

.light-mode .sidebar-create-btn .create-arrow {
    color: rgba(0, 0, 0, 0.3);
}

.light-mode .sidebar-create-btn .create-separator {
    color: rgba(0, 0, 0, 0.25);
}


/* =====================================================
   SIDEBAR TABS (Featured / Favorites)
   ===================================================== */

.sidebar-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.sidebar-tab:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.sidebar-tab.active {
    background: var(--primary);
    color: white;
}

.sidebar-tab svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.favorites-count {
    background: var(--primary);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

.sidebar-tab.active .favorites-count {
    background: rgba(255,255,255,0.3);
}

/* Favorites Section */
.favorites-section {
    padding: 0;
}

.favorites-loading,
.favorites-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.favorites-loading svg {
    animation: spin 1s linear infinite;
}

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

.favorites-empty svg {
    color: var(--text-muted);
    opacity: 0.5;
}

.favorites-list {
    padding: 8px 0;
}

/* Favorites character cards (rendered via JS) */
.favorites-list .character-card {
    text-decoration: none;
    color: inherit;
}

.favorites-list .character-card .character-name {
    color: var(--text-color);
    font-weight: 600;
    font-size: 14px;
}

.favorites-list .character-card .character-tagline {
    color: var(--text-muted);
    font-size: 12px;
    text-decoration: none;
}

/* Favorite card with remove button */
.character-card.favorite-card {
    position: relative;
    margin-left: 12px;
    margin-right: 18px;
}

.character-card.favorite-card .remove-favorite-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    z-index: 5;
}

.character-card.favorite-card:hover .remove-favorite-btn {
    opacity: 1;
}

/* Show remove button on touch devices (no hover) */
@media (max-width: 1023px), (hover: none) {
    .character-card.favorite-card .remove-favorite-btn {
        opacity: 0.7;
    }
    
    .character-card.favorite-card .remove-favorite-btn:active {
        opacity: 1;
        background: #ef4444;
        color: white;
    }
}

.character-card.favorite-card .remove-favorite-btn:hover {
    background: #ef4444;
    color: white;
}

/* Compact mode adjustments */
.sidebar.compact .sidebar-tabs {
    flex-direction: column;
    padding: 8px 4px;
}

.sidebar.compact .sidebar-tab {
    padding: 8px;
}

.sidebar.compact .sidebar-tab span:not(.favorites-count) {
    display: none;
}

.sidebar.compact .favorites-count {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 9px;
    padding: 1px 4px;
}

.sidebar.compact .sidebar-tab {
    position: relative;
}

.sidebar.compact .remove-favorite-btn {
    display: none !important;
}


/* Explore Button */
.sidebar-explore-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 8px 12px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.sidebar-explore-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.sidebar-explore-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Light mode */
.light-mode .sidebar-explore-btn {
    border-color: rgba(0, 0, 0, 0.12);
}

.light-mode .sidebar-explore-btn:hover {
    border-color: var(--primary);
}

/* Compact mode */
.sidebar.compact .sidebar-explore-btn {
    justify-content: center;
    padding: 10px;
    margin: 8px 4px;
}

.sidebar.compact .sidebar-explore-btn span {
    display: none;
}
