:root {
    --cpam-z: 10000;
    --cpam-bg-from: #ffffff;
    --cpam-bg-to: #f5f5f5;
    --cpam-bg: linear-gradient(90deg, var(--cpam-bg-from), var(--cpam-bg-to));
    --cpam-color: #111111;
    --cpam-active: #ff6200;
    --cpam-badge: #ff4444;
    --cpam-h: 56px;
    --cpam-rounded: 8px;
    
    /* NOWE: Zmienne dla centralnego przycisku */
    --cpam-center-bg: #ff6200;
    --cpam-center-color: #ffffff;
}

/* WIDOK DESKTOP: Ukryj paski CPAM na dużych ekranach */
@media (min-width: 1025px) {
    #cpam-top-bar,
    #cpam-bottom-bar,
    .cpam-sidebar,
    .cpam-overlay {
        display: none !important;
    }
    /* Przywróć domyślny padding, gdy CPAM jest ukryty */
    body.cpam-enabled {
        padding-top: 0 !important; 
        padding-bottom: 0 !important;
    }
}

/* WIDOK MOBILE: Ukryj oryginalny nagłówek ClassiPress */
@media only screen and (max-width: 1024px) {
    /* To jest kluczowe dla pełnego zastąpienia nagłówka ClassiPress */
    body.cpam-mobile-view .main-navigation,
    body.cpam-mobile-view .site-header,
    body.cpam-mobile-view .title-bar,
    body.cpam-mobile-view #header, /* Wymuszenie ukrycia w ClassiPress */
    body.cpam-mobile-view #wrapper > header[role="banner"],
    body.cpam-mobile-view #header-wrap {
        display: none !important;
    }

    /* Ustawienie wysokości dla paska wtyczki */
    body.cpam-enabled {
        padding-top: calc(var(--cpam-h) + env(safe-area-inset-top, 0)) !important;
        padding-bottom: calc(var(--cpam-h) + env(safe-area-inset-bottom, 0)) !important;
        margin: 0;
        min-height: 100vh;
    }
}

#cpam-top-bar,
#cpam-bottom-bar {
    position: fixed;
    width: 100vw;
    height: var(--cpam-h);
    padding: 0 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--cpam-bg);
    color: var(--cpam-color);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    z-index: var(--cpam-z);
    transition: transform 0.3s ease-in-out, opacity 0.3s ease, background 0.3s ease;
    border-radius: var(--cpam-rounded) var(--cpam-rounded) 0 0;
    overflow: hidden;
    box-sizing: border-box;
    -webkit-backface-visibility: hidden;
}

#cpam-top-bar {
    top: env(safe-area-inset-top, 0);
    left: 0;
    right: 0;
}

#cpam-bottom-bar {
    bottom: env(safe-area-inset-bottom, 0);
    left: 0;
    right: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    z-index: calc(var(--cpam-z) + 1);
}

#cpam-top-bar.cpam-hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

#cpam-bottom-bar.cpam-hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

.cpam-brand {
    flex: 1;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
    padding: 0 0.5rem;
}

.cpam-brand .cpam-logo img {
    max-height: 30px;
    width: auto;
    vertical-align: middle;
}

.cpam-toggle,
.cpam-action {
    background: none;
    border: 0;
    padding: 0.5rem;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: inherit;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    overflow: hidden;
    transition: transform 0.2s ease, color 0.2s ease;
}

.cpam-toggle:active,
.cpam-action:active {
    transform: scale(1.1);
}

.cpam-action.cpam-active {
    color: var(--cpam-active);
}

.cpam-icon,
.cpam-svg {
    display: inline-block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    vertical-align: middle;
}

/* Styl dla awatara uzytkownika */
.cpam-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}


.cpam-svg {
    object-fit: contain;
}

.cpam-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: var(--cpam-badge);
    color: #fff;
    font-size: 0.65rem;
    width: 16px;
    height: 16px;
    line-height: 16px;
    border-radius: 50%;
    display: none;
    text-align: center;
}

.cpam-notifications[data-count]:not([data-count="0"]) .cpam-badge {
    display: block;
}

.cpam-search-form {
    flex: 1;
    margin: 0 0.5rem;
    max-width: 70%;
}

.cpam-search-form input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.cpam-search-form input:focus {
    border-color: var(--cpam-active);
    outline: none;
    box-shadow: 0 0 5px rgba(255, 98, 0, 0.3);
}

.cpam-sidebar {
    position: fixed;
    top: calc(var(--cpam-h) + env(safe-area-inset-top, 0));
    bottom: calc(var(--cpam-h) + env(safe-area-inset-bottom, 0));
    width: 280px;
    background: var(--cpam-bg-from); /* Użycie zmiennej tła */
    color: var(--cpam-color);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: calc(var(--cpam-z) - 1);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.cpam-right {
    right: 0;
    left: auto;
    transform: translateX(100%);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
}

body.cpam-left-open .cpam-left,
body.cpam-right-open .cpam-right {
    transform: translateX(0);
}

body.cpam-left-open .cpam-overlay,
body.cpam-right-open .cpam-overlay {
    display: block;
}

.cpam-menu {
    list-style: none;
    margin: 1rem 0;
    padding: 0;
}

.cpam-menu .cpam-item a {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s ease;
}

.cpam-menu .cpam-item a:hover,
.cpam-menu .cpam-item.current-menu-item a {
    background: rgba(0, 0, 0, 0.05);
}

.cpam-menu .cpam-icon {
    margin-right: 0.75rem;
}

.cpam-bottom-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: center;
}

/* STYL DLA PRZYCISKU CENTRALNEGO - UZYCIE NOWYCH ZMIENNYCH */
.cpam-center {
    flex: 0 0 auto;
    padding: 0.5rem;
    background: var(--cpam-center-bg);
    color: var(--cpam-center-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    justify-content: center;
    align-items: center;
    margin: 0 1rem;
    display: flex;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 1;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Delikatny cień dla wyróżnienia */
}

.cpam-center:active {
    transform: scale(1.2);
}

.cpam-label {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    text-align: center;
    white-space: nowrap;
    color: var(--cpam-color); /* Etykieta bierze kolor tekstu */
    opacity: 0.7;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cpam-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.cpam-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 0.5rem;
    font-size: 0.8rem;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10001;
}

.cpam-tooltip.active {
    opacity: 1;
    transform: translateY(0);
}

.cpam-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--cpam-z) - 2);
    cursor: pointer;
    aria-hidden: true;
}

/* Tryb Ciemny */
@media (prefers-color-scheme: dark), body.cpam-dark-mode {
    body:not(.cpam-dark-mode-off) #cpam-top-bar,
    body:not(.cpam-dark-mode-off) #cpam-bottom-bar {
        background: #1c2526;
        color: #ffffff;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    }
    body:not(.cpam-dark-mode-off) .cpam-sidebar {
        background: #1c2526;
        color: #ffffff;
    }
    body:not(.cpam-dark-mode-off) .cpam-menu .cpam-item a:hover,
    body:not(.cpam-dark-mode-off) .cpam-menu .cpam-item.current-menu-item a {
        background: rgba(255, 255, 255, 0.1);
    }
    body:not(.cpam-dark-mode-off) .cpam-search-form input {
        background: #2c3536;
        color: #ffffff;
        border-color: #444;
    }
    body:not(.cpam-dark-mode-off) .cpam-label {
        color: #bbb;
    }
    body:not(.cpam-dark-mode-off) .cpam-center {
        /* Wymuszamy, by kolor i tło centrum były spójne, chyba że admin użyje bardzo jasnego koloru w ustawieniach */
        background: var(--cpam-center-bg);
        color: var(--cpam-center-color);
    }
}

/* Responsywność */
@media (max-width: 320px) {
    .cpam-bottom-actions {
        gap: 3px;
    }
    .cpam-icon {
        font-size: 16px;
    }
    .cpam-sidebar {
        width: 240px;
    }
    .cpam-center {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    .cpam-label {
        font-size: 0.7rem;
        max-width: 50px;
    }
}

@media (min-width: 481px) {
    .cpam-bottom-actions {
        gap: 15px;
    }
    .cpam-icon {
        font-size: 22px;
    }
    .cpam-sidebar {
        width: 300px;
    }
    .cpam-center {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
}