// CodePress default theme styles
// Compiled at runtime by ThemeManager (scssphp) into public/themes/default/theme.css

// Theme color variables (defined per theme; used by the CSS custom properties below)
$header-bg: #0a369d;
$header-font: #ffffff;
$header-height: 56px;
$nav-bg: #2754b4;
$nav-font: #ffffff;
$nav-height: 42px;
$sidebar-bg: #f8f9fa;
$sidebar-border: #dee2e6;

// Search input styling - override header white text
#site-header .search-input {
    background-color: #ffffff !important;
    color: #212529 !important;
    border: 2px solid #0a369d !important;
}
#site-header .search-input::placeholder {
    color: #6c757d !important;
}
#site-header .search-input:focus {
    background-color: #ffffff !important;
    color: #212529 !important;
    border-color: #2754b4 !important;
    box-shadow: 0 0 0 0.2rem rgba(10, 54, 157, 0.25) !important;
}

// Optional header background image and overlay opacity
$header-bg-image: none;
$header-bg-opacity: 1;

:root {
    --header-bg: #{$header-bg};
    --header-font: #{$header-font};
    --header-height: #{$header-height};
    --nav-bg: #{$nav-bg};
    --nav-font: #{$nav-font};
    --nav-height: #{$nav-height};
    --sidebar-bg: #{$sidebar-bg};
    --sidebar-border: #{$sidebar-border};
}

// Header background (optional background image via $header-bg-image)
#site-header {
    background-image: $header-bg-image;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

@if $header-bg-image != 'none' {
    #site-header::before {
        content: '';
        position: absolute;
        inset: 0;
        background-color: var(--header-bg);
        opacity: $header-bg-opacity;
        pointer-events: none;
        z-index: 0;
    }
}

// Header styles
.navbar {
    background-color: var(--header-bg) !important;
    min-height: var(--header-height);

    .navbar-brand,
    .navbar-text,
    .btn {
        color: var(--header-font) !important;
    }
    
    .form-control {
        color: var(--header-font) !important;
    }
    
    .form-control::placeholder {
        color: rgba(255, 255, 255, 0.7) !important;
    }
    
    // Search input - override with dark text on white background
    .search-input {
        background-color: #ffffff !important;
        color: #212529 !important;
        border: 2px solid #0a369d !important;
    }
    
    .search-input::placeholder {
        color: #6c757d !important;
        opacity: 1 !important;
    }
    
    .search-input:focus {
        background-color: #ffffff !important;
        color: #212529 !important;
        border-color: #2754b4 !important;
        box-shadow: 0 0 0 0.2rem rgba(10, 54, 157, 0.25) !important;
    }

    .btn-outline-light {
        border-color: var(--header-font) !important;
    }
}

// Dropdown menu styling — override Bootstrap variables completely
.dropdown-menu {
    --bs-dropdown-min-width: 0;
    --bs-dropdown-padding-x: 0;
    --bs-dropdown-padding-y: 0;
    --bs-dropdown-border-width: 0;
    --bs-dropdown-border-radius: 0;
    --bs-dropdown-box-shadow: none;
    background-color: var(--header-bg) !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 0 !important;
    box-shadow: none !important;
    width: max-content;
}

.dropdown-item {
    color: var(--header-font) !important;
    border-radius: 0 !important;
    padding: 0.4rem 1rem;
    white-space: nowrap;
    display: block;
    width: 100%;

    &:hover, &:focus {
        background-color: rgba(255, 255, 255, 0.1) !important;
        color: var(--header-font) !important;
    }
}

// Remove Bootstrap dropdown border/spacing on nav-tabs dropdown
.nav-tabs .dropdown-menu {
    margin-top: 0 !important;
}

// Hide Bootstrap dropdown arrow and use custom icon
.dropdown-toggle::after {
    display: none !important;
}

.btn-outline-light {
    color: var(--header-font) !important;
    border-color: var(--header-font) !important;

    &:hover {
        background-color: rgba(255, 255, 255, 0.1) !important;
        color: var(--header-font) !important;
    }

    &:focus,
    &:active,
    .show > &.dropdown-toggle {
        background-color: rgba(255, 255, 255, 0.1) !important;
        color: var(--header-font) !important;
        border-color: var(--header-font) !important;
        box-shadow: none !important;
    }
}

.bi-chevron-down {
    font-size: 0.75em;
    margin-left: 0.25rem;
}

// Remove Bootstrap default breadcrumb separators
.breadcrumb-item + .breadcrumb-item::before {
    content: "" !important;
    padding: 0 !important;
}

// Custom breadcrumb styling
.breadcrumb {
    --bs-breadcrumb-divider: "";
    --bs-breadcrumb-margin-bottom: 0;
    margin-bottom: 0;

    .breadcrumb-item {
        color: var(--header-bg) !important;

        a {
            color: var(--header-bg) !important;
            text-decoration: none;

            &:hover {
                text-decoration: underline;
            }
        }
    }
}

// Sidebar toggle button in breadcrumb
.sidebar-toggle-item {
    display: flex;
    align-items: center;
    margin-right: 0.5rem;
}

.sidebar-toggle-btn {
    padding: 0;
    line-height: 1;
    font-size: 1.1rem;
    color: var(--header-bg) !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer;

    &:hover {
        opacity: 0.7;
    }
}

// Sidebar hide/show transition
.sidebar-column {
    transition: all 0.3s ease;
}

.sidebar-hidden {
    display: none !important;
}

// Navigation section background
.navigation-section {
    background-color: var(--nav-bg) !important;
    color: var(--nav-font) !important;
    min-height: var(--nav-height);
}

// Enhanced accessibility styles
.focus-visible:focus,
.btn:focus,
.form-control:focus {
    outline: 3px solid #0056b3 !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 1px #ffffff, 0 0 0 4px #0056b3 !important;
}

// High contrast mode support
@media (prefers-contrast: high) {
    :root {
        --text-color: #000000;
        --bg-color: #ffffff;
        --border-color: #000000;
        --focus-color: #000000;
    }

    .btn-primary {
        background-color: #000000 !important;
        border-color: #000000 !important;
        color: #ffffff !important;
    }

    .btn-outline-light {
        color: #000000 !important;
        border-color: #000000 !important;
    }

    .text-muted {
        color: #000000 !important;
    }

    .navbar {
        background-color: #ffffff !important;
        border-bottom: 1px solid #000000 !important;
    }
}

// Reduced motion support
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

// Navigation tabs — completely override Bootstrap nav-tabs styling
.nav-tabs {
    --bs-nav-tabs-border-width: 0 !important;
    --bs-nav-tabs-border-color: transparent !important;
    --bs-nav-tabs-border-radius: 0 !important;
    --bs-nav-tabs-link-hover-border-color: transparent !important;
    --bs-nav-tabs-link-active-color: var(--nav-font) !important;
    --bs-nav-tabs-link-active-bg: transparent !important;
    --bs-nav-tabs-link-active-border-color: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-bottom: none !important;
    border-radius: 0 !important;
    gap: 0 !important;

    .nav-link {
        margin-bottom: 0 !important;
        background-color: transparent !important;
        border: none !important;
        border-top-left-radius: 0 !important;
        border-top-right-radius: 0 !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        color: var(--nav-font) !important;
        outline: none !important;
        box-shadow: none !important;

        &:hover, &:focus, &:focus-visible {
            isolation: auto;
            background-color: rgba(255, 255, 255, 0.1) !important;
            border: none !important;
            border-color: transparent !important;
            outline: none !important;
            box-shadow: none !important;
        }

        &.active {
            background-color: rgba(255, 255, 255, 0.2) !important;
            border: none !important;
            border-color: transparent !important;
            border-bottom: 2px solid var(--nav-font) !important;
            outline: none !important;
            box-shadow: none !important;
        }
    }

    .dropdown-menu {
        margin-top: 0 !important;
        border-top-left-radius: 0 !important;
        border-top-right-radius: 0 !important;
    }
}

// Bootstrap 5 nested dropdown support (dropdown-submenu) — unlimited depth, CSS hover
.dropdown-submenu {
    position: relative;

    > .dropdown-menu {
        top: 0;
        left: 100%;
        margin-top: 0;
        margin-left: 0;
        display: none;
        --bs-dropdown-border-width: 0;
        --bs-dropdown-border-radius: 0;
        --bs-dropdown-box-shadow: none;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        width: max-content;
    }

    // Open submenu on hover (desktop)
    &:hover > .dropdown-menu {
        display: block;
    }

    // Keep parent highlighted when hovering submenu
    &:hover > .dropdown-toggle {
        background-color: rgba(255, 255, 255, 0.15) !important;
    }

    // Arrow pointing right — vertically centered with text
    > .dropdown-toggle {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;

        .bi-chevron-right {
            flex-shrink: 0;
            font-size: 0.7rem;
        }
    }
}

// Mobile: submenu appears below instead of beside, open on tap
@media (max-width: 767.98px) {
    .dropdown-submenu > .dropdown-menu {
        left: 0;
        top: 100%;
        margin-top: 0;
        margin-left: 1rem;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none;
    }
    .dropdown-submenu:hover > .dropdown-menu {
        display: none;
    }
    .dropdown-submenu.show > .dropdown-menu {
        display: block;
    }
}

// Sidebar styling
.sidebar-column {
    background-color: var(--sidebar-bg) !important;
    border-right: 1px solid var(--sidebar-border) !important;
    position: sticky;
    top: 0;
    min-height: calc(100vh - var(--header-height) - var(--nav-height) - 42px);
}

.sidebar {
    padding: 1.5rem;
    height: 100%;
    overflow-y: auto;
}

.content-column {
    background-color: #ffffff;
}

.content-wrapper {
    padding: 2rem;
    padding-bottom: 80px !important;
}

// Ensure full height layout - footer stays at bottom
.main-content {
    flex: 1;
    min-height: auto;
}

// Mobile responsive
@media (max-width: 767.98px) {
    .sidebar-column {
        border-right: none !important;
        border-top: 1px solid var(--sidebar-border) !important;
        min-height: auto;
        margin-top: 1rem;
    }

    .content-column {
        background-color: #ffffff;
    }

    .content-wrapper {
        min-height: auto;
        padding-bottom: 2rem !important;
    }
}

// Tablet and mobile: sidebar below content
@media (max-width: 991.98px) {
    .sidebar-column {
        order: 2 !important;
    }

    .content-column {
        order: 1 !important;
    }
}

// Code block styling
pre {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid #dee2e6;
    margin-bottom: 1rem;

    code {
        background: none;
        padding: 0;
        color: #333;
        font-size: 0.85rem;
        line-height: 1.5;
    }
}

code {
    background: #e8e8e8;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.9em;
    color: #d63384;
}

// Footer icon hover effects
.footer-icon {
    color: #6c757d;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    display: inline-block;
    padding: 2px;

    &:hover {
        color: #0d6efd;
        transform: translateY(-1px);
    }

    &:active {
        transform: translateY(0);
    }

    &.guide:hover {
        color: #198754;
    }

    &.cms:hover {
        color: #dc3545;
    }

    &.git:hover {
        color: #6f42c1;
    }

    &.website:hover {
        color: #fd7e14;
    }
}
