/**
 * Plugin Name: Cookie Craft
 * Description: GDPR compliant cookie consent banner with Google Consent Mode v2 integration.
 * Version: 2.0
 * Author: Bogdan Paunica
 */

#cookie-consent-v2-banner,
#cookie-consent-v2-banner *,
#cookie-consent-v2-preferences-modal,
#cookie-consent-v2-preferences-modal *,
#cookie-consent-v2-preferences-button-duplicate,
#cookie-consent-v2-preferences-button-duplicate * {
    box-sizing: border-box;
}

/* Basic styling for the cookie consent banner */
#cookie-consent-v2-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 480px;
    background-color: var(--cc-bg, #f0f0f0);

    /* IMPORTANT: padding mutat pe sectiuni, ca sa nu consume din inaltimea fixa */
    padding: 0;

    z-index: 9999;
    box-shadow: 0px -2px 5px rgba(0, 0, 0, 0.2);

    /* Mobil (fara conditii): banner = 75% din ecran */
    height: 75vh;
    height: 75dvh;
    max-height: 75vh;
    max-height: 75dvh;

    display: flex;
    flex-direction: column;

    /* Nu lasa continutul sa "impinga" in afara containerului */
    overflow: hidden;

    /* Text color implicit pentru banner (fara sa afecteze restul site-ului) */
    color: var(--cc-text, #111111);
}

/* IMPORTANT: template-ul are div-uri .clear intre sectiuni.
   Le ascundem STRICT in banner, ca sa nu fie influentate de CSS-ul temei. */
#cookie-consent-v2-banner .clear {
    display: none !important;
}

/* Desktop adjustments */
@media (min-width: 640px) {
    #cookie-consent-v2-banner {
        width: 480px;
        right: 20px;
        bottom: 20px;
        left: auto;

        /* Desktop: max 40% din ecran */
        height: 40vh;
        height: 40dvh;
        max-height: 40vh;
        max-height: 40dvh;
    }
}

/* Title */
#cookie-consent-v2-banner-title {
    background-color: var(--cc-accent, #007bff);
    color: var(--cc-accent-text, #ffffff);
    text-align: center;
    font-weight: bold;

    /* Mobil: 8% din ecran */
    height: 8vh;
    height: 8dvh;

    flex: 0 0 auto;
    min-height: 0;
    overflow: hidden;

    display: flex;
    align-items: center;
    justify-content: center;

    /* Fara padding vertical, ca sa nu depaseasca 8vh */
    padding: 0 1em;
}

/* Desktop: 8/75 din 40vh = 4.27vh */
@media (min-width: 640px) {
    #cookie-consent-v2-banner-title {
        height: 4.27vh;
        height: 4.27dvh;
    }
}

/* Asigura explicit ca textul din header ramane alb */
#cookie-consent-v2-banner-title p,
#cookie-consent-v2-banner-title .cookie-banner-title {
    color: var(--cc-accent-text, #ffffff);
    margin: 0;
    font-size: 1.2em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Scrollable text (DOAR aici) */
#cookie-consent-v2-banner-text {
    /* Mobil: 51% din ecran */
    height: 51vh;
    height: 51dvh;

    flex: 0 0 auto;
    min-height: 0;

    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    /* padding mutat aici (in loc de container) */
    padding: 10px 20px;
}

/* Desktop: 51/75 din 40vh = 27.19vh */
@media (min-width: 640px) {
    #cookie-consent-v2-banner-text {
        height: 27.19vh;
        height: 27.19dvh;
    }
}

/* Text in banner */
#cookie-consent-v2-banner p {
    margin-bottom: 10px;
    text-align: center;
    font-size: 1em;
}

/* Lists inside banner */
#cookie-consent-v2-banner ul {
    font-size: 0.9em;
    text-align: left;
    margin-left: 0.4em;
    padding-left: 1em;
    list-style-type: disc;
}

#cookie-consent-v2-banner ul li {
    margin-bottom: 0.5em;
    line-height: 1.4;
}

/* Links section - scoped (ramane vizibila, fara scroll) */
#cookie-consent-v2-banner .cookie-consent-v2-links {
    /* Mobil: 8% din ecran */
    height: 8vh;
    height: 8dvh;

    flex: 0 0 auto;
    min-height: 0;
    overflow: hidden;

    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;

    margin: 0;
    padding: 0 12px;

    text-align: center;
}

/* Desktop: 4.27vh */
@media (min-width: 640px) {
    #cookie-consent-v2-banner .cookie-consent-v2-links {
        height: 4.27vh;
        height: 4.27dvh;
    }
}

#cookie-consent-v2-banner .cookie-consent-v2-links .link-button {
    display: inline-block;
    padding: 6px 10px;
    color: var(--cc-accent, #007bff);
    text-decoration: none;
    font-size: 0.9em;
    border: 1px solid var(--cc-accent, #007bff);
    background: none;
    cursor: pointer;

    margin: 4px 6px;
    line-height: 1.2;
    white-space: nowrap;
}

#cookie-consent-v2-banner .cookie-consent-v2-links .link-button:hover {
    background-color: var(--cc-accent, #007bff);
    color: var(--cc-accent-text, #ffffff);
}

/* Buttons section (ramane vizibila, fara scroll) */
#cookie-consent-v2-banner .cookie-consent-v2-buttons {
    /* Mobil: 8% din ecran */
    height: 8vh;
    height: 8dvh;

    flex: 0 0 auto;
    min-height: 0;
    overflow: hidden;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    margin: 0;
    padding: 0 12px;

    text-align: center;
}

/* Desktop: 4.27vh */
@media (min-width: 640px) {
    #cookie-consent-v2-banner .cookie-consent-v2-buttons {
        height: 4.27vh;
        height: 4.27dvh;
    }
}

#cookie-consent-v2-reject-button,
#cookie-consent-v2-accept-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 48%;
    height: 100%;

    /* fara padding vertical ca sa nu depaseasca containerul fix */
    padding: 0 10px;

    border: none;
    background-color: var(--cc-accent, #007bff);
    color: var(--cc-accent-text, #ffffff);
    cursor: pointer;
    font-size: 1em;
    line-height: 1.2;
}

#cookie-consent-v2-reject-button:hover,
#cookie-consent-v2-accept-button:hover {
    background-color: var(--cc-accent, #007bff);
}

/* Preferences button (Change preferences) - foloseste Accent color si este sigur vizibil */
#cookie-consent-v2-preferences-button-duplicate {
    padding: 0 1.5em;
    height: 3em;

    background-color: var(--cc-accent, #007bff);
    opacity: 0.5;
    color: var(--cc-accent-text, #ffffff);

    font-size: 1em;
    font-weight: bold;
    border: none;
    border-radius: 20px;

    display: flex;
    align-items: center;
    justify-content: center;

    position: fixed;
    bottom: calc(1em + 8px);
    right: calc(1em + 8px);
    left: auto;

    z-index: 1;

    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#cookie-consent-v2-preferences-button-duplicate:hover {
    opacity: 1;
}

#cookie-consent-v2-preferences-button-duplicate::before {
    content: "⚙ ";
    font-size: 1em;
    margin-right: 5px;
}

/* Simplified styles for the cookie consent modal */
#cookie-consent-v2-preferences-modal {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;

    background-color: #ffffff;
    color: var(--cc-text, #111111);

    padding: 20px;
    border-top: 1px solid #ccc;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);

    z-index: 9998;
}

#cookie-consent-v2-preferences-modal .modal-content {
    max-height: 70vh;
    max-height: 70dvh;
    overflow-y: auto;
    padding-bottom: 20px;
}

#cookie-consent-v2-preferences-modal .close {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 30px;
    cursor: pointer;
}

/* Save Preferences button - foloseste Accent color */
#cookie-consent-v2-preferences-modal #cookie-consent-v2-save-preferences {
    padding: 10px 20px;
    background-color: var(--cc-accent, #007bff);
    border: none;
    color: var(--cc-accent-text, #ffffff);
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
    display: block;
    width: auto;
}

#cookie-consent-v2-preferences-modal.show {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
}

/* Desktop modal adjustments */
@media (min-width: 640px) {
    #cookie-consent-v2-preferences-modal {
        width: 420px;
        right: 20px;
        bottom: 12px;
        left: auto;
        max-height: 60vh;
        max-height: 60dvh;
        height: auto;
    }
}