/**
 * Klaro Cookie Consent - Isolated Custom Styling
 * Purpose: Prevent global CSS rules from affecting the cookie popup
 * Strategy: Use high-specificity selectors and !important to override global styles
 */

/* ========================================
   ISOLATION & RESET
   ======================================== */

/* Namespace isolation - prevent global styles from leaking in */
.klaro,
.klaro *,
.klaro *::before,
.klaro *::after {
    box-sizing: border-box !important;
    margin: 0;
    padding: 0;
}

/* Hide Klaro completely when consent is given */
.klaro:empty,
.klaro .cookie-notice-hidden {
    display: none !important;
}

/* Basic container styling - isolated from global rules */
.klaro {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    color: #333 !important;
    position: fixed !important;
    z-index: 99999 !important;
}

/* ========================================
   RESET GLOBAL BUTTON STYLES
   ======================================== */

/* Override ALL global button styles that might affect Klaro buttons */
.klaro button,
.klaro .button,
.klaro .cm-btn,
.klaro .ui.button,
.klaro button.cm-btn,
.klaro a.cm-btn,
.klaro .cookie-notice button,
.klaro .cookie-modal button,
.klaro .context-notice button {
    /* Reset all potential global overrides */
    all: unset;

    /* Re-apply Klaro-specific button styling - Afranga defaults */
    display: inline-block !important;
    box-sizing: border-box !important;
    cursor: pointer !important;
    font-family: inherit !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.5 !important;
    text-align: center !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    vertical-align: middle !important;
    user-select: none !important;

    /* Button sizing - Afranga style */
    padding: 0.6em 1.2em !important;
    margin: 0 0.25em !important;
    border: 2px solid transparent !important;
    border-radius: 4px !important;

    /* Button colors - Afranga default (transparent with outline) */
    color: #052962 !important;
    background-color: transparent !important;
    border-color: #052962 !important;

    /* Transitions */
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease !important;
}

/* Button hover state - Afranga style */
.klaro button:hover,
.klaro .cm-btn:hover {
    background-color: rgba(5, 41, 98, 0.05) !important;
    border-color: #052962 !important;
    transform: none !important;
}

/* Button active state */
.klaro button:active,
.klaro .cm-btn:active {
    transform: translateY(0) !important;
}

/* Button disabled state */
.klaro button:disabled,
.klaro .cm-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* ========================================
   BUTTON VARIANTS - SPECIFIC COLORS
   ======================================== */

/* Accept All / Success button - Afranga green */
.klaro .cm-btn-success,
.klaro button.cm-btn-success,
.klaro .cookie-modal .cm-btn-success {
    background-color: #92D050 !important;
    color: rgba(0, 0, 0, 0.87) !important;
    border-color: #92D050 !important;
}

.klaro .cm-btn-success:hover {
    background-color: #7FBA3D !important;
    border-color: #7FBA3D !important;
}

/* "Accept selected" button - Afranga outline style (same as decline/necessary) */
.klaro .cm-btn-success-var,
.klaro button.cm-btn-success-var,
.klaro .cookie-modal .cm-btn.cm-btn-success-var,
.klaro .cookie-modal button.cm-btn-success-var,
.klaro .cookie-notice .cm-btn.cm-btn-success-var,
.klaro .context-notice .cm-btn.cm-btn-success-var {
    background-color: transparent !important;
    background: transparent !important;
    color: #052962 !important;
    border: 2px solid #052962 !important;
}

.klaro .cm-btn-success-var:hover,
.klaro button.cm-btn-success-var:hover,
.klaro .cookie-modal .cm-btn.cm-btn-success-var:hover,
.klaro .cookie-modal button.cm-btn-success-var:hover {
    background-color: rgba(5, 41, 98, 0.05) !important;
    background: rgba(5, 41, 98, 0.05) !important;
    border-color: #052962 !important;
    color: #052962 !important;
}

/* Accept button (if exists) - Same as decline/necessary */
.klaro .cm-btn-accept,
.klaro button.cm-btn-accept,
.klaro .cookie-modal .cm-btn-accept,
.klaro .cookie-notice .cm-btn-accept {
    background-color: transparent !important;
    background: transparent !important;
    color: #052962 !important;
    border: 2px solid #052962 !important;
}

.klaro .cm-btn-accept:hover,
.klaro button.cm-btn-accept:hover {
    background-color: rgba(5, 41, 98, 0.05) !important;
    background: rgba(5, 41, 98, 0.05) !important;
    border-color: #052962 !important;
    color: #052962 !important;
}


/* ========================================
   COOKIE NOTICE (Banner)
   ======================================== */

.klaro .cookie-notice {
    position: fixed !important;
    bottom: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 90% !important;
    max-width: 100% !important;
    background-color: #ffffff !important;
    color: #333333 !important;
    padding: 1.2em 1.5em !important;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.2) !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    z-index: 99999 !important;
}

/* Large screens (>1024px): 80% width */
@media (min-width: 1024px) {
    .klaro .cookie-notice {
        width: 80% !important;
        max-width: 1400px !important;
    }
}

.klaro .cookie-notice .cn-body {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 1.2em !important;
}

.klaro .cookie-notice .cn-body p {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    color: #333333 !important;
}

/* Button container: "More info" on left, other buttons on right */
.klaro .cookie-notice .cn-body .cn-buttons {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 0.75em !important;
    flex-wrap: nowrap !important;
}

/* All buttons should have auto width (not stretch) */
.klaro .cookie-notice .cn-buttons button,
.klaro .cookie-notice .cn-buttons a {
    flex: 0 0 auto !important;
    width: auto !important;
    white-space: nowrap !important;
}

/* Links inside notice (but NOT the Learn More button) */
.klaro .cookie-notice a:not(.cn-learn-more) {
    color: #2581c4 !important;
    text-decoration: underline !important;
    cursor: pointer !important;
}

.klaro .cookie-notice a:not(.cn-learn-more):hover {
    color: #1e6ca3 !important;
}

/* ========================================
   COOKIE MODAL (Detailed Settings)
   ======================================== 
   everything that is under 769
   
   */
@media (max-width: 290px) {
    .klaro .cookie-modal p {
        margin-top: 40px !important;
    }
}

   .klaro .cookie-modal p {
    margin-right: 40px !important;
}

.klaro .cookie-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    z-index: 99999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1em !important;
}

.klaro .cookie-modal .cm-modal {
    background-color: #fff !important;
    color: #333 !important;
    border-radius: 8px !important;
    max-width: 750px !important;
    max-height: 90vh !important;
    width: 100% !important;
    overflow: hidden !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
    display: flex !important;
    flex-direction: column !important;
}

.klaro .cookie-modal .cm-header {
    background-color: #052962 !important;
    color: #fff !important;
    padding: 1.25em 1.5em !important;
    border-bottom: none !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 1em !important;
}

.klaro .cookie-modal .cm-header h1,
.klaro .cookie-modal .cm-header h1.title {
    margin: 0 !important;
    padding: 0 !important;
    padding-right: 0.5em !important;
    font-size: 1.25em !important;
    font-weight: 600 !important;
    color: #fff !important;
    flex: 1 1 auto !important;
}

@media (max-width: 389px) {
    .klaro .cookie-modal .cm-header h1,
    .klaro .cookie-modal .cm-header h1.title {
        font-size: 1.0em !important;
    }
}

/* Close button in header (X button) */
.klaro .cookie-modal .cm-header button,
.klaro .cookie-modal .cm-header .cm-btn,
.klaro .cookie-modal .cm-header button.cm-btn {
    background-color: transparent !important;
    color: #fff !important;
    padding: 0.5em !important;
    margin: 0 !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 4px !important;
    font-size: 1.2em !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
}

.klaro .cookie-modal .cm-header button:hover,
.klaro .cookie-modal .cm-header .cm-btn:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    transform: none !important;
}

.klaro .cookie-modal .cm-body {
    padding: 1.5em !important;
    overflow-y: auto !important;
    flex: 1 1 auto !important;
    color: #333 !important;
}

.klaro .cookie-modal .cm-footer {
    background-color: #ffffff !important;
    padding: 1.5em !important;
    border-top: 1px solid #e0e0e0 !important;
    flex-shrink: 0 !important;
}

.klaro .cookie-modal .cm-footer-buttons {
    display: flex !important;
    justify-content: first baseline !important;
    align-items: center !important;
    gap: 0.75em !important;
    flex-wrap: wrap !important;
}

/* Footer buttons should have proper sizing */
.klaro .cookie-modal .cm-footer button,
.klaro .cookie-modal .cm-footer .cm-btn {
    padding: 0.75em 1.5em !important;
    font-size: 14px !important;
    height: auto !important;
    min-height: auto !important;
    width: auto !important;
    min-width: 100px !important;
}

@media (max-width: 768px) {
    .klaro .cookie-modal .cm-footer button,
    .klaro .cookie-modal .cm-footer .cm-btn {
        width: 100% !important;
        height: 60px !important;
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    .klaro .cookie-notice .cn-body {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .klaro .cookie-notice .cn-body .cn-buttons {
        width: 100% !important;
        justify-content: center !important;
    }

    .klaro .cookie-notice button,
    .klaro .cookie-notice .cm-btn {
        flex: 1 1 auto !important;
        min-width: 120px !important;
    }

    .klaro .cookie-modal .cm-modal {
        margin: 0 !important;
        width: calc(100% - 1em) !important;
    }

    .klaro .cookie-modal .cm-footer-buttons {
        flex-direction: column !important;
    }

    .klaro .cookie-modal .cm-footer-buttons button {
        width: 100% !important;
    }
}

@media (max-width: 384px) {
    .klaro .cookie-notice button,
    .klaro .cookie-notice .cm-btn {
        font-size: 12px !important;
        padding: 0.6em 1em !important;
    }
}

/* ========================================
   ADDITIONAL OVERRIDES FOR SEMANTIC UI & BOOTSTRAP
   ======================================== */

/* Ensure Semantic UI and Bootstrap don't affect Klaro */
.klaro .ui.button,
.klaro button.ui,
.klaro .btn,
.klaro button.btn {
    all: unset !important;
    display: inline-block !important;
    box-sizing: border-box !important;
    cursor: pointer !important;
    font-family: inherit !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.5 !important;
    text-align: center !important;
    padding: 0.75em 1.5em !important;
    margin: 0 0.25em !important;
    border: none !important;
    border-radius: 4px !important;
    color: #fff !important;
    background-color: #5c5c5c !important;
    transition: background-color 0.2s ease !important;
}

/* Reset any Bootstrap or Semantic margins/padding on text elements */
.klaro p,
.klaro h1,
.klaro h2,
.klaro h3,
.klaro h4,
.klaro h5,
.klaro h6,
.klaro div,
.klaro span {
    font-family: inherit !important;
}

/* Fix text colors in modal body and service descriptions */
.klaro .cookie-modal .cm-body,
.klaro .cookie-modal .cm-body p,
.klaro .cookie-modal .cm-body div,
.klaro .cookie-modal .cm-body span,
.klaro .cookie-modal .cm-body h1,
.klaro .cookie-modal .cm-body h2,
.klaro .cookie-modal .cm-body h3,
.klaro .cookie-modal .cm-body h4 {
    color: #333 !important;
}

/* Service descriptions and labels */
.klaro .cm-switch-container,
.klaro .cm-switch-container p,
.klaro .cm-switch-container span,
.klaro .cm-switch-container div,
.klaro .cm-app-title,
.klaro .cm-app-description,
.klaro .cm-service-description,
.klaro .cm-purposes {
    color: #333 !important;
}

/* Service item expanded content */
.klaro .cm-service-item,
.klaro .cm-service-item p,
.klaro .cm-service-item span,
.klaro .cm-service-item div {
    color: #333 !important;
}

/* Category headers */
.klaro .cm-purpose,
.klaro .cm-purpose-title,
.klaro .cookie-modal .cm-purpose h2 {
    color: #333 !important;
}

/* Links in modal should be readable */
.klaro .cookie-modal a,
.klaro .cookie-modal .cm-body a {
    color: #2581c4 !important;
    text-decoration: underline !important;
}

.klaro .cookie-modal a:hover,
.klaro .cookie-modal .cm-body a:hover {
    color: #1e6ca3 !important;
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.klaro button:focus,
.klaro .cm-btn:focus {
    outline: 2px solid #24cc9a !important;
    outline-offset: 2px !important;
}

/* ========================================
   TOGGLE SWITCHES (Afranga Style)
   ======================================== */

/* Switch track background - All switches use Afranga coral/red */
.klaro .cm-switch .cm-slider,
.klaro .cm-switch input[type="checkbox"] + .cm-slider,
.klaro .cm-switch input[type="checkbox"]:not(:checked) + .cm-slider,
.klaro .cm-switch input[type="checkbox"]:checked + .cm-slider {
    background-color: #FF7E79 !important;
    border: 1px solid #FF7E79 !important;
}

/* Switch knob/handle - white knob, position changes based on state */
.klaro .cm-switch .cm-slider:before {
    background-color: #ffffff !important;
}

/* Switch hover states - slightly darker coral */
.klaro .cm-switch input[type="checkbox"]:hover + .cm-slider,
.klaro .cm-switch input[type="checkbox"]:not(:checked):hover + .cm-slider,
.klaro .cm-switch input[type="checkbox"]:checked:hover + .cm-slider {
    background-color: #FF6B65 !important;
    border-color: #FF6B65 !important;
}

/* ========================================
   AFRANGA CUSTOM BUTTON STYLES (3-Button Design)
   ======================================== */


/* Hide native learn-more button since we use custom "Select cookies" button */
.klaro .cookie-notice .cn-learn-more,
.klaro .cookie-notice button.cm-btn.cm-btn-info {
    display: none !important;
}

/* "Select cookies" button (custom button) - LEFT side, uses global Afranga defaults */
.klaro .cookie-notice .cm-btn-select-cookies,
.klaro .cookie-notice button.cm-btn-select-cookies {
    order: 0 !important;
    margin-left: 0 !important;
    margin-right: auto !important;
    flex-shrink: 0 !important;
}

/* "Accept necessary" button - RIGHT side, uses global Afranga defaults */
.klaro .cookie-notice .cm-btn-decline,
.klaro .cookie-notice button.cm-btn-decline {
    order: 1 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    flex-shrink: 0 !important;
}

/* "Accept all" button - RIGHT side, inherits Afranga green from global success variant */
.klaro .cookie-notice .cm-btn-success,
.klaro .cookie-notice button.cm-btn-success {
    order: 2 !important;
    margin-left: 0 !important;
    flex-shrink: 0 !important;
    font-weight: 600 !important;
}

/* Tablet and smaller: Adjust banner */
@media (max-width: 1024px) {
    .klaro .cookie-notice {
        width: 95% !important;
        bottom: 15px !important;
    }
}

/* Mobile responsive: Stack buttons on small screens */
@media (max-width: 768px) {
    .klaro .cookie-notice {
        padding: 1em !important;
        bottom: 10px !important;
        width: 95% !important;
    }

    .klaro .cookie-notice .cn-body {
        gap: 1em !important;
    }

    .klaro .cookie-notice .cn-body p {
        font-size: 12px !important;
        width: 100% !important;
    }

    .klaro .cookie-notice .cn-buttons {
        width: 100% !important;
        flex-direction: column !important;
        gap: 0.6em !important;
        align-items: stretch !important;
    }

    .klaro .cookie-notice .cn-buttons button,
    .klaro .cookie-notice .cn-buttons a {
        width: 100% !important;
        font-size: 12px !important;
        padding: 0.7em 1em !important;
        margin: 0 !important;
        order: initial !important;
    }

    /* On mobile, keep original order */
    .klaro .cookie-notice .cn-learn-more,
    .klaro .cookie-notice button.cm-btn.cm-btn-info {
        order: 1 !important;
    }

    .klaro .cookie-notice .cm-btn-decline {
        order: 2 !important;
    }

    .klaro .cookie-notice .cm-btn-success {
        order: 3 !important;
    }
}

/* ========================================
   HIDE WHEN CONSENT IS GIVEN
   ======================================== */

.klaro.cm-hidden,
.klaro .cookie-notice.cookie-notice-hidden,
.klaro .cookie-modal.cm-hidden {
    display: none !important;
}

/* ========================================
   HIDE Branding :)
   ======================================== */
.klaro .cm-powered-by {
    display: none !important;
}
