/**
 * Consent Popup Styles
 *
 * @package ERC
 */

/* === TARGETED CSS ISOLATION === */
/* Prevents WordPress theme styles from overriding consent popup styles */
/* Uses targeted resets - preserves layout properties */

/* Box-sizing only for child elements */
.erc-consent-popup *,
.erc-consent-popup *::before,
.erc-consent-popup *::after {
	box-sizing: border-box;
}

/* Typography reset - targeted */
.erc-consent-popup h1,
.erc-consent-popup h2,
.erc-consent-popup h3,
.erc-consent-popup h4,
.erc-consent-popup p,
.erc-consent-popup span,
.erc-consent-popup label {
	font-family: inherit !important;
	letter-spacing: normal !important;
	text-transform: none !important;
}

/* Button reset - targeted */
.erc-consent-popup button {
	font-family: inherit !important;
	font-size: 16px !important;
	line-height: 1.5 !important;
	letter-spacing: normal !important;
	text-transform: none !important;
	text-decoration: none !important;
	min-height: auto !important;
	min-width: auto !important;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
}

/* Input reset - targeted */
.erc-consent-popup input {
	font-family: inherit !important;
	appearance: none;
	-webkit-appearance: none;
}

/* List reset */
.erc-consent-popup ul,
.erc-consent-popup ol {
	list-style: none;
}

/* Popup Container - Must be above ALL page elements including sticky headers */
.erc-consent-popup {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
	font-size: 16px !important;
	line-height: 1.5 !important;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 2147483647 !important; /* Maximum z-index value */
    display: flex;  /* Removed !important so JS can override */
    align-items: center !important;
    justify-content: center !important;
    isolation: isolate !important; /* Create new stacking context */
    transform: translateZ(0) !important; /* Force GPU layer */
    -webkit-transform: translateZ(0) !important;
    pointer-events: auto !important;
    contain: layout style paint !important;
}

/* Hidden state - must override the display:flex above */
.erc-consent-popup.erc-consent-hidden,
.erc-consent-popup[aria-hidden="true"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* When popup is visible, ensure it's on top of everything */
.erc-consent-popup[style*="display: block"],
.erc-consent-popup[style*="display:block"],
.erc-consent-popup:not([style*="display: none"]):not([style*="display:none"]) {
    z-index: 2147483647 !important;
}

/* Overlay */
.erc-consent-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    z-index: 1 !important;
}

/* Modal */
.erc-consent-modal {
    position: relative;
    max-width: 700px;
    max-height: 90vh;
    width: 95%;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 2;
}

/* Header */
.erc-consent-header {
    position: relative;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.erc-consent-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.erc-consent-close:hover {
    background: #f3f4f6;
    color: #111827;
}

/* Body */
.erc-consent-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px 32px 24px;
}

/* Intro */
.erc-consent-intro {
    text-align: center;
    margin-bottom: 32px;
}

.erc-consent-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}

.erc-consent-title {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 12px;
    line-height: 1.3;
}

.erc-consent-subtitle {
    font-size: 16px;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}

/* Disclaimers Container */
.erc-consent-disclaimers {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Disclaimer Item */
.erc-disclaimer-item {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    background: #f9fafb;
    transition: all 0.3s ease;
}

.erc-disclaimer-item.erc-disclaimer-consented {
    border-color: #10b981;
    background: #f0fdf4;
}

/* Disclaimer Header */
.erc-disclaimer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.erc-disclaimer-title {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.erc-disclaimer-version {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
    background: #e5e7eb;
    padding: 4px 10px;
    border-radius: 4px;
}

/* Disclaimer Content */
.erc-disclaimer-content {
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
    margin-bottom: 16px;
}

.erc-disclaimer-content h3,
.erc-disclaimer-content h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 16px 0 8px;
    color: #111827;
}

.erc-disclaimer-content p {
    margin: 0 0 12px;
}

.erc-disclaimer-content ul {
    margin: 8px 0;
    padding-left: 24px;
}

.erc-disclaimer-content li {
    margin-bottom: 8px;
}

.erc-disclaimer-content strong {
    font-weight: 600;
    color: #111827;
}

/* Checkbox Wrapper */
.erc-disclaimer-checkbox-wrapper {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.erc-disclaimer-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.erc-disclaimer-checkbox {
    position: relative;
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #667eea;
    /* Visible border for all themes */
    border: 2px solid #6b7280;
    border-radius: 4px;
    background-color: #ffffff;
    transition: all 0.2s ease;
}

.erc-disclaimer-checkbox:checked {
    background-color: #667eea;
    border-color: #667eea;
}

/* Custom checkmark since appearance:none removes native one */
.erc-disclaimer-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 6px;
    height: 11px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.erc-disclaimer-checkbox:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.erc-disclaimer-checkbox:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.erc-disclaimer-checkbox-text {
    flex: 1;
    font-size: 15px;
    color: #374151;
    line-height: 1.5;
}

.erc-disclaimer-status {
    margin-left: auto;
    font-size: 14px;
    font-weight: 500;
}

.erc-disclaimer-status .erc-loading {
    color: #6b7280;
}

.erc-disclaimer-status .erc-success {
    color: #10b981;
}

.erc-disclaimer-status .erc-error {
    color: #ef4444;
}

/* Footer Note */
.erc-consent-footer-note {
    margin-top: 24px;
    padding: 16px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
}

.erc-consent-footer-note p {
    margin: 0;
    font-size: 14px;
    color: #1e40af;
    line-height: 1.5;
}

/* Footer */
.erc-consent-footer {
    padding: 20px 32px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    text-align: center;
}

/* Continue Button */
.erc-consent-btn {
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    padding: 14px 32px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
}

.erc-consent-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.erc-consent-btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.erc-consent-btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.erc-consent-btn-primary:disabled {
    background: #d1d5db;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Scrollbar Styles */
.erc-consent-body::-webkit-scrollbar {
    width: 8px;
}

.erc-consent-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.erc-consent-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.erc-consent-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive */
@media (max-width: 768px) {
    .erc-consent-modal {
        max-width: 95%;
        margin: 2.5vh auto;
        max-height: 95vh;
    }

    .erc-consent-body {
        padding: 24px 20px 16px;
    }

    .erc-consent-title {
        font-size: 24px;
    }

    .erc-consent-subtitle {
        font-size: 15px;
    }

    .erc-disclaimer-item {
        padding: 16px;
    }

    .erc-disclaimer-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .erc-consent-footer {
        padding: 16px 20px;
    }

    .erc-consent-btn {
        width: 100%;
        min-width: auto;
    }
}

/* Dark Mode Support (optional) */
@media (prefers-color-scheme: dark) {
    .erc-consent-modal {
        background: #1f2937;
    }

    .erc-consent-header {
        border-bottom-color: #374151;
    }

    .erc-consent-close {
        color: #9ca3af;
    }

    .erc-consent-close:hover {
        background: #374151;
        color: #f9fafb;
    }

    .erc-consent-title {
        color: #f9fafb;
    }

    .erc-consent-subtitle {
        color: #d1d5db;
    }

    .erc-disclaimer-item {
        background: #111827;
        border-color: #374151;
    }

    .erc-disclaimer-item.erc-disclaimer-consented {
        background: #064e3b;
        border-color: #10b981;
    }

    .erc-disclaimer-header {
        border-bottom-color: #374151;
    }

    .erc-disclaimer-title {
        color: #f9fafb;
    }

    .erc-disclaimer-version {
        background: #374151;
        color: #d1d5db;
    }

    .erc-disclaimer-content {
        color: #d1d5db;
    }

    .erc-disclaimer-content h3,
    .erc-disclaimer-content h4,
    .erc-disclaimer-content strong {
        color: #f9fafb;
    }

    .erc-disclaimer-checkbox-wrapper {
        border-top-color: #374151;
    }

    .erc-disclaimer-checkbox-text {
        color: #d1d5db;
    }

    .erc-disclaimer-checkbox {
        border-color: #9ca3af;
        background-color: #374151;
    }

    .erc-disclaimer-checkbox:checked {
        background-color: #667eea;
        border-color: #667eea;
    }

    .erc-disclaimer-checkbox:focus {
        outline-color: #818cf8;
    }

    .erc-consent-footer-note {
        background: #1e3a8a;
        border-color: #3b82f6;
    }

    .erc-consent-footer-note p {
        color: #93c5fd;
    }

    .erc-consent-footer {
        background: #111827;
        border-top-color: #374151;
    }

    .erc-consent-body::-webkit-scrollbar-track {
        background: #1f2937;
    }

    .erc-consent-body::-webkit-scrollbar-thumb {
        background: #4b5563;
    }

    .erc-consent-body::-webkit-scrollbar-thumb:hover {
        background: #6b7280;
    }
}
