/*
Theme Name: CoolSphere Industrial
Theme URI: https://coolsphere.com/
Author: CoolSphere Team
Author URI: https://coolsphere.com/
Description: Professional industrial cooling solutions theme
Version: 1.0.0
License: GPL v2 or later
Text Domain: coolsphere
*/

/* ==========================================================================
   基础样式
   ========================================================================== */
:root {
    --primary-color: #0d6efd;
    --primary-dark: #0a58ca;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --info-color: #0dcaf0;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #fff;
    overflow-x: hidden;
}

/* ==========================================================================
   排版
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
    color: var(--dark-color);
}

h1 { font-size: 3.5rem; }
h2 { font-size: 2.75rem; }
h3 { font-size: 2.25rem; }
h4 { font-size: 1.75rem; }
h5 { font-size: 1.5rem; }
h6 { font-size: 1.25rem; }

@media (max-width: 768px) {
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }
    h3 { font-size: 1.75rem; }
    h4 { font-size: 1.5rem; }
}

p {
    margin-bottom: 1rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ==========================================================================
   工具类
   ========================================================================== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.text-primary { color: var(--primary-color) !important; }
.bg-primary { background-color: var(--primary-color) !important; }
.bg-light { background-color: var(--light-color) !important; }
.bg-dark { background-color: var(--dark-color) !important; }

/* ==========================================================================
   图片样式
   ========================================================================== */
.responsive-img {
    max-width: 100%;
    height: auto;
    display: block;
}

.img-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.img-contain {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 图片尺寸类 */
.img-sm { max-height: 200px; }
.img-md { max-height: 400px; }
.img-lg { max-height: 600px; }

/* 图片阴影 */
.img-shadow {
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: box-shadow var(--transition-speed) ease;
}

.img-shadow:hover {
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* ==========================================================================
   按钮样式
   ========================================================================== */
.btn {
    display: inline-block;
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
    user-select: none;
    border: 1px solid transparent;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.375rem;
    transition: all var(--transition-speed) ease;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary {
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(13, 110, 253, 0.3);
}

.btn-outline-primary {
    color: var(--primary-color);
    background-color: transparent;
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.25rem;
}

/* ==========================================================================
   卡片样式
   ========================================================================== */
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: #fff;
    background-clip: border-box;
    border: 1px solid rgba(0,0,0,.125);
    border-radius: 0.5rem;
    overflow: hidden;
    transition: all var(--transition-speed) ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.card-img-top {
    width: 100%;
    height: 250px;
    object-fit: cover;
}

.card-body {
    flex: 1 1 auto;
    padding: 1.5rem;
}

.card-title {
    margin-bottom: 0.75rem;
    font-size: 1.5rem;
}

/* ==========================================================================
   表格样式
   ========================================================================== */
.table {
    width: 100%;
    margin-bottom: 1rem;
    color: #212529;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem;
    vertical-align: top;
    border-top: 1px solid #dee2e6;
}

.table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid #dee2e6;
    background-color: rgba(13, 110, 253, 0.05);
    font-weight: 600;
}

.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* ==========================================================================
   响应式工具
   ========================================================================== */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }

@media (min-width: 768px) {
    .d-md-none { display: none !important; }
    .d-md-block { display: block !important; }
    .d-md-flex { display: flex !important; }
}

@media (min-width: 992px) {
    .d-lg-none { display: none !important; }
    .d-lg-block { display: block !important; }
    .d-lg-flex { display: flex !important; }
}

/* 边距类 */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

.py-1 { padding-top: 0.25rem !important; padding-bottom: 0.25rem !important; }
.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
.py-5 { padding-top: 3rem !important; padding-bottom: 3rem !important; }

/* 文本对齐 */
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

/* 动画 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

/* ==========================================================================
   WordPress 特定样式
   ========================================================================== */
.alignnone { margin: 5px 20px 20px 0; }
.aligncenter { display: block; margin: 5px auto; }
.alignright { float: right; margin: 5px 0 20px 20px; }
.alignleft { float: left; margin: 5px 20px 20px 0; }

.wp-caption { max-width: 100%; }
.wp-caption-text { font-size: 0.875rem; color: #666; }

.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

/* ==========================================================================
   打印样式
   ========================================================================== */
@media print {
    .no-print { display: none !important; }
    a { text-decoration: underline !important; }
    .btn { display: none !important; }
}

/* ==========================================================================
   移动端图片响应式优化
   ========================================================================== */

/* 确保所有图片在移动端都能正常显示 */
@media screen and (max-width: 768px) {
    /* 基础图片响应式 */
    img {
        max-width: 100% !important;
        height: auto !important;
        display: block;
    }
    
    /* 覆盖你可能设置的固定高度 */
    .card-img-top,
    .wp-post-image,
    .attachment-post-thumbnail,
    .size-full,
    .size-large,
    .size-medium {
        height: auto !important;
        max-height: none !important;
        object-fit: contain !important;
    }
    
    /* 修复图片尺寸类的移动端适配 */
    .img-sm,
    .img-md,
    .img-lg {
        max-height: none !important;
        height: auto !important;
        width: 100% !important;
    }
    
    /* 特定尺寸调整 */
    .img-sm { max-width: 200px; margin: 0 auto; }
    .img-md { max-width: 300px; margin: 0 auto; }
    .img-lg { max-width: 100%; }
    
    /* 处理WordPress图片类 */
    .alignleft,
    .alignright,
    .aligncenter {
        float: none !important;
        margin: 15px auto !important;
        display: block;
        text-align: center;
    }
    
    .alignnone {
        margin: 15px auto !important;
        display: block;
        max-width: 100%;
    }
    
    /* 修复卡片中的图片 */
    .card-img-top {
        width: 100%;
        height: auto;
        max-height: 200px; /* 设置一个合理的最大高度 */
    }
    
    /* 处理背景图片 */
    [style*="background-image"],
    .has-background {
        background-size: contain !important;
        background-position: center !important;
    }
}

/* 超小屏幕（手机）优化 */
@media screen and (max-width: 480px) {
    /* 进一步调整图片大小 */
    img {
        max-width: 100%;
    }
    
    .card-img-top {
        max-height: 150px;
    }
    
    /* 图片容器适配 */
    .image-container,
    .wp-block-image,
    .figure,
    figure {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 0 !important;
    }
    
    /* 处理图片阴影 */
    .img-shadow {
        box-shadow: 0 3px 10px rgba(0,0,0,0.1) !important;
    }
}

/* 平板设备优化 */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    img {
        max-width: 100%;
        height: auto;
    }
    
    .card-img-top {
        height: 200px;
        object-fit: cover;
    }
}

/* 防止图片超出容器 */
.img-fluid {
    max-width: 100%;
    height: auto;
}

/* WordPress图片区块优化 */
.wp-block-image img {
    height: auto;
}

.wp-block-image.size-full img,
.wp-block-image.size-large img {
    width: 100%;
    height: auto;
}

/* 修复图片链接 */
a img {
    border: 0;
}

/* 确保Gutenberg图片区块在移动端正常 */
@media screen and (max-width: 768px) {
    .wp-block-image {
        margin: 1em 0;
    }
    
    .wp-block-image .alignleft,
    .wp-block-image .alignright {
        float: none;
        margin: 1em auto;
    }
    
    .wp-block-image figcaption {
        font-size: 0.9em;
        text-align: center;
        margin-top: 0.5em;
    }
}

/* 响应式图片包装器 */
.responsive-image-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.responsive-image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 保持宽高比的图片容器 */
.aspect-ratio-box {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 比例 */
    overflow: hidden;
}

.aspect-ratio-box img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 修复WordPress画廊 */
@media screen and (max-width: 768px) {
    .gallery {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
    }
    
    .gallery-item {
        flex: 0 0 48% !important;
        margin: 1% !important;
    }
    
    .gallery-item img {
        width: 100% !important;
        height: auto !important;
    }
}

/* ==========================================================================
   移动端表格响应式修复
   ========================================================================== */

@media screen and (max-width: 768px) {
    /* 1. 基础表格修复 */
    table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-collapse: collapse !important;
    }
    
    /* 2. 表格容器滚动 */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 3. 防止表格单元格换行 */
    table th,
    table td {
        white-space: nowrap !important;
        min-width: 100px !important;
        padding: 12px 8px !important;
        font-size: 14px !important;
    }
    
    /* 4. 表头固定（可选） */
    table thead th {
        background-color: var(--light-color) !important;
        position: sticky;
        left: 0;
        z-index: 1;
    }
    
    /* 5. 表格标题适配 */
    table caption {
        font-size: 1.2rem !important;
        padding: 10px !important;
        text-align: center !important;
    }
    
    /* 6. 表格边框优化 */
    table, table th, table td {
        border: 1px solid #ddd !important;
    }
    
    /* 7. 斑马条纹提高可读性 */
    table tbody tr:nth-child(even) {
        background-color: rgba(0,0,0,0.02) !important;
    }
}

/* 小屏幕手机优化 */
@media screen and (max-width: 480px) {
    table {
        font-size: 12px !important;
    }
    
    table th,
    table td {
        padding: 8px 6px !important;
        font-size: 12px !important;
        min-width: 80px !important;
    }
    
    /* 重要数据高亮 */
    table td:first-child {
        font-weight: 600 !important;
        background-color: rgba(13, 110, 253, 0.05) !important;
    }
}

/* ==========================================================================
   表格堆叠布局（另一种方案）
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* 方案B：将表格转换为卡片式布局 */
    .table-stacked {
        display: block !important;
    }
    
    .table-stacked thead {
        display: none !important;
    }
    
    .table-stacked tbody,
    .table-stacked tr,
    .table-stacked td {
        display: block !important;
        width: 100% !important;
        text-align: left !important;
    }
    
    .table-stacked tr {
        margin-bottom: 15px !important;
        border: 1px solid #ddd !important;
        border-radius: 8px !important;
        overflow: hidden !important;
        background: white !important;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
    }
    
    .table-stacked td {
        padding: 10px 15px !important;
        border: none !important;
        border-bottom: 1px solid #eee !important;
        white-space: normal !important;
    }
    
    .table-stacked td:last-child {
        border-bottom: none !important;
    }
    
    /* 添加标签 */
    .table-stacked td::before {
        content: attr(data-label) !important;
        font-weight: 600 !important;
        display: block !important;
        margin-bottom: 5px !important;
        color: var(--primary-color) !important;
        font-size: 0.9em !important;
    }
}

/* ==========================================================================
   WordPress表格特定修复
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* Gutenberg表格区块 */
    .wp-block-table {
        overflow-x: auto !important;
        margin: 20px 0 !important;
    }
    
    .wp-block-table table {
        min-width: 600px !important;
    }
    
    /* Classic Editor表格 */
    .entry-content table,
    .post-content table {
        display: block !important;
        overflow-x: auto !important;
    }
}