/* Custom Theme for AI Powered UserScript Studio */
/* Matches the extension's color schemes */

:root {
    /* Light Blue Theme (Default for now, changes to dark-purple on load) */
    --theme-hue: 200;
    --theme-saturation: 85%;
    --theme-lightness: 53%;

    /* Custom colors */
    --custom-primary: #0ea5e9;
    --custom-bg: #ffffff;
    --custom-text: #1e293b;
    --custom-text-anchor: #1e297b;
    --custom-sidebar-bg: #f8fafc;
    --custom-border: #f1f5f9;
}

/* Dark Purple Theme */
[data-theme="dark-purple"] {
    --custom-primary: #8b5cf6;
    --custom-bg: #1e1b31;
    --custom-text: #e5e7eb;
    --custom-text-anchor: #75e7fb;
    --custom-sidebar-bg: #252140;
    --custom-border: #2d2748;

    /* Override docsify theme color */
    --theme-color: #8b5cf6;
    --theme-hue: 258;
    --theme-saturation: 85%;
    --theme-lightness: 66%;
}

/* Deep Onyx Theme */
[data-theme="deep-onyx"] {
    --custom-primary: #06b6d4;
    --custom-bg: #000000;
    --custom-text: #ffffff;
    --custom-sidebar-bg: #1a1a1a;
    --custom-border: #333333;

    --theme-color: #06b6d4;
    --theme-hue: 187;
    --theme-saturation: 95%;
    --theme-lightness: 43%;
}

/* Light Blue Theme */
[data-theme="light-blue"] {
    --custom-primary: #0ea5e9;
    --custom-bg: #ffffff;
    --custom-text: #1e293b;
    --custom-sidebar-bg: #f8fafc;
    --custom-border: #f1f5f9;

    --theme-color: #0ea5e9;
    --theme-hue: 200;
    --theme-saturation: 85%;
    --theme-lightness: 53%;
}

/* Apply theme colors to body and main elements */
body {
    background-color: var(--custom-bg) !important;
    color: var(--custom-text) !important;
    transition: background-color 0.3s ease, color 0.3s ease;
}

aside.sidebar {
    padding-top: 100px;
    background-color: var(--custom-sidebar-bg) !important;
    border-right-color: var(--custom-border) !important;
}

.sidebar-toggle {
    background-color: transparent !important;
}

.sidebar ul li a {
    color: var(--custom-text) !important;
}

.sidebar ul li a:hover {
    color: var(--custom-primary) !important;
}

.sidebar ul li.active > a {
    color: var(--custom-primary) !important;
    border-right: 3px solid var(--custom-primary) !important;
}

.app-name {
    color: var(--custom-text) !important;
}

.app-name-link img {
    width: 36px;
    height: 36px;
    margin-right: 8px;
}

/* Content area */
.markdown-section {
    color: var(--custom-text) !important;
}

body .markdown-section h1,
body .markdown-section h2,
body .markdown-section h3,
body .markdown-section h4,
body .markdown-section h5,
body .markdown-section h6,
body .markdown-section strong {
   color: var(--custom-text) !important;
}
.anchor span {
    color: var(--custom-text-anchor) !important;
}

.markdown-section a {
    color: var(--custom-primary) !important;
}

.markdown-section code {
    background-color: var(--custom-sidebar-bg) !important;
    color: var(--custom-primary) !important;
}

.markdown-section pre {
    background-color: var(--custom-sidebar-bg) !important;
    border: 1px solid var(--custom-border) !important;
}

.markdown-section pre code {
    color: var(--custom-text) !important;
}

.markdown-section blockquote {
    border-left-color: var(--custom-primary) !important;
    background-color: var(--custom-sidebar-bg) !important;
    color: var(--custom-text) !important;
}

.markdown-section table th {
    background-color: var(--custom-primary) !important;
    color: white !important;
}

.markdown-section table td {
    border-color: var(--custom-border) !important;
    color: var(--custom-text) !important;
}

.markdown-section tr:nth-child(even) {
    background-color: var(--custom-sidebar-bg) !important;
}

/* Search */
.search input {
    background-color: var(--custom-sidebar-bg) !important;
    border-color: var(--custom-border) !important;
    color: var(--custom-text) !important;
}

.search .results-panel {
    background-color: var(--custom-bg) !important;
    border: 1px solid var(--custom-border) !important;
}

.search .matching-post {
    border-bottom-color: var(--custom-border) !important;
}

.search .matching-post strong {
    color: var(--custom-primary) !important;
}

/* Copy code button */
.docsify-copy-code-button {
    background: var(--custom-primary) !important;
}

/* Theme switcher button */
.theme-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
}

.theme-button {
    background-color: var(--custom-sidebar-bg);
    border: 1px solid var(--custom-border);
    color: var(--custom-text);
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.theme-button:hover {
    background-color: var(--custom-primary);
    color: white;
    transform: rotate(45deg);
}

.theme-dropdown {
    position: absolute;
    top: 60px;
    right: 0;
    background-color: var(--custom-bg);
    border: 1px solid var(--custom-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 280px;
    padding: 12px;
    display: none;
}

.theme-dropdown.active {
    display: block;
}

.theme-dropdown-title {
    padding: 8px 12px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--custom-text);
}

.theme-option {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /*color: var(--custom-text);*/
}

.theme-option:hover {
    background-color: var(--custom-sidebar-bg);
}

.theme-option.selected {
    background-color: var(--custom-primary);
    color: white;
}

.theme-option-name {
    font-weight: 500;
}

.theme-option-badge {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 2px;
}

.theme-preview {
    display: flex;
    gap: 6px;
}

.theme-preview-circle {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Pagination */
.pagination-item-title {
    color: var(--custom-text) !important;
}

.pagination-item-label {
    color: var(--custom-primary) !important;
}

/* Sidebar Drawer Functionality */
.sidebar {
    transform: translateX(-300px) !important;
    transition: transform 0.3s ease-in-out !important;
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 300px !important;
}

.sidebar.open {
    transform: translateX(0) !important;
}

/* Hamburger menu button */
.hamburger-menu {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1002;
    background-color: var(--custom-sidebar-bg);
    border: 1px solid var(--custom-border);
    color: var(--custom-text);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.hamburger-menu:hover {
    background-color: var(--custom-primary);
    color: white;
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 20px;
}

.hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: currentColor;
    transition: all 0.3s ease;
}

.hamburger-menu.active .hamburger-icon span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.active .hamburger-icon span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .hamburger-icon span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Overlay for drawer */
.drawer-overlay {
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    height: 100%;
    left: 0;
    position: fixed;
    top: 0;
    transition: opacity 0.3s ease;
    width: 100%;
    z-index: 999;
}

.drawer-overlay.active {
    display: none;
}

/* Adjust sidebar z-index to appear above overlay */
.sidebar {
    z-index: 1000 !important;
}

/* Adjust content margin when sidebar is hidden */
.content {
    margin-left: 0 !important;
    transition: margin-left 0.3s ease;
}

/* Override Docsify's default mobile sidebar toggle */
.sidebar-toggle {
    display: none !important;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .theme-switcher {
        top: 10px;
        right: 10px;
    }

    .theme-dropdown {
        max-width: calc(100vw - 40px);
    }

    .hamburger-menu {
        top: 10px;
        left: 10px;
    }

    /* Ensure sidebar is still accessible on mobile */
    .sidebar {
        width: 280px !important;
    }

    /* Ensure content doesn't have any left margin on mobile */
    body .content {
        margin-left: 0 !important;
        padding-left: 15px;
        padding-right: 15px;
    }
}

/* For very small screens */
@media screen and (max-width: 480px) {
    .sidebar {
        width: 260px !important;
    }

    .hamburger-menu {
        width: 40px;
        height: 40px;
    }

    .theme-button {
        width: 40px;
        height: 40px;
    }
}

/* Smooth transitions */
* {
    transition-property: background-color, color, border-color;
    transition-duration: 0.3s;
    transition-timing-function: ease;
}
