/* ========================================
   网盘按钮统一左对齐修复 - 终极版
   让1-4个按钮也像5-6个按钮那样左对齐排列
   版本: 1.0.2 - 终极增强版
   ======================================== */

/* 
 * 修复目标：
 * - 1-4个按钮：改为左对齐排列（原来是居中）
 * - 5-6个按钮：保持左对齐排列（已经正常）
 * - 所有按钮：统一使用左对齐的flex布局
 * 
 * 修复策略：
 * - 使用最高优先级选择器
 * - 覆盖所有可能的居中对齐样式
 * - 针对内联样式使用属性选择器
 */

/* ========================================
   超高优先级：强制左对齐所有按钮容器
   ======================================== */

/* 1. 强制所有可能的按钮容器左对齐 */
body .zib-netdisk-download-shortcode,
body .zib-netdisk-download-section,
body div[id^="zib-netdisk-buttons-"],
body div[id^="zib-netdisk-shortcode-"],
body.single .zib-netdisk-download-shortcode,
body.single .zib-netdisk-download-section,
body.single div[id^="zib-netdisk-buttons-"],
body.single div[id^="zib-netdisk-shortcode-"] {
    text-align: left !important;
}

/* 2. 强制所有内部div容器左对齐 */
body .zib-netdisk-download-shortcode > div,
body .zib-netdisk-download-section > div,
body div[id^="zib-netdisk-buttons-"] > div,
body div[id^="zib-netdisk-shortcode-"] > div,
body .zib-netdisk-download-shortcode div,
body .zib-netdisk-download-section div,
body div[id^="zib-netdisk-buttons-"] div,
body div[id^="zib-netdisk-shortcode-"] div {
    text-align: left !important;
}

/* 3. 强制所有flex容器左对齐 - 包括所有可能的写法 */
body .zib-netdisk-download-shortcode div[style*="display:flex"],
body .zib-netdisk-download-shortcode div[style*="display: flex"],
body .zib-netdisk-download-shortcode div[style*="display:Flex"],
body .zib-netdisk-download-shortcode div[style*="display: Flex"],
body .zib-netdisk-download-section div[style*="display:flex"],
body .zib-netdisk-download-section div[style*="display: flex"],
body div[id^="zib-netdisk-buttons-"] div[style*="display:flex"],
body div[id^="zib-netdisk-buttons-"] div[style*="display: flex"],
body .zib-netdisk-download-shortcode div[style*="flex"],
body .zib-netdisk-download-section div[style*="flex"],
body div[id^="zib-netdisk-buttons-"] div[style*="flex"] {
    justify-content: flex-start !important;
    text-align: left !important;
}

/* 4. 强制覆盖所有可能的居中对齐样式 */
body .zib-netdisk-download-shortcode div[style*="justify-content"],
body .zib-netdisk-download-section div[style*="justify-content"],
body div[id^="zib-netdisk-buttons-"] div[style*="justify-content"],
body .zib-netdisk-download-shortcode div[style*="text-align"],
body .zib-netdisk-download-section div[style*="text-align"],
body div[id^="zib-netdisk-buttons-"] div[style*="text-align"] {
    justify-content: flex-start !important;
    text-align: left !important;
}

/* 5. 强制覆盖table相关的居中对齐 */
body .zib-netdisk-download-shortcode table,
body .zib-netdisk-download-section table,
body div[id^="zib-netdisk-buttons-"] table {
    text-align: left !important;
    margin-left: 0 !important;
    margin-right: auto !important;
}

/* ========================================
   桌面端：所有按钮左对齐排列 - 超高优先级
   ======================================== */

@media (min-width: 769px) {
    /* 强制所有按钮容器使用flex布局，左对齐 - 超高优先级 */
    body .zib-netdisk-download-shortcode > div[style*="display"],
    body .zib-netdisk-download-section > div[style*="display"],
    body div[id^="zib-netdisk-buttons-"] > div[style*="display"],
    body.single .zib-netdisk-download-shortcode > div[style*="display"],
    body.single .zib-netdisk-download-section > div[style*="display"],
    body.single div[id^="zib-netdisk-buttons-"] > div[style*="display"] {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;  /* 左对齐 */
        align-items: flex-start !important;
        gap: 15px !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        text-align: left !important;
    }

    /* 强制按钮外层div不限制宽度 - 超高优先级 */
    body .zib-netdisk-download-shortcode > div > div,
    body .zib-netdisk-download-section > div > div,
    body div[id^="zib-netdisk-buttons-"] > div > div,
    body.single .zib-netdisk-download-shortcode > div > div,
    body.single .zib-netdisk-download-section > div > div,
    body.single div[id^="zib-netdisk-buttons-"] > div > div {
        width: auto !important;
        max-width: none !important;
        min-width: auto !important;
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        text-align: left !important;
    }

    /* tbody使用flex布局，左对齐 - 超高优先级 */
    body .zib-netdisk-download-shortcode tbody,
    body .zib-netdisk-download-section tbody,
    body div[id^="zib-netdisk-buttons-"] tbody,
    body.single .zib-netdisk-download-shortcode tbody,
    body.single .zib-netdisk-download-section tbody,
    body.single div[id^="zib-netdisk-buttons-"] tbody {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;  /* 左对齐 */
        align-items: center !important;
        gap: 16px !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        text-align: left !important;
    }

    /* tr使用contents，不影响布局 */
    body .zib-netdisk-download-shortcode tr,
    body .zib-netdisk-download-section tr,
    body div[id^="zib-netdisk-buttons-"] tr {
        display: contents !important;
    }

    /* 强制覆盖所有可能的居中对齐样式 - 超高优先级 */
    body .zib-netdisk-download-shortcode[style*="text-align"],
    body .zib-netdisk-download-section[style*="text-align"],
    body div[id^="zib-netdisk-buttons-"][style*="text-align"],
    body.single .zib-netdisk-download-shortcode[style*="text-align"],
    body.single .zib-netdisk-download-section[style*="text-align"],
    body.single div[id^="zib-netdisk-buttons-"][style*="text-align"] {
        text-align: left !important;
    }

    /* 强制覆盖内部div的居中对齐 - 超高优先级 */
    body .zib-netdisk-download-shortcode div[style*="justify-content:center"],
    body .zib-netdisk-download-shortcode div[style*="justify-content: center"],
    body .zib-netdisk-download-section div[style*="justify-content:center"],
    body .zib-netdisk-download-section div[style*="justify-content: center"],
    body div[id^="zib-netdisk-buttons-"] div[style*="justify-content:center"],
    body div[id^="zib-netdisk-buttons-"] div[style*="justify-content: center"],
    body .zib-netdisk-download-shortcode div[style*="justify-content"],
    body .zib-netdisk-download-section div[style*="justify-content"],
    body div[id^="zib-netdisk-buttons-"] div[style*="justify-content"] {
        justify-content: flex-start !important;
    }

    /* 强制覆盖按钮包裹div的样式 - 超高优先级 */
    body .zib-netdisk-download-shortcode > div[style*="display:flex"],
    body .zib-netdisk-download-shortcode > div[style*="display: flex"],
    body .zib-netdisk-download-section > div[style*="display:flex"],
    body .zib-netdisk-download-section > div[style*="display: flex"],
    body .zib-netdisk-download-shortcode > div[style],
    body .zib-netdisk-download-section > div[style],
    body div[id^="zib-netdisk-buttons-"] > div[style] {
        justify-content: flex-start !important;
        text-align: left !important;
    }

    /* 强制覆盖按钮外层div - 超高优先级 */
    body .zib-netdisk-download-shortcode div[style*="width:calc(50%"],
    body .zib-netdisk-download-section div[style*="width:calc(50%"],
    body .zib-netdisk-download-shortcode div[style*="width: calc(50%"],
    body .zib-netdisk-download-section div[style*="width: calc(50%"] {
        text-align: left !important;
    }

    /* td作为按钮容器 - 超高优先级 */
    .zib-netdisk-download-shortcode td,
    .zib-netdisk-download-section td,
    div[id^="zib-netdisk-buttons-"] td {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex: 0 0 auto !important;  /* 不拉伸，自适应宽度 */
        width: auto !important;
        min-width: auto !important;
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        background: transparent !important;
        text-align: center !important;
        vertical-align: middle !important;
    }

    /* 按钮样式 */
    .zib-netdisk-download-shortcode td .zib-netdisk-btn,
    .zib-netdisk-download-section td .zib-netdisk-btn,
    div[id^="zib-netdisk-buttons-"] td .zib-netdisk-btn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        padding: 12px 24px !important;
        background: #1578f8 !important;
        color: white !important;
        text-decoration: none !important;
        border-radius: 6px !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        transition: all 0.3s ease !important;
        box-shadow: 0 2px 8px rgba(21, 120, 248, 0.3) !important;
        border: none !important;
        cursor: pointer !important;
        white-space: nowrap !important;
        min-width: 140px !important;
        width: auto !important;
        max-width: none !important;
        margin: 0 !important;
    }

    /* 覆盖所有可能的居中对齐样式 */
    .zib-netdisk-download-shortcode tbody[data-button-count],
    .zib-netdisk-download-section tbody[data-button-count],
    div[id^="zib-netdisk-buttons-"] tbody[data-button-count] {
        justify-content: flex-start !important;  /* 强制左对齐 */
    }

    /* 移除3个按钮的特殊Grid布局 */
    .zib-netdisk-download-shortcode tbody[data-button-count="3"],
    .zib-netdisk-download-section tbody[data-button-count="3"],
    div[id^="zib-netdisk-buttons-"] tbody[data-button-count="3"] {
        display: flex !important;  /* 覆盖Grid布局 */
        grid-template-columns: none !important;
        justify-content: flex-start !important;  /* 左对齐 */
    }

    /* 移除3个按钮的特殊td样式 */
    .zib-netdisk-download-shortcode tbody[data-button-count="3"] td,
    .zib-netdisk-download-section tbody[data-button-count="3"] td,
    div[id^="zib-netdisk-buttons-"] tbody[data-button-count="3"] td {
        grid-column: auto !important;
        justify-content: center !important;  /* td内部按钮居中 */
        flex: 0 0 auto !important;
        width: auto !important;
    }

    /* 移除特殊对齐类 */
    .zib-netdisk-download-shortcode tbody.flex-3-buttons,
    .zib-netdisk-download-section tbody.flex-3-buttons,
    div[id^="zib-netdisk-buttons-"] tbody.flex-3-buttons,
    .zib-netdisk-download-shortcode tbody.absolute-3-buttons,
    .zib-netdisk-download-section tbody.absolute-3-buttons,
    div[id^="zib-netdisk-buttons-"] tbody.absolute-3-buttons {
        display: flex !important;
        position: static !important;
        justify-content: flex-start !important;  /* 左对齐 */
        height: auto !important;
    }

    /* 移除绝对定位 */
    .zib-netdisk-download-shortcode tbody.absolute-3-buttons td,
    .zib-netdisk-download-section tbody.absolute-3-buttons td,
    div[id^="zib-netdisk-buttons-"] tbody.absolute-3-buttons td {
        position: static !important;
        left: auto !important;
        right: auto !important;
        transform: none !important;
        width: auto !important;
        height: auto !important;
    }

    /* 移除表格布局的特殊样式 */
    .zib-netdisk-download-shortcode table.table-3-buttons,
    .zib-netdisk-download-section table.table-3-buttons,
    div[id^="zib-netdisk-buttons-"] table.table-3-buttons {
        display: block !important;
        table-layout: auto !important;
    }

    .zib-netdisk-download-shortcode table.table-3-buttons tbody,
    .zib-netdisk-download-section table.table-3-buttons tbody,
    div[id^="zib-netdisk-buttons-"] table.table-3-buttons tbody {
        display: flex !important;
        justify-content: flex-start !important;  /* 左对齐 */
    }

    .zib-netdisk-download-shortcode table.table-3-buttons tr,
    .zib-netdisk-download-section table.table-3-buttons tr,
    div[id^="zib-netdisk-buttons-"] table.table-3-buttons tr {
        display: contents !important;
    }

    .zib-netdisk-download-shortcode table.table-3-buttons td,
    .zib-netdisk-download-section table.table-3-buttons td,
    div[id^="zib-netdisk-buttons-"] table.table-3-buttons td {
        display: flex !important;
        width: auto !important;
        text-align: center !important;
        padding: 0 !important;
    }
}

/* ========================================
   移动端：保持原有布局
   ======================================== */

@media (max-width: 768px) {
    /* 移动端使用flex布局，两列显示 */
    .zib-netdisk-download-shortcode tbody,
    .zib-netdisk-download-section tbody,
    div[id^="zib-netdisk-buttons-"] tbody {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 12px !important;
        width: 100% !important;
    }

    .zib-netdisk-download-shortcode tr,
    .zib-netdisk-download-section tr,
    div[id^="zib-netdisk-buttons-"] tr {
        display: contents !important;
    }

    .zib-netdisk-download-shortcode td,
    .zib-netdisk-download-section td,
    div[id^="zib-netdisk-buttons-"] td {
        display: flex !important;
        flex: 0 0 calc(50% - 6px) !important;
        max-width: calc(50% - 6px) !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .zib-netdisk-download-shortcode td .zib-netdisk-btn,
    .zib-netdisk-download-section td .zib-netdisk-btn,
    div[id^="zib-netdisk-buttons-"] td .zib-netdisk-btn {
        width: 100% !important;
        min-width: 0 !important;
        padding: 10px 16px !important;
        font-size: 13px !important;
    }
}

@media (max-width: 480px) {
    .zib-netdisk-download-shortcode td .zib-netdisk-btn,
    .zib-netdisk-download-section td .zib-netdisk-btn,
    div[id^="zib-netdisk-buttons-"] td .zib-netdisk-btn {
        padding: 10px 12px !important;
        font-size: 12px !important;
    }
}

/* ========================================
   调试辅助样式（可选）
   ======================================== */

/* 添加调试边框，方便查看布局（开发时使用） */
/*
.zib-netdisk-download-shortcode tbody,
.zib-netdisk-download-section tbody,
div[id^="zib-netdisk-buttons-"] tbody {
    outline: 2px dashed red !important;
}

.zib-netdisk-download-shortcode td,
.zib-netdisk-download-section td,
div[id^="zib-netdisk-buttons-"] td {
    outline: 1px solid blue !important;
}
*/
