/* ===========================================
   清水家园工具引导页 - 主样式
   iOS 风格设计
   =========================================== */

/* 全局变量 */
:root {
    /* iOS 颜色系统 */
    --ios-blue: #007AFF;
    --ios-gray: #8E8E93;
    --ios-light-gray: #C7C7CC;
    --ios-bg: #F2F2F7;
    --ios-card-bg: #FFFFFF;
    --ios-text: #000000;
    --ios-text-secondary: #8E8E93;

    /* 圆角 */
    --radius-large: 16px;
    --radius-medium: 12px;
    --radius-small: 8px;

    /* 阴影 */
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);

    /* 动画 */
    --transition: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);

    /* 间距 */
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
}

/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 字体系统 */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans", sans-serif,
                 "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 16px;
    line-height: 1.6;
    color: var(--ios-text);
    background-color: var(--ios-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 通用卡片样式 */
.card {
    background: var(--ios-card-bg);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

/* 主容器 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-md) var(--spacing-lg); /* 减少上下内边距 */
    min-height: auto; /* 改为自适应高度 */
}

/* ===========================================
   宣传页模块
   =========================================== */
.promotion-section {
    margin-bottom: var(--spacing-md); /* 减少底部间距 */
    overflow: hidden;
    max-height: 260px; /* 进一步减少宣传页高度 */
}

.promotion-content {
    display: flex;
    gap: var(--spacing-md); /* 减少间距 */
    padding: var(--spacing-md); /* 减少内边距 */
    max-height: 260px; /* 减少内容高度 */
}

.promotion-image {
    flex: 0 0 30%;
    min-height: 160px;
    max-height: 200px; /* 减少图片最大高度 */
    background: var(--ios-bg);
    border-radius: var(--radius-medium);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.promotion-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.promotion-image.empty {
    color: var(--ios-text-secondary);
    font-size: 14px;
}

.promotion-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    max-height: 200px; /* 减少文字区域最大高度 */
    overflow-y: auto; /* 内容超出时显示滚动条 */
    padding-right: var(--spacing-sm); /* 为滚动条留出空间 */
}

/* 自定义滚动条样式（iOS 风格）*/
.promotion-text::-webkit-scrollbar {
    width: 6px;
}

.promotion-text::-webkit-scrollbar-track {
    background: transparent;
}

.promotion-text::-webkit-scrollbar-thumb {
    background: var(--ios-light-gray);
    border-radius: 3px;
}

.promotion-text::-webkit-scrollbar-thumb:hover {
    background: var(--ios-gray);
}

.promotion-text h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--ios-text);
}

.promotion-text p {
    margin-bottom: var(--spacing-sm);
    color: var(--ios-text);
}

/* ===========================================
   中间区域布局
   =========================================== */
.middle-section {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: var(--spacing-md); /* 减少间距 */
    margin-bottom: var(--spacing-md); /* 减少底部间距 */
    align-items: stretch; /* 改为拉伸以保持统一高度 */
    height: 360px; /* 减少固定高度 */
}

/* ===========================================
   公告页模块
   =========================================== */
.announcements-section {
    padding: var(--spacing-md); /* 减少内边距 */
    height: 100%; /* 占满父容器高度 */
    max-height: 360px; /* 减少最大高度限制 */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 防止溢出 */
}

.section-title {
    font-size: 20px; /* 减少字号 */
    font-weight: 600;
    margin-bottom: var(--spacing-sm); /* 减少底部间距 */
    color: var(--ios-text);
    flex-shrink: 0; /* 标题不缩小 */
}

.announcements-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    overflow-y: auto; /* 公告列表可滚动 */
    flex: 1; /* 占据剩余空间 */
    padding-right: var(--spacing-xs);
}

/* 自定义滚动条样式 */
.announcements-list::-webkit-scrollbar {
    width: 6px;
}

.announcements-list::-webkit-scrollbar-track {
    background: transparent;
}

.announcements-list::-webkit-scrollbar-thumb {
    background: var(--ios-light-gray);
    border-radius: 3px;
}

.announcements-list::-webkit-scrollbar-thumb:hover {
    background: var(--ios-gray);
}

.announcement-item {
    border-bottom: 1px solid var(--ios-bg);
    padding: var(--spacing-sm) 0;
    cursor: pointer;
    transition: all var(--transition);
}

.announcement-item:last-child {
    border-bottom: none;
}

.announcement-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm);
    border-radius: var(--radius-small);
    transition: background var(--transition);
}

.announcement-header:hover {
    background: var(--ios-bg);
}

.announcement-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--ios-text);
    flex: 1;
}

.announcement-icon {
    font-size: 18px;
    color: var(--ios-text-secondary);
    transition: transform var(--transition);
}

.announcement-item.expanded .announcement-icon {
    transform: rotate(180deg);
}

.announcement-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition), padding var(--transition);
    padding: 0 var(--spacing-sm);
}

.announcement-item.expanded .announcement-content {
    max-height: 2000px;
    padding: var(--spacing-md) var(--spacing-sm);
}

.announcement-body {
    font-size: 14px;
    line-height: 1.8;
    color: var(--ios-text-secondary);
}

.announcement-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-small);
    margin: var(--spacing-sm) 0;
}

.no-announcements {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--ios-text-secondary);
}

/* ===========================================
   链接模块区域
   =========================================== */
.links-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: var(--spacing-sm); /* 减少间距 */
    height: 100%; /* 占满父容器高度 */
    max-height: 360px; /* 减少最大高度限制 */
}

.link-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    text-decoration: none;
    color: var(--ios-text);
    min-height: 120px;
    height: 100%; /* 占满网格单元格 */
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
}

.link-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ios-blue);
    opacity: 0;
    transition: opacity var(--transition);
}

.link-card.active {
    background: var(--ios-blue);
    color: white;
}

.link-card.disabled {
    background: var(--ios-bg);
    color: var(--ios-gray);
    cursor: not-allowed;
    pointer-events: none;
}

.link-card:not(.disabled):hover {
    transform: translateY(-4px) scale(1.02);
}

.link-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-sm);
    transition: transform var(--transition);
}

.link-card:not(.disabled):hover .link-icon {
    transform: scale(1.1);
}

.link-title {
    font-size: 16px;
    font-weight: 500;
    text-align: center;
}

/* ===========================================
   底部备案信息
   =========================================== */
.footer {
    text-align: center;
    padding: var(--spacing-sm) var(--spacing-lg); /* 减少上下内边距 */
    color: var(--ios-text-secondary);
    font-size: 12px;
}

.footer a {
    color: var(--ios-text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

.footer a:hover {
    color: var(--ios-blue);
}

/* ===========================================
   响应式设计 - 移动端
   =========================================== */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-sm);
    }

    /* 宣传页垂直布局 */
    .promotion-section {
        max-height: none; /* 移动端取消高度限制 */
        margin-bottom: var(--spacing-md);
    }

    .promotion-content {
        flex-direction: column;
        padding: var(--spacing-md);
        max-height: none; /* 移动端取消高度限制 */
        gap: var(--spacing-md);
    }

    .promotion-image {
        flex: 0 0 auto;
        width: 100%;
        min-height: 180px;
        max-height: 200px; /* 移动端限制图片高度 */
    }

    .promotion-text {
        max-height: 250px; /* 移动端限制文字高度 */
        font-size: 14px;
        line-height: 1.6;
    }

    .promotion-text h1 {
        font-size: 20px;
        margin-bottom: var(--spacing-xs);
    }

    .promotion-text p {
        margin-bottom: var(--spacing-xs);
    }

    /* 中间区域垂直布局 */
    .middle-section {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        height: auto !important; /* 移动端强制使用自适应高度 */
        max-height: none !important; /* 移动端取消最大高度限制 */
        gap: var(--spacing-md);
    }

    /* 公告区域 */
    .announcements-section {
        padding: var(--spacing-md);
        max-height: 350px !important; /* 移动端限制公告区域高度 */
        height: auto !important; /* 移动端自适应高度 */
    }

    .section-title {
        font-size: 18px;
        margin-bottom: var(--spacing-sm);
    }

    .announcement-title {
        font-size: 15px;
    }

    .announcement-body {
        font-size: 13px;
    }

    /* 链接区域垂直布局 */
    .links-section {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, auto);
        height: auto !important; /* 移动端强制自适应高度 */
        max-height: none !important; /* 移动端取消最大高度限制 */
        gap: var(--spacing-sm);
    }

    .link-card {
        min-height: 90px;
        max-height: 110px; /* 移动端限制链接卡片高度 */
        height: auto !important; /* 移动端自适应高度 */
        padding: var(--spacing-md);
    }

    .link-icon {
        font-size: 32px;
        margin-bottom: var(--spacing-xs);
    }

    .link-title {
        font-size: 14px;
    }

    /* 底部备案 */
    .footer {
        padding: var(--spacing-md);
        font-size: 11px;
    }

    /* 移动端卡片悬停效果禁用 */
    .card:hover {
        transform: none;
    }

    .link-card:not(.disabled):hover {
        transform: none;
    }
}

/* ===========================================
   平板端优化
   =========================================== */
@media (min-width: 769px) and (max-width: 1024px) {
    .middle-section {
        grid-template-columns: 1fr 350px;
    }

    .container {
        max-width: 100%;
        padding: var(--spacing-lg);
    }
}

/* ===========================================
   动画效果
   =========================================== */

/* 页面加载动画 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.promotion-section,
.announcements-section,
.links-section {
    animation: fadeInUp 0.6s ease-out;
}

.announcement-item {
    animation: fadeInUp 0.4s ease-out;
}

.link-card {
    animation: fadeInUp 0.5s ease-out;
}

/* 为链接卡片添加延迟动画 */
.link-card:nth-child(1) {
    animation-delay: 0.1s;
}

.link-card:nth-child(2) {
    animation-delay: 0.2s;
}

.link-card:nth-child(3) {
    animation-delay: 0.3s;
}

.link-card:nth-child(4) {
    animation-delay: 0.4s;
}

/* 加载状态 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--ios-light-gray);
    border-radius: 50%;
    border-top-color: var(--ios-blue);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===========================================
   打印样式
   =========================================== */
@media print {
    .footer {
        display: none;
    }

    .link-card:not(.active) {
        display: none;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--ios-light-gray);
    }
}
