/* Custom Drawer Component Styles */

:root {
    /* CSS变量定义 */
    --drawer-width: 440px;
    --drawer-position: right;
    --overlay-opacity: 0.5;
    --drawer-background: #ffffff;
    --drawer-text-color: #000000;
    --drawer-padding: 20px;
    --animation-duration: 200ms;
}

.custom-drawer {
    position: fixed;
    z-index: 999;
    top: 0;
    width: 100vw;
    height: 100%;
    display: flex;
    background-color: rgba(var(--color-mask), var(--overlay-opacity, 0.5));
    transition: visibility var(--animation-duration) ease;
    visibility: hidden;
}

.custom-drawer.active {
    visibility: visible;
}

/* 左侧抽屉 */
.custom-drawer[data-drawer-position="left"] {
    left: 0;
    justify-content: flex-start;
}

/* 右侧抽屉 */
.custom-drawer[data-drawer-position="right"] {
    right: 0;
    justify-content: flex-end;
}

.custom-drawer-container {
    width: var(--drawer-width, 440px);
    height: 100%;
    position: relative;
}

.custom-drawer__overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    cursor: pointer;
    z-index: -1;
}

.custom-drawer__body {
    height: 100%;
    overflow: hidden;
    transition: transform var(--animation-duration) ease;
    display: flex;
    flex-direction: column;
    background-color: var(--drawer-background, rgb(var(--color-page-background)));
    color: var(--drawer-text-color, rgb(var(--color-text)));
    position: relative;
    z-index: 1;
}

/* 左侧抽屉动画 */
.custom-drawer[data-drawer-position="left"] .custom-drawer__body {
    transform: translateX(-100%);
}

.custom-drawer[data-drawer-position="left"].active .custom-drawer__body {
    transform: translateX(0);
}

/* 右侧抽屉动画 */
.custom-drawer[data-drawer-position="right"] .custom-drawer__body {
    transform: translateX(100%);
}

.custom-drawer[data-drawer-position="right"].active .custom-drawer__body {
    transform: translateX(0);
}

.custom-drawer__inner {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

/* 头部样式 */
.custom-drawer__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgb(var(--color-entry-line));
    gap: 15px;
}

.custom-drawer__heading {
    margin: 0;
    font-weight: 600;
    flex: 1;
    min-width: 0;
}

.custom-drawer__close {
    color: var(--drawer-text-color, rgb(var(--color-text)));
    cursor: pointer;
    width: 36px;
    height: 36px;
    line-height: 0;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

/* 独立关闭按钮样式（不在头部内时） */
.custom-drawer__inner>.custom-drawer__close {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
}

.custom-drawer__close:hover {
    background-color: rgba(var(--color-entry-line), 0.1);
}

/* 内容区域 */
.custom-drawer__content {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.custom-drawer__content::-webkit-scrollbar {
    width: 3px;
}

.custom-drawer__content::-webkit-scrollbar-thumb {
    background-color: rgba(var(--color-text), 0.3);
    border-radius: 100px;
}

.custom-drawer__content::-webkit-scrollbar-track {
    background: transparent;
}

/* 块样式 */
.custom-drawer__block {
    margin-bottom: 24px;
}

.custom-drawer__block:last-child {
    margin-bottom: 0;
}

/* 文本块 */
.custom-drawer__text-block {
    line-height: 1.6;
}

.custom-drawer__block-heading {
    margin: 12px 0 12px 0;
    font-weight: 600;
}

.custom-drawer__block-text {
    margin: 0;
}

.custom-drawer__block-text p {
    margin: 0 0 12px 0;
}

.custom-drawer__block-text p:last-child {
    margin-bottom: 0;
}

/* 图片块 */
.custom-drawer__image-block {
    text-align: center;
}

.custom-drawer__image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.custom-drawer__image-link {
    display: inline-block;
    transition: opacity 0.2s ease;
}

.custom-drawer__image-link:hover {
    opacity: 0.8;
}

.custom-drawer__image-caption {
    margin: 8px 0 0 0;
    color: rgb(var(--color-light-text));
    font-style: italic;
}

/* 按钮块 */
.custom-drawer__button-block {
    text-align: center;
}

.custom-drawer__button {
    display: inline-block;
    min-width: 120px;
    transition: all 0.2s ease;
}

/* 自定义HTML块 */
.custom-drawer__html-block {
    line-height: 1.6;
}

/* 底部样式 */
.custom-drawer__footer {
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid rgb(var(--color-entry-line));
    text-align: center;
}

.custom-drawer__footer-text {
    margin: 0;
    color: rgb(var(--color-light-text));
}

/* 触发器样式 */
.custom-drawer__trigger-wrapper {
    margin: 20px 0;
    text-align: center;
}

.custom-drawer__trigger {
    transition: all 0.2s ease;
}

/* 响应式设计 */
@media (max-width: 959px) {
    .custom-drawer-container {
        width: 90vw;
        max-width: 400px;
    }

    .custom-drawer__inner {
        padding: 16px;
    }

    .custom-drawer__header {
        padding-bottom: 16px;
        margin-bottom: 16px;
    }

    .custom-drawer__close {
        width: 44px;
        height: 44px;
        padding: 10px;
    }

    /* 独立关闭按钮移动端样式 */
    .custom-drawer__inner>.custom-drawer__close {
        top: 16px;
        right: 16px;
    }

    .custom-drawer__block {
        margin-bottom: 20px;
    }

    .custom-drawer__button {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 16px;
    }
}

@media (max-width: 479px) {
    .custom-drawer-container {
        width: 100vw;
        max-width: none;
    }

    .custom-drawer__inner {
        padding: 16px;
    }

    .custom-drawer__header {
        padding-bottom: 12px;
        margin-bottom: 12px;
    }

    .custom-drawer__close {
        width: 48px;
        height: 48px;
        padding: 12px;
    }

    /* 独立关闭按钮小屏幕样式 */
    .custom-drawer__inner>.custom-drawer__close {
        top: 16px;
        right: 16px;
    }

    .custom-drawer__block {
        margin-bottom: 16px;
    }
}

/* 新组件样式 */

/* 视频组件 */
.custom-drawer__video-block {
    margin-bottom: 20px;
}

.custom-drawer__video-wrapper {
    position: relative;
    width: 100%;
    margin-top: 10px;
}

.custom-drawer__video {
    width: 100%;
    height: auto;
    border-radius: 8px;
    max-height: 300px;
}

iframe.custom-drawer__video {
    aspect-ratio: 16/9;
    height: auto;
}

/* 分隔线组件 */
.custom-drawer__divider-block {
    margin: 20px 0;
}

.custom-drawer__divider {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 20px 0;
}

/* 社交媒体链接组件 */
.custom-drawer__social-block {
    margin-bottom: 20px;
}

.custom-drawer__social-links {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.custom-drawer__social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #f5f5f5;
    color: #666;
    text-decoration: none;
    transition: all 0.3s ease;
}

.custom-drawer__social-link:hover {
    background-color: #e0e0e0;
    color: #333;
    transform: translateY(-2px);
}

.custom-drawer__social-link svg {
    width: 20px;
    height: 20px;
}

/* 联系表单组件 */
.custom-drawer__form-block {
    margin-bottom: 20px;
}

.custom-drawer__contact-form {
    margin-top: 15px;
}

.custom-drawer__form-field {
    margin-bottom: 15px;
}

.custom-drawer__form-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.custom-drawer__form-field input,
.custom-drawer__form-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.custom-drawer__form-field input:focus,
.custom-drawer__form-field textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.custom-drawer__form-field textarea {
    resize: vertical;
    min-height: 80px;
}

.custom-drawer__form-submit {
    width: 100%;
    margin-top: 10px;
}

/* 产品卡片组件 */
.custom-drawer__product-block {
    margin-bottom: 20px;
}

.custom-drawer__product-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.custom-drawer__product-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
}

.custom-drawer__product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.custom-drawer__product-image:hover .custom-drawer__product-img {
    transform: scale(1.05);
}

.custom-drawer__product-info {
    padding: 15px;
}

.custom-drawer__product-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.custom-drawer__product-title a {
    color: #333;
    text-decoration: none;
}

.custom-drawer__product-title a:hover {
    color: #007bff;
}

.custom-drawer__product-price {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-drawer__product-price-compare {
    color: #999;
    text-decoration: line-through;
    font-size: 14px;
}

.custom-drawer__product-price-current {
    color: #e74c3c;
    font-weight: 600;
    font-size: 16px;
}

.custom-drawer__add-to-cart {
    width: 100%;
    padding: 10px;
    font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 479px) {
    .custom-drawer-container {
        width: 100vw;
        max-width: none;
    }

    .custom-drawer__inner {
        padding: 16px;
    }

    .custom-drawer__header {
        padding-bottom: 12px;
        margin-bottom: 12px;
    }

    .custom-drawer__close {
        width: 48px;
        height: 48px;
        padding: 12px;
    }

    /* 独立关闭按钮小屏幕样式 */
    .custom-drawer__inner>.custom-drawer__close {
        top: 16px;
        right: 16px;
    }

    .custom-drawer__block {
        margin-bottom: 16px;
    }

    .custom-drawer__button {
        width: 100%;
        min-height: 48px;
        padding: 14px 20px;
        font-size: 16px;
    }

    .custom-drawer__image-block img {
        border-radius: 8px;
    }

    .custom-drawer__social-links {
        gap: 8px;
    }

    .custom-drawer__social-link {
        width: 36px;
        height: 36px;
    }

    .custom-drawer__social-link svg {
        width: 18px;
        height: 18px;
    }

    .custom-drawer__product-info {
        padding: 12px;
    }

    .custom-drawer__product-title {
        font-size: 15px;
    }

    .custom-drawer__button {
        width: 100%;
        min-height: 48px;
        padding: 14px 20px;
        font-size: 16px;
    }

    .custom-drawer__image-block img {
        border-radius: 8px;
    }
}

/* 移动端特定样式 */
@media (max-width: 767px) {

    /* 全屏模式支持 */
    .custom-drawer[data-mobile-fullscreen="true"] .custom-drawer-container {
        width: 100vw;
        height: 100vh;
    }

    .custom-drawer[data-mobile-fullscreen="true"] .custom-drawer__body {
        border-radius: 0;
    }

    /* 底部抽屉模式 */
    .custom-drawer[data-mobile-position="bottom"] {
        align-items: flex-end;
    }

    .custom-drawer[data-mobile-position="bottom"] .custom-drawer-container {
        width: 100vw;
        height: auto;
        max-height: 80vh;
    }

    .custom-drawer[data-mobile-position="bottom"] .custom-drawer__body {
        border-radius: 16px 16px 0 0;
    }

    /* 触摸优化 */
    .custom-drawer__close,
    .custom-drawer__button,
    .custom-drawer__trigger {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    /* 滑动指示器 */
    .custom-drawer[data-mobile-position="bottom"] .custom-drawer__body::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background-color: rgba(var(--color-text), 0.3);
        border-radius: 2px;
    }

    .custom-drawer[data-mobile-position="bottom"] .custom-drawer__inner {
        padding-top: 24px;
    }
}

/* 动画优化 */
@media (prefers-reduced-motion: reduce) {

    .custom-drawer,
    .custom-drawer__body,
    .custom-drawer__close,
    .custom-drawer__image-link,
    .custom-drawer__button,
    .custom-drawer__trigger {
        transition: none;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {

    .custom-drawer__header,
    .custom-drawer__footer {
        border-color: currentColor;
    }

    .custom-drawer__close:hover {
        background-color: currentColor;
        color: var(--drawer-background, rgb(var(--color-page-background)));
    }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
    .custom-drawer__content::-webkit-scrollbar-thumb {
        background-color: rgba(255, 255, 255, 0.3);
    }
}

/* 焦点样式 */
.custom-drawer__close:focus,
.custom-drawer__button:focus,
.custom-drawer__trigger:focus,
.custom-drawer__image-link:focus {
    outline: 2px solid rgb(var(--color-button-background));
    outline-offset: 2px;
}

/* 打印样式 */
@media print {
    .custom-drawer {
        display: none;
    }
}