/* Base styles for cookie banner and preferences */
#gcm-banner, #gcm-preferences {
    position: fixed;
    z-index: 9999;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    overflow: hidden;
    max-width: 100%;
}

/* Banner specific styles - modern bottom right positioning */
#gcm-banner {
    bottom: 20px;
    right: 20px;
    width: 380px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding: 24px;
    transform: translateY(20px);
    opacity: 0;
    animation: gcm-fade-in 0.5s forwards;
}

@keyframes gcm-fade-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#gcm-banner.gcm-show {
    opacity: 1;
    transform: translateY(0);
}

#gcm-banner p {
    margin: 12px 0 18px;
    width: 100%;
}

#gcm-banner a {
    text-decoration: underline;
    color: inherit;
    font-weight: 500;
    transition: opacity 0.2s;
}

#gcm-banner a:hover {
    opacity: 0.8;
}

#gcm-banner small {
    opacity: 0.7;
    font-size: 11px;
    align-self: flex-end;
    margin-bottom: 10px;
}

#gcm-banner img {
    align-self: center;
    margin-bottom: 15px;
}

/* Preferences panel styles - centered modal */
#gcm-preferences {
    display: none;
    flex-direction: column;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    background-color: #fff;
}

#gcm-preferences h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 20px;
}

#gcm-preferences > p {
    margin-bottom: 20px;
    opacity: 0.8;
}

.gcm-preferences-categories {
    width: 100%;
}

/* Modern toggle switch styling */
.gcm-preference-category {
    margin-bottom: 15px;
    padding: 15px;
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.03);
    transition: box-shadow 0.3s;
}

.gcm-preference-category:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.gcm-preference-category label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.gcm-preference-category label strong {
    flex-grow: 1;
}

/* Custom toggle switch */
.gcm-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.gcm-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.gcm-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 24px;
}

.gcm-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .gcm-toggle-slider {
    background-color: #0073aa;
}

input:checked + .gcm-toggle-slider:before {
    transform: translateX(20px);
}

input:disabled + .gcm-toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.gcm-category-description {
    margin-top: 8px;
    font-size: 0.9em;
    opacity: 0.8;
    padding-right: 44px; /* Space for toggle */
}

/* Button styles */
.gcm-banner-buttons, .gcm-preferences-buttons {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 20px;
    flex-wrap: wrap;
}

#gcm-banner button, #gcm-preferences button {
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    outline: none;
    min-width: 120px;
}

#gcm-banner button.primary-button, 
#gcm-preferences button.primary-button {
    background: #0073aa;
    color: white;
}

#gcm-banner button.primary-button:hover, 
#gcm-preferences button.primary-button:hover {
    background: #005a87;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#gcm-banner button.secondary-button, 
#gcm-preferences button.secondary-button {
    background-color: transparent;
    color: inherit;
    border: 1px solid currentColor;
}

#gcm-banner button.secondary-button:hover, 
#gcm-preferences button.secondary-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

/* Footer link styles - floating fixed position */
.gcm-footer-link {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    left: auto !important; /* Ensure it's not positioned on the left */
    z-index: 9990 !important;
    font-size: 12px !important;
    margin: 0 !important;
    text-align: center !important;
    width: auto !important; /* Ensure it doesn't stretch across the screen */
    display: block !important;
}

.gcm-footer-button {
    color: #fff !important;
    text-decoration: none !important;
    padding: 10px 20px !important;
    border-radius: 30px !important;
    background: #0073aa !important; /* WordPress blue */
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3) !important;
    transition: all 0.3s ease !important;
    display: inline-block !important;
    border: none !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    line-height: 1.5 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
    cursor: pointer !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    outline: none !important;
    text-transform: none !important;
    letter-spacing: 0.5px !important;
}

/* Apply backdrop-filter only if supported */
@supports (backdrop-filter: blur(5px)) or (-webkit-backdrop-filter: blur(5px)) {
    .gcm-footer-button {
        backdrop-filter: blur(5px) !important;
        -webkit-backdrop-filter: blur(5px) !important;
        background: rgba(0, 115, 170, 0.85) !important; /* Semi-transparent WordPress blue with blur */
    }
}

/* Fallback for browsers without backdrop-filter support */
@supports not ((backdrop-filter: blur(5px)) or (-webkit-backdrop-filter: blur(5px))) {
    .gcm-footer-button {
        background: #0073aa !important; /* Solid WordPress blue without blur */
    }
}

.gcm-footer-button:hover {
    background: #005a87 !important; /* Darker blue on hover */
    color: #fff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.4) !important;
}

/* Hide footer link when banner or preferences are visible */
@supports (selector(:has(div))) {
    /* Modern browsers that support :has */
    body:has(#gcm-banner[style*="display: block"]) .gcm-footer-link,
    body:has(#gcm-preferences[style*="display: flex"]) .gcm-footer-link {
        display: none;
    }
}

/* Fallback for browsers that don't support :has (including older Chrome versions) */
.gcm-banner-visible .gcm-footer-link,
.gcm-preferences-visible .gcm-footer-link {
    display: none !important; /* Use !important to ensure it works in all browsers */
}

/* Overlay for preferences modal */
.gcm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: none;
    animation: gcm-fade-in 0.3s forwards;
}

/* Utility classes */
.gcm-hidden {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #gcm-banner {
        width: calc(100% - 40px);
        bottom: 10px;
        right: 10px;
        left: 10px;
        padding: 20px;
    }
    
    #gcm-preferences {
        width: 95%;
        padding: 20px;
    }
    
    .gcm-banner-buttons, .gcm-preferences-buttons {
        flex-direction: column;
    }
    
    #gcm-banner button, #gcm-preferences button {
        margin: 5px 0;
        width: 100%;
    }
    
    .gcm-preference-category label {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .gcm-toggle {
        margin-top: 10px;
    }
    
    .gcm-category-description {
        padding-right: 0;
    }
}

/* For very small screens */
@media (max-width: 380px) {
    #gcm-banner {
        width: calc(100% - 20px);
        bottom: 5px;
        right: 5px;
        left: 5px;
        padding: 15px;
    }
}
