body {
    overflow-x: hidden;
}

body, h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6, table, th, td {
    font-family: var(--bs-body-font-family) !important;
}

/* Sidebar Styles */
#sidebar-wrapper {
    height: 100vh;
    width: 250px;
    margin-left: -250px;
    transition: margin 0.25s ease-out;
    background-color: var(--sidebar-bg);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none; /* Firefox: hide by default */
    display: flex;
    flex-direction: column;
}

#sidebar-wrapper:hover {
    scrollbar-width: thin; /* Firefox: show on hover */
}

/* Custom Scrollbar for WebKit (Chrome, Safari, Edge) */
#sidebar-wrapper::-webkit-scrollbar {
    width: 4px;
    display: none; /* Hide by default */
}

#sidebar-wrapper:hover::-webkit-scrollbar {
    display: block; /* Show on hover */
}

#sidebar-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar-wrapper::-webkit-scrollbar-thumb {
    background-color: var(--bs-secondary);
    border-radius: 10px;
}

#sidebar-wrapper::-webkit-scrollbar-thumb:hover {
    background-color: var(--bs-primary);
}

.app-version {
    font-family: 'Consolas', 'Monaco', 'Lucida Console', 'Courier New', monospace;
    font-size: 0.55rem;
    color: var(--text-muted-on-dark);
    letter-spacing: 0.05rem;
    margin-top: -5px;
    margin-bottom: 5px;
}

#sidebar-wrapper .sidebar-heading {
    height: 70px;
    padding: 0 1.5rem;
    color: var(--text-on-dark);
    position: relative;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: center;
    align-items: center;
}

#sidebar-wrapper .sidebar-heading::after {
    content: '';
    position: absolute;
    bottom: -1px;
    width: 80%;
    left: 10%;
    /* Center the line */
    height: 1px;
    background-color: var(--primary-accent);
}

#sidebar-wrapper .sidebar-divider {
    width: 80%;
    margin: 1rem auto;
    border-top: 1px solid var(--primary-accent);
    opacity: 1;
}

#sidebar-wrapper .list-group {
    width: 250px;
}

#sidebar-wrapper .list-group-item {
    background-color: transparent;
    color: var(--text-on-dark);
    opacity: 0.75;
    border: none;
    padding: 10px 24px;
    width: 100%;
    margin: 0;
    border-radius: 0;
    font-weight: 400; /* Regular zgodnie z Brand Bookiem */
    transition: all 0.2s ease-in-out;
    text-align: left;
    display: flex;
    align-items: center;
    position: relative;
    border-left: 3px solid transparent;
    font-size: 0.9rem;
}

#sidebar-wrapper .list-group-item i {
    font-size: 1.1rem;
    margin-right: 12px;
    width: 24px;
    text-align: center;
    transition: color 0.2s ease-in-out;
    color: var(--text-muted-on-dark);
}

#sidebar-wrapper .list-group-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-on-dark);
    opacity: 1;
    text-decoration: none;
    border-left: 3px solid var(--primary-accent-border);
}

#sidebar-wrapper .list-group-item:hover i {
    color: var(--primary-accent);
}

#sidebar-wrapper .list-group-item.active {
    background-color: var(--primary-accent-transparent);
    color: var(--text-on-dark);
    opacity: 1;
    font-weight: 700; /* Bold dla zachowania 2 poziomów różnicy względem 400 */
    border-left: 3px solid var(--primary-accent);
}

#sidebar-wrapper .list-group-item.active i {
    color: var(--primary-accent);
}

/* Accordion Header Styles */
#sidebar-wrapper .sidebar-section-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

#sidebar-wrapper .sidebar-section-header:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

#sidebar-wrapper .sidebar-section-header .chevron-icon {
    font-size: 0.7rem;
    transition: transform 0.3s ease-in-out;
    opacity: 0.5;
}

#sidebar-wrapper .sidebar-section-header:not(.collapsed) .chevron-icon {
    transform: rotate(180deg);
}

#sidebar-wrapper .sidebar-section-header.active i:first-child {
    color: var(--primary-accent) !important;
}

#sidebar-wrapper .sub-menu .list-group-item {
    font-size: 0.85rem;
    padding-left: 40px;
    border-left: none;
}

#sidebar-wrapper .sub-menu .list-group-item:hover,
#sidebar-wrapper .sub-menu .list-group-item.active {
    border-left: none;
    background-color: rgba(0, 0, 0, 0.02);
}

/* Content Wrapper */
#page-content-wrapper {
    width: 100%;
    transition: all 0.25s ease-out;
}

/* Show sidebar on desktop */
@media (min-width: 768px) {
    #sidebar-wrapper {
        margin-left: 0;
    }

    #page-content-wrapper {
        margin-left: 250px;
        width: calc(100% - 250px);
    }
}

/* Toggled state for mobile (show) or desktop (hide - not implemented but possible) */
#wrapper.toggled #sidebar-wrapper {
    margin-left: 0;
}

/* Top Bar */
.top-bar {
    background-color: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-light);
    box-shadow: 0 2px 4px rgba(0,0,0,0.01);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.user-info-section {
    display: flex;
    align-items: center;
}

.user-avatar {
    font-size: 2rem;
    color: var(--bs-secondary);
    margin-right: 10px;
}

.user-details {
    line-height: normal;
    text-align: left;
}

.user-name {
    font-weight: bold;
    font-size: 1.1rem;
    display: block;
}

.user-email {
    font-size: 0.8rem;
    color: var(--bs-secondary);
    display: block;
}


/* Refactored Inline Styles */
.sidebar-close-btn {
    font-size: 1.3rem;
    color: var(--text-muted-on-dark);
    text-decoration: none;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    padding: 0;
    border: none;
    background: transparent;
    transition: color 0.3s ease, transform 0.3s ease;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-close-btn:hover {
    color: var(--primary-accent);
    transform: translateY(-50%) scale(1.1);
}

.sidebar-close-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.sidebar-logo-container {
    padding: 1.5rem 1rem;
}

.sidebar-logo {
    max-height: 100px;
    width: 150px;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .sidebar-logo-container {
        padding: 1rem 0.5rem;
    }
    .sidebar-logo {
        width: 120px;
    }
}

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05rem;
    color: var(--text-dim-on-dark) !important;
    padding: 0.75rem 24px !important;
    margin-top: 0.5rem !important;
    text-transform: uppercase;
}

.disabled-sidebar-header {
    cursor: not-allowed !important;
    opacity: 0.6;
}

.app-version {
    font-size: 0.55rem;
    color: var(--text-muted-on-dark);
    margin-top: 5px;
    margin-bottom: 0px;
}

.text-inherit {
    color: inherit;
}


/* Logo Placeholder Styles (przeniesione z base.html) */
.placeholder-logo-display {
    font-size: 3.5rem;
    font-weight: 800;
    text-transform: lowercase;
    letter-spacing: -2px;
    user-select: none;
    display: inline-block;
}
.placeholder-logo-display .highlight { color: var(--bs-body-color); }
.placeholder-logo-display .dot { color: var(--primary-accent); display: inline-block; }
.placeholder-logo-display .suffix {
    color: var(--primary-accent);
    font-weight: 400;
    margin-left: 2px;
    text-transform: none;
    letter-spacing: 0;
}
.content-area-placeholder {
    height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.1;
}

/* Custom Dark Table Headers */
.thead-miellec-dark th {
    background-color: var(--sidebar-bg) !important;
    color: var(--text-on-dark) !important;
    border-bottom: 2px solid var(--border-accent) !important;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05rem;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
}

/* Sidebar Footer & AI Assistant Pill Button */
.sidebar-footer {
    padding: 0 15px; /* Dopasowanie marginesów bocznych */
    margin-top: 1rem;
}

.ai-assistant-pill-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding: 12px 16px;
    background: transparent; /* Ghost style */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-muted-on-dark) !important;
    text-decoration: none !important;
    transition: all 0.3s ease-in-out !important;
    width: 100%;
}

.ai-assistant-pill-btn:hover {
    background: rgba(255, 255, 255, 0.03); /* Ekstremalnie delikatna poświata */
    color: var(--primary-accent) !important;
    border-color: var(--primary-accent-border);
    transform: translateX(5px);
}

.ai-assistant-pill-btn:active {
    transform: scale(0.98);
}

.ai-assistant-pill-btn i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    margin-right: 15px;
    color: inherit; /* Ikona dziedziczy kolor (dla zmiany na pomarańczowy) */
    transition: transform 0.3s ease-in-out, color 0.3s ease-in-out;
}

.ai-assistant-pill-btn:hover i {
    transform: scale(1.1);
    color: var(--primary-accent);
}

/* Fix for Sidebar items in flex container */
#sidebar-wrapper .list-group {
    flex-grow: 1;
}

/* Chatwoot Coordination Fallback */
.chatwoot-hidden-fallback {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
}

/* Chatbot Mobile Responsiveness (RWD) */
@media (max-width: 768px) {
    #chatbot-container {
        width: 100% !important;
        max-width: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        bottom: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        overscroll-behavior: contain;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Wyższy nagłówek dla łatwiejszej obsługi dotykowej */
    #chatbot-container .bg-dark.p-3 {
        padding: 1rem 1.25rem !important;
        height: 60px;
        display: flex;
        align-items: center;
    }

    /* Powiększony przycisk zamknięcia (min 44x44px target) */
    #chatbot-close-btn {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem !important;
    }

    #chatbot-messages {
        padding-bottom: 20px !important;
    }

    /* Pole wprowadzania na dole (z marginesem bezpieczeństwa "breathing room") */
    #chatbot-container .p-2.border-top {
        padding-left: 12px !important;
        padding-right: calc(14px + env(safe-area-inset-right)) !important;
        padding-bottom: calc(14px + env(safe-area-inset-bottom)) !important;
        padding-top: 12px !important;
        box-sizing: border-box !important;
    }
}

.x-small {
    font-size: 0.75rem;
}

/* Helper Classes */
.miellec-trapeze {
    background-color: var(--bs-primary);
    clip-path: polygon(0 0, 100% 0, 85% 100%, 0% 100%);
    position: relative;
    display: inline-block;
    padding: 5px 20px 5px 15px;
    color: var(--bs-body-color);
    font-weight: 700;
}

.miellec-underline {
    position: relative;
    display: inline-block;
}

.miellec-underline::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--bs-primary);
    border-radius: 2px;
}

/* Utilities for responsive widths */
@media (min-width: 768px) {
    .w-md-auto {
        width: auto !important;
    }
}

/* Page Header Panel Styles (Unified System Header) */
.page-header-panel {
    background: transparent;
    margin-bottom: 1.5rem;
}

.page-header-panel h1 {
    font-weight: 700;
    color: var(--bs-dark);
    margin-bottom: 0.25rem;
    transition: font-size 0.2s ease;
}

.page-header-panel .info-text {
    color: var(--bs-secondary);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
}

@media (max-width: 767.98px) {
    .page-header-panel {
        margin-bottom: 1rem;
    }
    .page-header-panel h1 {
        font-size: 1.4rem;
    }
    /* Info text is hidden on mobile by default in component, but we ensure style consistency here */
    .page-header-panel .info-text {
        font-size: 0.8rem;
    }
}
