/* ==========================================================================
   M8 Cookie Consent Banner & Granular Preferences Styles
   Hero Banner Date Color Scheme (#d2ba83 - Solid, No Gradient)
   Floating Box / Card Layout with Margins (Bottom, Left, Right)
   Compliant with GDPR, ePrivacy, and Moonton / MLBB Esports Standards
   ========================================================================== */

:root {
    --m8-cookie-theme-color: #d2ba83;
    --m8-cookie-theme-glow: rgba(210, 186, 131, 0.3);
    --m8-cookie-theme-border: rgba(210, 186, 131, 0.25);
}

/* 1. Main Cookie Banner (Floating Card with Margins) */
.m8-cookie-banner {
    position: fixed;
    bottom: 24px;
    left: 40px;
    right: auto;
    max-width: 1040px;
    width: calc(100% - 160px);
    margin: 0;
    z-index: 999999;
    background-color: #000000;
    color: #ffffff;
    padding: 22px 34px;
    border-radius: 16px;
    box-shadow: none;
    border: 1.5px solid var(--m8-cookie-theme-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    animation: m8CookieSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes m8CookieSlideUp {
    from {
        transform: translateY(35px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Round Cookie Icon attached to the left edge of the box */
.m8-cookie-side-icon {
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #000000;
    border: 1.5px solid var(--m8-cookie-theme-color);
    color: var(--m8-cookie-theme-color);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    z-index: 2;
}

.m8-cookie-side-icon svg {
    display: block;
    stroke: var(--m8-cookie-theme-color);
}

.m8-cookie-container {
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 36px;
}

.m8-cookie-content {
    flex: 1;
    max-width: 820px;
}

.m8-cookie-title {
    font-size: 0.875rem; /* ~14px */
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 6px 0;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.m8-cookie-text {
    font-size: 0.75rem; /* ~12px */
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    font-weight: 400;
}

.m8-cookie-text a,
.cookie-notice-link {
    color: var(--m8-cookie-theme-color) !important;
    text-decoration: underline !important;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.m8-cookie-text a:hover,
.cookie-notice-link:hover {
    opacity: 0.85;
}

/* Three Stacked Buttons on Right (#d2ba83 Solid Outline, No Gradient) */
.m8-cookie-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
    width: 230px;
}

.m8-cookie-btn {
    width: 100%;
    padding: 8px 18px;
    border-radius: 9999px;
    font-size: 0.8125rem; /* ~13px */
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    outline: none;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-sizing: border-box;
    white-space: nowrap;
    user-select: none;
    font-family: inherit;
    line-height: 1.35;
    min-height: 38px;
}

/* Primary Recommended Button (Filled Solid #d2ba83 for optimal UX) */
.m8-cookie-btn.m8-cookie-btn-primary,
#btnCookieAcceptAll,
#btnModalAcceptAll {
    background-color: var(--m8-cookie-theme-color);
    color: #000000 !important;
    border: 1.5px solid var(--m8-cookie-theme-color);
    box-shadow: 0 4px 14px var(--m8-cookie-theme-glow);
}

.m8-cookie-btn.m8-cookie-btn-primary:hover,
#btnCookieAcceptAll:hover,
#btnModalAcceptAll:hover {
    background-color: #dfcaa0;
    border-color: #dfcaa0;
    color: #000000 !important;
    box-shadow: 0 6px 20px rgba(210, 186, 131, 0.45);
    transform: translateY(-1px);
}

.m8-cookie-btn.m8-cookie-btn-primary:active,
#btnCookieAcceptAll:active,
#btnModalAcceptAll:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(210, 186, 131, 0.3);
}

/* Outlined Buttons (#d2ba83 Border, Black Background) */
.m8-cookie-btn.m8-cookie-btn-outline,
#btnCookieRejectNonEssential,
#btnCookieSettings,
#btnModalRejectNonEssential,
#btnModalSavePreferences {
    background-color: #000000;
    color: var(--m8-cookie-theme-color);
    border: 1.5px solid var(--m8-cookie-theme-color);
}

.m8-cookie-btn.m8-cookie-btn-outline:hover,
#btnCookieRejectNonEssential:hover,
#btnCookieSettings:hover,
#btnModalRejectNonEssential:hover,
#btnModalSavePreferences:hover {
    background-color: rgba(210, 186, 131, 0.15);
    color: var(--m8-cookie-theme-color) !important;
    border-color: var(--m8-cookie-theme-color);
    box-shadow: 0 0 12px var(--m8-cookie-theme-glow);
    transform: translateY(-1px);
}

.m8-cookie-btn.m8-cookie-btn-outline:active,
#btnCookieRejectNonEssential:active,
#btnCookieSettings:active,
#btnModalRejectNonEssential:active,
#btnModalSavePreferences:active {
    transform: translateY(0);
    box-shadow: 0 0 4px var(--m8-cookie-theme-glow);
}

/* 2. Granular Preferences Modal Overlay */
.m8-cookie-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: m8FadeIn 0.2s ease forwards;
}

@keyframes m8FadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.m8-cookie-modal {
    background: #0f121a;
    border: 1px solid var(--m8-cookie-theme-border);
    border-radius: 18px;
    width: 100%;
    max-width: 760px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.95), 0 0 24px rgba(210, 186, 131, 0.08);
    color: #ffffff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    animation: m8ScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes m8ScaleUp {
    from {
        transform: scale(0.96);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.m8-cookie-modal-header {
    padding: 24px 28px 18px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    background: #141822;
}

.m8-cookie-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--m8-cookie-theme-color);
    margin: 0 0 6px 0;
    letter-spacing: -0.01em;
}

.m8-cookie-modal-subtitle {
    font-size: 0.8125rem;
    color: #a0a6b5;
    margin: 0;
    line-height: 1.5;
}

.m8-cookie-modal-close {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.m8-cookie-modal-close:hover {
    background: rgba(210, 186, 131, 0.15);
    color: var(--m8-cookie-theme-color);
    border-color: var(--m8-cookie-theme-color);
    transform: rotate(90deg);
}

.m8-cookie-modal-body {
    padding: 24px 28px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Category Item Cards */
.m8-cookie-category-item {
    background: #161a25;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 18px 20px;
    transition: border-color 0.2s ease;
}

.m8-cookie-category-item:hover {
    border-color: var(--m8-cookie-theme-border);
}

.m8-cookie-cat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}

.m8-cookie-cat-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.m8-cookie-cat-name {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #ffffff;
}

.m8-cookie-badge-status {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 6px;
}

.m8-status-always {
    background: rgba(72, 187, 120, 0.18);
    color: #48bb78;
    border: 1px solid rgba(72, 187, 120, 0.35);
}

.m8-status-optional {
    background: rgba(160, 174, 192, 0.15);
    color: #cbd5e0;
    border: 1px solid rgba(160, 174, 192, 0.25);
}

.m8-cookie-cat-desc {
    font-size: 0.8125rem;
    line-height: 1.55;
    color: #a0a6b5;
    margin: 0 0 10px 0;
}

.m8-cookie-cat-meta {
    font-size: 0.75rem;
    color: #717b91;
    line-height: 1.5;
}

.m8-cookie-cat-meta code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--m8-cookie-theme-color);
    font-size: 0.75rem;
}

/* Custom Toggle Switch */
.m8-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}

.m8-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.m8-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #2d3748;
    transition: 0.25s;
    border-radius: 34px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.m8-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    transition: 0.25s;
    border-radius: 50%;
}

.m8-switch input:checked + .m8-slider {
    background-color: var(--m8-cookie-theme-color);
    border-color: var(--m8-cookie-theme-color);
}

.m8-switch input:checked + .m8-slider:before {
    transform: translateX(20px);
    background-color: #000000;
}

.m8-slider-locked {
    cursor: not-allowed;
    background-color: #276749 !important;
    border-color: #276749 !important;
    opacity: 0.9;
}

.m8-switch input:disabled + .m8-slider:before {
    background-color: #c6f6d5;
}

/* Audit Record Card */
.m8-cookie-audit-card {
    background: #11151f;
    border: 1px dashed var(--m8-cookie-theme-border);
    border-radius: 12px;
    padding: 16px 20px;
}

.m8-audit-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--m8-cookie-theme-color);
    margin-bottom: 12px;
}

.m8-audit-header i {
    color: var(--m8-cookie-theme-color);
}

.m8-audit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    font-size: 0.75rem;
    margin-bottom: 12px;
}

.m8-audit-label {
    display: block;
    color: #717b91;
    margin-bottom: 2px;
    font-weight: 500;
}

.m8-audit-val {
    color: #cbd5e0;
    font-weight: 600;
    word-break: break-all;
}

.m8-audit-note {
    font-size: 0.75rem;
    line-height: 1.5;
    color: #a0a6b5;
    margin: 0;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Modal Footer Buttons (#d2ba83 Solid Outline, No Gradient) */
.m8-cookie-modal-footer {
    padding: 18px 28px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: #141822;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.m8-cookie-modal-footer .m8-cookie-btn {
    width: auto;
    min-width: 170px;
}

/* 3. Persistent Floating Entrance Badge (#d2ba83 Solid Theme) */
.m8-cookie-badge {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 99998;
    animation: m8FadeIn 0.3s ease;
}

.m8-cookie-badge-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: rgba(15, 18, 26, 0.95);
    border: 1.5px solid var(--m8-cookie-theme-color);
    border-radius: 50%;
    color: var(--m8-cookie-theme-color);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 10px rgba(210, 186, 131, 0.15);
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.m8-cookie-badge-btn:hover {
    background-color: var(--m8-cookie-theme-color);
    color: #000000 !important;
    border-color: var(--m8-cookie-theme-color);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px var(--m8-cookie-theme-glow);
}

.m8-cookie-icon {
    display: block;
    stroke: currentColor;
}

/* 4. Responsive Queries */
@media (max-width: 991px) {
    .m8-cookie-banner {
        bottom: 14px;
        left: 14px;
        right: 14px;
        width: auto;
        max-width: none;
        padding: 20px 18px;
        border-radius: 14px;
    }

    .m8-cookie-title {
        font-size: 0.8125rem; /* ~13px */
        margin-bottom: 4px;
    }

    .m8-cookie-text {
        font-size: 0.6875rem; /* ~11px */
        line-height: 1.45;
    }

    .m8-cookie-side-icon {
        left: 14px;
        top: -18px;
        transform: none;
        width: 34px;
        height: 34px;
    }

    .m8-cookie-side-icon svg {
        width: 16px;
        height: 16px;
    }
    
    .m8-cookie-container {
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
    }
    
    .m8-cookie-content {
        max-width: 100%;
    }
    
    .m8-cookie-actions {
        width: 100%;
        gap: 10px;
    }
    
    .m8-cookie-modal {
        max-height: 94vh;
    }
    
    .m8-cookie-modal-footer {
        flex-direction: column;
        align-items: stretch;
    }
    
    .m8-cookie-modal-footer .m8-cookie-btn {
        width: 100%;
    }
    
    .m8-cookie-badge {
        bottom: 16px;
        left: 16px;
    }
}
