/* =============================================================================
   COOKIE MANAGER STYLES
   ============================================================================= */

/* Cookie Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    color: white;
    padding: 1.5rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.cookie-banner.cookie-banner-visible {
    transform: translateY(0);
}

.cookie-banner-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.cookie-banner-text h4 {
    color: white;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.cookie-banner-text p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0;
    line-height: 1.5;
}

.cookie-banner-actions {
    display: flex;
    gap: 1rem;
    flex-shrink: 0;
}

.cookie-banner-actions .btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* 特别设置 Reject All 按钮的样式 */
#reject-all-cookies {
    background-color: white;
    color: #2d3748;
    border: 1px solid #cbd5e0;
}

#reject-all-cookies:hover {
    background-color: #f7fafc;
    border-color: #a0aec0;
}

/* Cookie Settings Modal */
.cookie-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 2rem;
}

.cookie-modal.cookie-modal-visible {
    opacity: 1;
}

.cookie-modal-content {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.cookie-modal.cookie-modal-visible .cookie-modal-content {
    transform: scale(1);
}

.cookie-modal-header {
    padding: 2rem 2rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 16px 16px 0 0;
}

.cookie-modal-header h3 {
    margin: 0;
    color: #2d3748;
    font-size: 1.5rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #718096;
    cursor: pointer;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background-color: #f1f5f9;
    color: #4a5568;
}

.cookie-modal-body {
    padding: 1rem 2rem;
}

.cookie-category {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: #f7fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.cookie-category:last-child {
    margin-bottom: 0;
}

.cookie-category-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    justify-content: space-between;
}

.cookie-category-info h4 {
    margin: 0 0 0.5rem 0;
    color: #2d3748;
    font-size: 1.1rem;
}

.cookie-category-info p {
    margin: 0;
    color: #4a5568;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Cookie Switch */
.cookie-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    margin-top: 2px;
    flex-shrink: 0;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e0;
    transition: 0.3s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background-color: #3182ce;
}

input:focus + .slider {
    box-shadow: 0 0 1px #3182ce;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

input:disabled + .slider {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #3182ce !important; /* Keep blue for required GA4 */
}

input:disabled + .slider:before {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateX(22px); /* Keep in 'on' position for GA4 */
}

/* Special styling for required analytics cookies */
#analytics-cookies:disabled + .slider {
    background-color: #3182ce !important;
    opacity: 0.8;
}

#analytics-cookies:disabled + .slider:after {
    position: absolute;
    right: -70px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: #e53e3e;
    font-weight: 600;
    white-space: nowrap;
    z-index: 1;
}

.cookie-modal-footer {
    padding: 1rem 2rem 2rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Floating Cookie Settings Button */
.cookie-settings-floating {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
}

.cookie-settings-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background-color: #3182ce;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cookie-settings-btn:hover {
    background-color: #2c5aa0;
}

.cookie-settings-btn:active {
    transform: translateY(0);
}

/* Desktop Specific Improvements */
@media (min-width: 769px) {
    .cookie-modal-content {
        max-width: 650px;
        width: 600px;
    }
    
    .cookie-category {
        margin-bottom: 1.5rem;
        padding: 2rem;
        border-radius: 12px;
    }
    
    .cookie-category-header {
        align-items: center;
        gap: 1.5rem;
    }
    
    .cookie-category-info {
        flex: 1;
    }
    
    .cookie-category-info h4 {
        font-size: 1.2rem;
        margin-bottom: 0.75rem;
    }
    
    .cookie-category-info p {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    .cookie-switch {
        margin-top: 0;
        order: 2;
    }
    
    .cookie-modal-footer {
        padding: 2rem;
        gap: 1.5rem;
    }
    
    .cookie-modal-footer .btn {
        padding: 0.875rem 2rem;
        font-size: 1rem;
        min-width: 150px;
    }
    
    /* Improve hover states for desktop */
    .cookie-category:hover {
        background-color: #edf2f7;
        border-color: #cbd5e0;
        transition: all 0.2s ease;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .cookie-banner-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .cookie-banner-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .cookie-banner-actions .btn {
        flex: 1;
        min-width: 120px;
    }
    
    .cookie-modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .cookie-modal-header,
    .cookie-modal-body,
    .cookie-modal-footer {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    
    .cookie-category {
        padding: 1rem;
    }
    
    .cookie-category-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .cookie-switch {
        align-self: flex-start;
    }
    
    .cookie-modal-footer {
        flex-direction: column;
    }
    
    .cookie-modal-footer .btn {
        width: 100%;
    }
    
    .cookie-settings-floating {
        bottom: 80px;
    }
}

@media (max-width: 480px) {
    .cookie-banner {
        padding: 1rem;
    }
    
    .cookie-banner-text h4 {
        font-size: 1.1rem;
    }
    
    .cookie-banner-text p {
        font-size: 0.9rem;
    }
    
    .cookie-banner-actions .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
    
    .cookie-modal-header {
        padding: 1.5rem 1rem 1rem;
    }
    
    .cookie-modal-body {
        padding: 1rem;
    }
    
    .cookie-modal-footer {
        padding: 1rem;
    }
    
    .cookie-category {
        padding: 0.75rem;
    }
    
    .cookie-settings-btn {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
}

/* Animation for cookie banner entrance */
@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Cookie notice for screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .cookie-banner {
        background: #000;
        border-top: 2px solid #fff;
    }
    
    .cookie-modal {
        background: rgba(0, 0, 0, 0.8);
    }
    
    .cookie-modal-content {
        border: 2px solid #000;
    }
    
    .slider {
        border: 1px solid #000;
    }
    
    input:checked + .slider {
        background-color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .cookie-banner,
    .cookie-modal,
    .cookie-modal-content,
    .cookie-settings-btn,
    .slider {
        transition: none;
    }
    
    .cookie-banner.cookie-banner-visible {
        animation: none;
    }
}