/**
 * Cookie Consent Banner Styles
 * Bootstrap 5 compatible, responsive design
 */

/* Cookie Consent Banner */
#cookie-consent-banner {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    width: auto;
    max-width: 920px;
    margin: 0 auto;
    background: #ffffff;
    color: #1f2d33;
    border: 1px solid #b8ccc7;
    border-radius: 16px;
    box-shadow: 0 18px 44px rgba(12, 40, 44, 0.18);
    z-index: 1050;
    padding: 1.1rem 1.25rem;
    transform: translateY(12px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-height: min(70vh, 320px);
    overflow-y: auto;
}

/* Show banner when consent not recorded or when .show class is added */
#cookie-consent-banner.show:not(.consent-recorded),
#cookie-consent-banner:not(.consent-recorded) {
    transform: translateY(0) !important;
    opacity: 1;
    visibility: visible;
    display: block !important;
}

/* Hide banner when consent has been recorded */
#cookie-consent-banner.consent-recorded {
    transform: translateY(100%) !important;
    opacity: 0;
    visibility: hidden;
    display: none !important;
}

/* Ensure banner stays hidden even if show class is accidentally added after consent */
#cookie-consent-banner.consent-recorded.show {
    transform: translateY(100%) !important;
    display: none !important;
}

/* Dark mode support */
[data-theme="dark"] #cookie-consent-banner {
    background: #212529;
    border-top-color: #495057;
    color: #f8f9fa;
}

/* Banner Content */
.cookie-consent-content {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    max-width: none;
    margin: 0;
}

.cookie-consent-text {
    flex: 1;
    margin-bottom: 0;
    line-height: 1.5;
}

.cookie-consent-text h3 {
    color: #056269;
}

.cookie-consent-text p {
    margin-bottom: 0.5rem;
}

.cookie-consent-text a {
    text-decoration: underline;
}

.cookie-consent-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0;
}

/* Buttons */
#cookie-consent-accept,
#cookie-consent-reject,
#cookie-consent-customize {
    white-space: nowrap;
}

#cookie-consent-reject {
    background-color: #ffffff;
    border-color: #b8ccc7;
    color: #1f2d33;
}

#cookie-consent-reject:hover {
    background-color: #f3f7f6;
    border-color: #056269;
    color: #056269;
}

#cookie-consent-customize {
    background-color: transparent;
    border-color: #056269;
    color: #056269;
}

#cookie-consent-customize:hover {
    background-color: #056269;
    color: #ffffff;
}

[data-theme="dark"] #cookie-consent-customize {
    border-color: #6c757d;
    color: #adb5bd;
}

[data-theme="dark"] #cookie-consent-customize:hover {
    background-color: #6c757d;
    color: #ffffff;
}

/* Modal Styles */
#cookie-consent-modal .modal-header {
    border-bottom: 1px solid #dee2e6;
}

#cookie-consent-modal .modal-footer {
    border-top: 1px solid #dee2e6;
}

[data-theme="dark"] #cookie-consent-modal .modal-header,
[data-theme="dark"] #cookie-consent-modal .modal-footer {
    border-color: #495057;
}

/* Cookie Category Items */
.cookie-category-item {
    padding: 1.25rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    background: #f8f9fa;
}

[data-theme="dark"] .cookie-category-item {
    background: #343a40;
    border-color: #495057;
}

.cookie-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.cookie-category-title {
    font-weight: 600;
    margin: 0;
    font-size: 1.1rem;
}

.cookie-category-description {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 0;
    line-height: 1.5;
}

[data-theme="dark"] .cookie-category-description {
    color: #adb5bd;
}

/* Toggle Switch */
.cookie-toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.cookie-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.cookie-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.cookie-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .cookie-toggle-slider {
    background-color: #0d6efd;
}

input:focus + .cookie-toggle-slider {
    box-shadow: 0 0 1px #0d6efd;
}

input:checked + .cookie-toggle-slider:before {
    transform: translateX(24px);
}

input:disabled + .cookie-toggle-slider {
    opacity: 0.6;
    cursor: not-allowed;
}

input:disabled:checked + .cookie-toggle-slider {
    background-color: #198754;
}

/* Required Badge */
.cookie-required-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    background-color: #198754;
    color: #ffffff;
    border-radius: 0.25rem;
    margin-left: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    #cookie-consent-banner {
        left: 10px;
        right: 10px;
        bottom: 10px;
        padding: 1rem;
        max-height: 70vh;
    }

    .cookie-consent-content {
        flex-direction: column;
        align-items: stretch;
    }
    
    .cookie-consent-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    #cookie-consent-accept,
    #cookie-consent-reject,
    #cookie-consent-customize {
        width: 100%;
    }
    
    .cookie-category-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .cookie-toggle-switch {
        align-self: flex-end;
    }
}

/* Animation for banner appearance */
@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

#cookie-consent-banner.show {
    animation: slideUp 0.3s ease-out;
}

/* Accessibility - Only hide if explicitly set to hidden AND consent recorded */
#cookie-consent-banner[aria-hidden="true"].consent-recorded {
    display: none;
}

/* Ensure banner is visible when consent not recorded, even if aria-hidden is set */
#cookie-consent-banner:not(.consent-recorded) {
    display: block !important;
}

#cookie-consent-banner:focus {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

/* Ensure banner doesn't overlap with other fixed elements */
body.cookie-banner-visible {
    padding-bottom: 140px;
}

@media (max-width: 768px) {
    body.cookie-banner-visible {
        padding-bottom: 220px;
    }
}
