/**
 * 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 */
    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;
    text-decoration: none !important;
    white-space: nowrap !important;
    vertical-align: middle !important;
    user-select: none !important;

    /* Button sizing */
    padding: 0.75em 1.5em !important;
    margin: 0 0.25em !important;
    border: none !important;
    border-radius: 4px !important;

    /* Button colors - default */
    color: #fff !important;
    background-color: #5c5c5c !important;

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

/* Button hover state */
.klaro button:hover,
.klaro .cm-btn:hover {
    opacity: 0.9 !important;
    transform: translateY(-1px) !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 - Green */
.klaro .cm-btn-success,
.klaro button.cm-btn-success,
.klaro .cookie-notice .cm-btn-success,
.klaro .cookie-modal .cm-btn-success {
    background-color: #1a936f !important;
    color: #fff !important;
}

.klaro .cm-btn-success:hover {
    background-color: #157a5c !important;
}

/* Accept All variant */
.klaro .cm-btn-success-var,
.klaro button.cm-btn-success-var {
    background-color: #24cc9a !important;
    color: #fff !important;
}

.klaro .cm-btn-success-var:hover {
    background-color: #1fb885 !important;
}

/* Reject All / Decline button - Gray */
.klaro .cm-btn-decline,
.klaro button.cm-btn-decline,
.klaro .cm-btn-close,
.klaro button.cm-btn-close,
.klaro .cookie-notice .cm-btn-decline,
.klaro .cookie-modal .cm-btn-decline {
    background-color: #6c6c6c !important;
    color: #fff !important;
}

.klaro .cm-btn-decline:hover,
.klaro .cm-btn-close:hover {
    background-color: #5a5a5a !important;
}

/* Info / Learn More button - Blue */
.klaro .cm-btn-info,
.klaro button.cm-btn-info,
.klaro .cookie-notice .cm-btn-info,
.klaro .cookie-modal .cm-btn-info {
    background-color: #2581c4 !important;
    color: #fff !important;
}

.klaro .cm-btn-info:hover {
    background-color: #1e6ca3 !important;
}

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

.klaro .cookie-notice {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    background-color: #2c3e50 !important;
    color: #fff !important;
    padding: 1.5em !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2) !important;
    z-index: 99999 !important;
}

.klaro .cookie-notice .cn-body {
    max-width: 1200px !important;
    margin: 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 1em !important;
}

.klaro .cookie-notice .cn-body p {
    flex: 1 1 auto !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    color: #fff !important;
}

.klaro .cookie-notice .cn-body .cn-buttons {
    display: flex !important;
    align-items: center !important;
    gap: 0.5em !important;
    flex-wrap: wrap !important;
}

/* Links inside notice */
.klaro .cookie-notice a {
    color: #24cc9a !important;
    text-decoration: underline !important;
    cursor: pointer !important;
}

.klaro .cookie-notice a:hover {
    color: #1fb885 !important;
}

/* ========================================
   COOKIE MODAL (Detailed Settings)
   ======================================== */

.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;
}

.klaro .cookie-modal .cm-modal {
    background-color: #fff !important;
    color: #333 !important;
    border-radius: 8px !important;
    max-width: 600px !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: #2c3e50 !important;
    color: #fff !important;
    padding: 1.25em 1.5em !important;
    border-bottom: 1px solid #ddd !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;
}

/* 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: #f5f5f5 !important;
    padding: 1em 1.5em !important;
    border-top: 1px solid #ddd !important;
    flex-shrink: 0 !important;
}

.klaro .cookie-modal .cm-footer-buttons {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 0.5em !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;
}

/* ========================================
   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.5em !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;
}

/* ========================================
   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;
}
