/**
 * 固件下载中心页面增强样式
 * 包含响应式设计、移动端优化和智能固定侧边栏
 */

/* ========================================
   桌面端侧边栏固定效果
   ======================================== */
@media (min-width: 992px) {
    .sidebar-sticky-wrapper {
        position: relative;
        height: 100%;
    }

    .sidebar-sticky {
        position: sticky;
        top: 20px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
        transition: all 0.3s ease;
    }

}

/* ========================================
   移动端导航样式
   ======================================== */
.firmware-mobile-nav {
    display: none;
}

@media (max-width: 991px) {
    /* 移动端导航容器 */
    .firmware-mobile-nav {
        display: block;
        background: var(--color-white, #fff);
        border-bottom: 2px solid var(--thm-f3, #f3f3f3);
        position: sticky;
        top: 48px;
        z-index: 100;
        margin: -15px -15px 20px -15px;
        padding: 0;
        box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    /* 横向滚动包装器 */
    .mobile-nav-wrapper {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding: 0 15px;
    }

    /* Safari/Chrome/WebKit 隐藏滚动条 */
    .mobile-nav-wrapper::-webkit-scrollbar {
        display: none;
        width: 0;
        height: 0;
    }


    /* 导航列表 */
    .mobile-nav-list {
        display: flex;
        flex-wrap: nowrap;
        padding: 12px 0;
        margin: 0;
        list-style: none;
        gap: 10px;
        min-width: min-content;
    }

    /* 导航项 */
    .mobile-nav-item {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    /* 导航按钮 */
    .mobile-nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 14px 18px;
        border: 2px solid var(--thm-f3, #f3f3f3);
        border-radius: 12px;
        background: var(--color-white, #fff);
        color: var(--thm-gray, #8e8e8e);
        text-decoration: none;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        min-width: 95px;
        cursor: pointer;
        position: relative;
        overflow: hidden;
    }

    /* 导航图标图片 */
    .nav-icon-img {
        width: 32px;
        height: 32px;
        object-fit: contain;
        margin-bottom: 8px;
        transition: transform 0.3s ease;
    }

    /* 导航文字 */
    .mobile-nav-btn span {
        font-size: 12px;
        font-weight: 500;
        letter-spacing: 0.02em;
        text-align: center;
    }

    /* 激活状态背景动画 */
    .mobile-nav-btn::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: var(--thm-line);
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: -1;
    }

    .mobile-nav-btn.active::before {
        transform: translateY(0);
    }

    .mobile-nav-btn.active {
        color: var(--thm-color);
        border-color: var(--thm-color);
    }

    .mobile-nav-btn.active .nav-icon-img {
        transform: scale(1.5);
    }

    /* 隐藏桌面端侧边栏 */
    .col-lg-3.col-12:first-child {
        display: none !important;
    }

    /* 移动端内容全宽 */
    .col-lg-9.col-12 {
        width: 100%;
        padding: 0;
    }
}

/* ========================================
   固件列表项样式优化
   ======================================== */
.firmware-item {
    background: var(--color-white, #fff);
    border: 1px solid var(--thm-f3, #f3f3f3);
    border-radius: 12px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.firmware-item:hover {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
    border-color: var(--thm-base, #55C6EF);
}

.firmware-info h4 {
    color: var(--thm-black, #14296C);
    font-weight: 600;
    transition: color 0.3s ease;
}

.firmware-item:hover .firmware-info h4 {
    color: var(--thm-base, #55C6EF);
}

/* ========================================
   侧边栏样式优化（桌面端）
   ======================================== */
.atf-sidebar-widget {
    background: var(--color-white, #fff);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.08);
}

.atf-sidebar-widget .atf-widget-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--thm-black, #14296C);
    margin-bottom: 20px;
    padding-bottom: 12px;
}

.atf-sidebar-widget .list-group-item {
    border: none;
    padding: 14px 18px;
    margin-bottom: 8px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    background: var(--thm-f6, #F1F8FF);
}

.atf-sidebar-widget .list-group-item span {
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 列表项图标 - 兼容 picture 标签和 img 标签 */
.atf-sidebar-widget .list-group-item span img,
.atf-sidebar-widget .list-group-item span picture {
    width: 40px;
    height: 40px;
    object-fit: contain;
    transition: transform 0.3s ease;
    display: block;
}

/* picture 标签内的 img 继承样式 */
.atf-sidebar-widget .list-group-item span picture img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    display: block;
}

.atf-sidebar-widget .list-group-item:hover {
    background: var(--thm-f3, #f3f3f3);
    transform: translateX(8px);
}

.atf-sidebar-widget .list-group-item:hover span img,
.atf-sidebar-widget .list-group-item:hover span picture {
    transform: rotate(5deg) scale(1.1);
}

.atf-sidebar-widget .list-group-item.active {
    background: var(--thm-line);
    color: var(--color-white, #fff);
    font-weight: 500;
}


/* ========================================
   内容区域样式
   ======================================== */
.tab-content {
    background: var(--color-white, #fff);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.08);
    min-height: 500px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-pane {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========================================
   下载按钮样式
   ======================================== */
.atf-themes-btn {
    background: var(--thm-line);
    color: var(--color-white, #fff);
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.atf-themes-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.atf-themes-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(31, 114, 195, 0.4);
    color: var(--color-white, #fff);
}

.atf-themes-btn:hover::before {
    width: 300px;
    height: 300px;
}

.atf-themes-btn i {
    margin-right: 8px;
}

/* ========================================
   Popover 样式优化
   ======================================== */
.popover {
    max-width: 400px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

.popover-header {
    background: var(--thm-line);
    color: var(--color-white, #fff);
    border-radius: 10px 10px 0 0;
    font-weight: 600;
    padding: 12px 16px;
}

.popover-body {
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
}

/* ========================================
   响应式调整
   ======================================== */
@media (max-width: 768px) {
    .atf-section-padding {
        padding: 40px 0;
    }

    .firmware-mobile-nav {
        margin: -10px -10px 15px -10px;
    }

    .mobile-nav-btn {
        min-width: 85px;
        padding: 12px 14px;
    }

    .nav-icon-img {
        width: 28px;
        height: 28px;
        margin-bottom: 6px;
    }

    .mobile-nav-btn span {
        font-size: 11px;
    }

    .tab-content {
        padding: 20px 15px;
        border-radius: 10px;
    }

    .firmware-item {
        margin-bottom: 10px;
    }

    .firmware-info h4 {
        font-size: 15px;
    }

    .firmware-info p {
        font-size: 13px;
    }
}

@media (max-width: 576px) {
    .firmware-mobile-nav {
        margin: -5px -5px 10px -5px;
    }

    .mobile-nav-list {
        gap: 6px;
        padding: 10px 0;
    }

    .mobile-nav-btn {
        min-width: 75px;
        padding: 10px 12px;
    }

    .atf-themes-btn {
        padding: 10px 18px;
        font-size: 14px;
    }
}

/* ========================================
   加载和错误状态样式
   ======================================== */
.list-group-item.text-center {
    padding: 30px;
    color: var(--thm-gray, #8e8e8e);
}

.list-group-item.text-center i.fa-spinner {
    font-size: 20px;
    color: var(--thm-base, #55C6EF);
}

.list-group-item.text-danger {
    color: var(--color-orange, #8c3743) !important;
}

/* ========================================
   打印样式
   ======================================== */
@media print {
    .firmware-mobile-nav,
    .col-lg-3.col-12:first-child {
        display: none !important;
    }

    .col-lg-9.col-12 {
        width: 100% !important;
    }

    .tab-pane {
        display: block !important;
        opacity: 1 !important;
    }

    .atf-themes-btn {
        background: #f0f0f0 !important;
        color: #333 !important;
    }
}

/* ============================================================
   V2 Firmware Page Overrides
   说明：
   - 固件页与下载/手册页保持同一套移动导航与侧边栏语言。
   ============================================================ */

.firmware-mobile-nav,
.firmware-item,
.atf-sidebar-widget,
.tab-content {
    background: var(--v2-bg-primary);
    border: 1px solid var(--v2-bg-divider);
    border-radius: var(--v2-radius-lg);
    box-shadow: var(--v2-shadow-card);
}

.mobile-nav-btn {
    border-color: var(--v2-bg-divider);
    color: var(--v2-text-secondary);
}

.mobile-nav-btn::before {
    background: var(--v2-primary-500);
}

.mobile-nav-btn.active,
.firmware-item:hover .firmware-info h4 {
    color: var(--v2-primary-500);
}

.firmware-item:hover {
    border-color: var(--v2-primary-200);
    box-shadow: var(--v2-shadow-card-hover);
}

.atf-sidebar-widget,
.tab-content,
.firmware-item,
.firmware-mobile-nav,
.atf-sidebar-widget .list-group-item,
.firmware-list .list-group-item,
.mobile-nav-btn,
.popover,
.popover-header {
    border-radius: var(--v2-radius-sm, 8px) !important;
}

.firmware-list .atf-themes-btn {
    border-radius: var(--v2-radius-button-pill, 22px) !important;
}

.atf-sidebar-widget .atf-widget-title,
.tab-pane h3 {
    color: var(--v2-text-heading, #171A1D);
    font-size: 24px;
    font-weight: 500;
    line-height: 32px;
}

.atf-sidebar-widget .list-group-item,
.firmware-list .list-group-item,
.tab-pane p,
.firmware-info p,
.popover-body {
    font-size: 16px;
    line-height: 24px;
}

.atf-sidebar-widget .list-group-item,
.firmware-info h4 {
    font-weight: 500;
}

.firmware-info h4,
.firmware-list h4,
.firmware-info h4.fs-6.fw-bold {
    color: var(--v2-text-heading, #171A1D);
    font-size: 20px !important;
    font-weight: 500 !important;
    line-height: 28px !important;
}

@media (max-width: 767px) {
    .atf-sidebar-widget .atf-widget-title,
    .tab-pane h3 {
        font-size: 20px;
        line-height: 28px;
    }

    .mobile-nav-btn span {
        font-size: 12px;
        line-height: 16px;
        letter-spacing: 0;
    }

    .firmware-list .atf-themes-btn {
        border-radius: 21px !important;
    }
}
