/**
 * Cookie Banner Styles
 *
 * EU GDPR/ePrivacy-compliant cookie consent banner
 *
 * @package TFM_Cloud_Services
 * @since 2.2.0
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
    --tfmcs-cookie-bg: #ffffff;
    --tfmcs-cookie-text: #333333;
    --tfmcs-cookie-text-muted: #666666;
    --tfmcs-cookie-border: #e0e0e0;
    --tfmcs-cookie-primary: #0073aa;
    --tfmcs-cookie-primary-hover: #005a87;
    --tfmcs-cookie-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
    --tfmcs-cookie-radius: 4px;
    --tfmcs-cookie-spacing: 16px;
    --tfmcs-cookie-z-index: 999999;
}

/* ==========================================================================
   Banner Container
   ========================================================================== */

.tfmcs-cookie-banner {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: var(--tfmcs-cookie-bg) !important;
    box-shadow: var(--tfmcs-cookie-shadow) !important;
    z-index: var(--tfmcs-cookie-z-index) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    color: var(--tfmcs-cookie-text) !important;
    transform: translateY(100%) !important;
    transition: transform 0.3s ease-out !important;
    box-sizing: border-box !important;
}

.tfmcs-cookie-banner *,
.tfmcs-cookie-banner *::before,
.tfmcs-cookie-banner *::after {
    box-sizing: border-box;
}

.tfmcs-cookie-banner[data-state="visible"] {
    transform: translateY(0) !important;
}

.tfmcs-cookie-banner[data-state="hidden"] {
    transform: translateY(100%) !important;
}

/* ==========================================================================
   Banner Content
   ========================================================================== */

.tfmcs-cookie-banner-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--tfmcs-cookie-spacing);
}

.tfmcs-cookie-banner-header {
    margin-bottom: 8px;
}

.tfmcs-cookie-banner-title {
    margin: 0;
    padding: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--tfmcs-cookie-text);
    line-height: 1.3;
}

.tfmcs-cookie-banner-body {
    margin-bottom: var(--tfmcs-cookie-spacing);
}

.tfmcs-cookie-banner-message {
    margin: 0;
    padding: 0;
    color: var(--tfmcs-cookie-text-muted);
}

.tfmcs-cookie-privacy-link {
    color: var(--tfmcs-cookie-primary);
    text-decoration: underline;
}

.tfmcs-cookie-privacy-link:hover,
.tfmcs-cookie-privacy-link:focus {
    color: var(--tfmcs-cookie-primary-hover);
    text-decoration: none;
}

/* ==========================================================================
   Banner Actions
   ========================================================================== */

.tfmcs-cookie-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.tfmcs-cookie-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    border-radius: var(--tfmcs-cookie-radius);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    border: 2px solid transparent;
    font-family: inherit;
    white-space: nowrap;
}

.tfmcs-cookie-btn:focus {
    outline: 2px solid var(--tfmcs-cookie-primary);
    outline-offset: 2px;
}

.tfmcs-cookie-btn:focus:not(:focus-visible) {
    outline: none;
}

.tfmcs-cookie-btn:focus-visible {
    outline: 2px solid var(--tfmcs-cookie-primary);
    outline-offset: 2px;
}

/* Primary Button */
.tfmcs-cookie-btn-primary {
    background-color: var(--tfmcs-cookie-primary);
    border-color: var(--tfmcs-cookie-primary);
    color: #ffffff;
}

.tfmcs-cookie-btn-primary:hover {
    background-color: var(--tfmcs-cookie-primary-hover);
    border-color: var(--tfmcs-cookie-primary-hover);
}

/* Secondary Button */
.tfmcs-cookie-btn-secondary {
    background-color: transparent;
    border-color: var(--tfmcs-cookie-border);
    color: var(--tfmcs-cookie-text);
}

.tfmcs-cookie-btn-secondary:hover {
    background-color: #f5f5f5;
    border-color: #cccccc;
}

/* Link Button */
.tfmcs-cookie-btn-link {
    background-color: transparent;
    border-color: transparent;
    color: var(--tfmcs-cookie-primary);
    padding: 10px 12px;
}

.tfmcs-cookie-btn-link:hover {
    color: var(--tfmcs-cookie-primary-hover);
    text-decoration: underline;
}

/* ==========================================================================
   Preferences Panel
   ========================================================================== */

.tfmcs-cookie-preferences-panel {
    margin-top: var(--tfmcs-cookie-spacing);
    padding-top: var(--tfmcs-cookie-spacing);
    border-top: 1px solid var(--tfmcs-cookie-border);
}

.tfmcs-cookie-preferences-panel[hidden] {
    display: none;
}

/* ==========================================================================
   Cookie Categories
   ========================================================================== */

.tfmcs-cookie-category {
    padding: 12px 0;
    border-bottom: 1px solid var(--tfmcs-cookie-border);
}

.tfmcs-cookie-category:last-of-type {
    border-bottom: none;
}

.tfmcs-cookie-category-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--tfmcs-cookie-spacing);
}

.tfmcs-cookie-category-info {
    flex: 1;
    min-width: 0;
}

.tfmcs-cookie-category-title {
    margin: 0 0 4px 0;
    padding: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--tfmcs-cookie-text);
    line-height: 1.3;
}

.tfmcs-cookie-category-title label {
    cursor: pointer;
}

.tfmcs-cookie-category-desc {
    margin: 0;
    padding: 0;
    font-size: 13px;
    color: var(--tfmcs-cookie-text-muted);
}

.tfmcs-cookie-category-toggle {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.tfmcs-cookie-always-active {
    font-size: 12px;
    font-weight: 500;
    color: #2e7d32;
    background: #e8f5e9;
    padding: 4px 10px;
    border-radius: 12px;
}

/* ==========================================================================
   Toggle Switch
   ========================================================================== */

.tfmcs-cookie-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.tfmcs-cookie-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.tfmcs-cookie-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cccccc;
    transition: background-color 0.2s ease;
    border-radius: 26px;
}

.tfmcs-cookie-slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    transition: transform 0.2s ease;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.tfmcs-cookie-switch input:checked + .tfmcs-cookie-slider {
    background-color: var(--tfmcs-cookie-primary);
}

.tfmcs-cookie-switch input:checked + .tfmcs-cookie-slider::before {
    transform: translateX(22px);
}

.tfmcs-cookie-switch input:focus + .tfmcs-cookie-slider {
    box-shadow: 0 0 0 2px var(--tfmcs-cookie-primary);
}

.tfmcs-cookie-switch input:focus:not(:focus-visible) + .tfmcs-cookie-slider {
    box-shadow: none;
}

.tfmcs-cookie-switch input:focus-visible + .tfmcs-cookie-slider {
    box-shadow: 0 0 0 2px var(--tfmcs-cookie-primary);
}

/* ==========================================================================
   Preferences Actions
   ========================================================================== */

.tfmcs-cookie-preferences-actions {
    margin-top: var(--tfmcs-cookie-spacing);
    display: flex;
    justify-content: flex-end;
}

/* ==========================================================================
   Preferences Link (for footer/shortcode)
   ========================================================================== */

.tfmcs-cookie-preferences-link {
    color: var(--tfmcs-cookie-primary);
    text-decoration: underline;
    cursor: pointer;
}

.tfmcs-cookie-preferences-link:hover,
.tfmcs-cookie-preferences-link:focus {
    color: var(--tfmcs-cookie-primary-hover);
    text-decoration: none;
}

/* ==========================================================================
   Screen Reader Text
   ========================================================================== */

.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media screen and (max-width: 600px) {
    .tfmcs-cookie-banner-content {
        padding: 12px;
    }

    .tfmcs-cookie-banner-title {
        font-size: 16px;
    }

    .tfmcs-cookie-banner-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .tfmcs-cookie-btn {
        width: 100%;
        text-align: center;
    }

    .tfmcs-cookie-btn-link {
        order: 1;
    }

    .tfmcs-cookie-category-header {
        flex-direction: column;
        gap: 8px;
    }

    .tfmcs-cookie-category-toggle {
        align-self: flex-end;
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .tfmcs-cookie-banner {
        transition: none;
    }

    .tfmcs-cookie-slider,
    .tfmcs-cookie-slider::before,
    .tfmcs-cookie-btn {
        transition: none;
    }
}

/* ==========================================================================
   High Contrast Mode
   ========================================================================== */

@media (prefers-contrast: high) {
    .tfmcs-cookie-banner {
        border-top: 2px solid #000000;
    }

    .tfmcs-cookie-btn {
        border-width: 2px;
    }

    .tfmcs-cookie-btn-primary {
        background-color: #000000;
        border-color: #000000;
    }

    .tfmcs-cookie-btn-primary:hover {
        background-color: #333333;
        border-color: #333333;
    }

    .tfmcs-cookie-btn-secondary {
        border-color: #000000;
    }

    .tfmcs-cookie-slider {
        background-color: #666666;
        border: 2px solid #000000;
    }

    .tfmcs-cookie-switch input:checked + .tfmcs-cookie-slider {
        background-color: #000000;
    }

    .tfmcs-cookie-switch input:focus + .tfmcs-cookie-slider {
        box-shadow: 0 0 0 3px #000000;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .tfmcs-cookie-banner {
        display: none !important;
    }
}

/* ==========================================================================
   Legal Links (Footer Shortcode)
   ========================================================================== */

.tfmcs-legal-links {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5em;
    font-size: inherit;
    line-height: inherit;
}

.tfmcs-legal-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: transparent;
    transition: text-decoration-color 0.2s ease;
}

.tfmcs-legal-link:hover,
.tfmcs-legal-link:focus {
    text-decoration-color: currentColor;
}

.tfmcs-legal-separator {
    opacity: 0.6;
}
