/**
 * Cookie Consent Styles
 * GDPR/CCPA Compliant Cookie Banner and Panel
 */

/* Cookie Consent Banner */
#cookie-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #25324B 0%, #2F3F5E 100%);
    color: #ffffff;
    padding: 24px;
    z-index: 9999;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    display: none;
    animation: slideUp 0.3s ease-out;
}

/* 桌面端隐藏展开/收起按钮（移动端专用） */
#cookie-consent-banner .cookie-expand-btn,
#cookie-consent-banner .cookie-collapse-btn {
    display: none;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.cookie-banner-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: center;
    justify-content: space-between;
}

.cookie-banner-text {
    flex: 1;
    min-width: 300px;
}

.cookie-banner-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #ffffff;
}

.cookie-banner-description {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #CDD6E5;
    margin-bottom: 8px;
}

.cookie-banner-links {
    font-size: 0.875rem;
    color: rgba(226,232,240,0.85);
}

.cookie-banner-links a {
    color: #E08A34;
    text-decoration: none;
    transition: color 0.3s;
}

.cookie-banner-links a:hover {
    color: #F0A65E;
    text-decoration: underline;
}

.cookie-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.cookie-btn {
    padding: 12px 24px;
    border-radius: 2px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s;
    white-space: nowrap;
}

.cookie-btn-primary {
    background: #E08A34;
    color: #25324B;
}

.cookie-btn-primary:hover {
    background: #F0A65E;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(201, 162, 75, 0.32);
}

.cookie-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.cookie-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.cookie-btn-outline {
    background: transparent;
    color: rgba(226,232,240,0.85);
    border: 1px solid rgba(226,232,240,0.38);
}

.cookie-btn-outline:hover {
    color: #ffffff;
    border-color: rgba(226,232,240,0.85);
}

/* Cookie Preferences Panel */
#cookie-consent-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99999;
    display: none;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.cookie-panel-content {
    background: #ffffff;
    max-width: 600px;
    width: 100%;
    margin: 40px auto;
    border-radius: 2px;
    overflow: hidden;
    animation: fadeIn 0.3s ease-out;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.cookie-panel-header {
    padding: 24px;
    background: linear-gradient(135deg, #25324B 0%, #2F3F5E 100%);
    color: #ffffff;
}

.cookie-panel-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.cookie-panel-subtitle {
    font-size: 0.9rem;
    color: #CDD6E5;
}

.cookie-panel-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.cookie-panel-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.cookie-panel-body {
    padding: 24px;
}

.cookie-item {
    padding: 16px 0;
    border-bottom: 1px solid #DFE4EE;
}

.cookie-item:last-child {
    border-bottom: none;
}

.cookie-item-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.cookie-item-info {
    flex: 1;
}

.cookie-item-title {
    font-size: 1rem;
    font-weight: 600;
    color: #25324B;
    margin-bottom: 4px;
}

.cookie-item-description {
    font-size: 0.875rem;
    color: #78859C;
    line-height: 1.5;
}

.cookie-item-toggle {
    position: relative;
}

.cookie-toggle-switch {
    position: relative;
    width: 50px;
    height: 28px;
    background: #DFE4EE;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.3s;
}

.cookie-toggle-switch.active {
    background: #4A5B7A;
}

.cookie-toggle-switch.disabled {
    background: #2F6B4F;
    cursor: not-allowed;
}

.cookie-toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.cookie-toggle-switch.active .cookie-toggle-slider,
.cookie-toggle-switch.disabled .cookie-toggle-slider {
    transform: translateX(22px);
}

.cookie-item-checkbox {
    display: none;
}

.cookie-panel-footer {
    padding: 24px;
    background: #FBFCFE;
    border-top: 1px solid #DFE4EE;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-end;
}

/* 移动端优化：浮窗指纹图标 */
@media (max-width: 768px) {
    /* 默认横幅隐藏，使用浮窗图标 */
    #cookie-consent-banner {
        padding: 0;
        background: transparent;
        box-shadow: none;
    }

    /* 浮窗指纹图标 */
    .cookie-float-icon {
        position: fixed;
        bottom: 20px;
        left: 20px;
        width: 44px;
        height: 44px;
        background: #25324B;
        border-radius: 2px !important;
        border: 1px solid rgba(224, 138, 52, 0.55);
        box-shadow: none;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 9998;
        transition: border-color 0.18s ease, background-color 0.18s ease;
    }

    .cookie-float-icon:hover,
    .cookie-float-icon:focus-visible {
        transform: none;
        background: #4A5B7A;
        border-color: #F0A65E;
        box-shadow: none;
    }

    .cookie-float-icon i {
        font-size: 17px;
        color: #F0A65E;
    }

    /* 紧凑横幅（展开状态） */
    #cookie-consent-banner.expanded {
        padding: 12px 16px;
        background: linear-gradient(135deg, #25324B 0%, #2F3F5E 100%);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }

    /* 浮窗图标是 body 的后续兄弟节点，不是 #cookie-consent-banner 的后代；
       原后代选择器不会命中，展开/收起后图标上沿会从横幅边缘露出一条金边。
       JS 给图标写过 inline display:flex，因此这里必须 !important 才能覆盖。 */
    #cookie-consent-banner.expanded ~ .cookie-float-icon,
    #cookie-consent-banner.minimized[style*="display: block"] ~ .cookie-float-icon {
        display: none !important;
    }

    /* 最小化文本显示 */
    .cookie-banner-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .cookie-banner-text {
        min-width: auto;
    }

    .cookie-banner-title {
        font-size: 1rem;
        margin-bottom: 6px;
    }

    .cookie-banner-description {
        font-size: 0.85rem;
        line-height: 1.4;
        max-height: 60px;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    /* 折叠时的迷你横幅 */
    #cookie-consent-banner.minimized {
        background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
        backdrop-filter: blur(10px);
        padding: 8px 16px;
    }

    #cookie-consent-banner.minimized .cookie-banner-text {
        display: none;
    }

    #cookie-consent-banner.minimized .cookie-banner-actions {
        gap: clamp(4px, 1.2vw, 8px);
        flex-wrap: wrap;
    }

    /* 按钮样式调整
       根因：旧规则用 flex:1 + min-width:80px + white-space:nowrap 把三颗按钮
       等宽分栏，长文案（Manage Preferences / Einstellungen Verwalten ...）
       的 min-content 会撑破按钮；minimized 又强制 nowrap，整行也无法换行。
       现在改为「按内容宽度参与 flex，空间不足时整颗按钮换行」，文字不再越界。
       overflow-wrap 只是后台填入超长文案时的兜底，现有 9 语言均保持单行。 */
    .cookie-banner-actions {
        justify-content: space-between;
        min-width: 0;
        width: 100%;
        flex-wrap: wrap;
        gap: clamp(4px, 1.2vw, 8px);
        align-items: stretch;
    }

    .cookie-btn {
        flex: 1 1 max-content;
        width: max-content;
        min-width: 0;
        max-width: 100%;
        padding: 10px clamp(6px, 2vw, 10px);
        font-size: 0.85rem;
        line-height: 1.25;
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: center;
        min-height: 44px;
    }

    /* 偏好设置面板底部两颗按钮同属 .cookie-btn，沿用同一套防越界规则；
       仅把 gap 改为流体值，避免窄屏两颗长按钮挤在一行。 */
    .cookie-panel-footer {
        gap: clamp(6px, 2vw, 12px);
        align-items: stretch;
    }

    /* 展开和收起按钮 */
    .cookie-expand-btn,
    .cookie-collapse-btn {
        position: absolute;
        top: 8px;
        right: 8px;
        background: rgba(255, 255, 255, 0.1);
        border: none;
        color: #ffffff;
        width: 28px;
        height: 28px;
        border-radius: 2px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        transition: all 0.3s;
    }

    .cookie-expand-btn:hover,
    .cookie-collapse-btn:hover {
        background: rgba(255, 255, 255, 0.2);
    }

    /* 面板样式 */
    #cookie-consent-panel {
        padding: 10px;
    }

    .cookie-panel-content {
        margin: 10px auto;
        max-height: calc(100vh - 20px);
        border-radius: 2px;
    }

    .cookie-panel-close {
        top: 16px;
        right: 16px;
    }

    /* 脉冲动画 */
    @keyframes pulse {
        0% {
            box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
        }
        70% {
            box-shadow: 0 0 0 15px rgba(59, 130, 246, 0);
        }
        100% {
            box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
        }
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    #cookie-consent-banner {
        background: linear-gradient(135deg, #25324B 0%, #2F3F5E 100%);
    }
}
