/**
 * 响应式设计样式
 * 移动端优化和响应式布局
 */

/* 移动端优先的响应式设计 */
@media (max-width: 768px) {
    /* 顶部导航栏移动端优化 */
    .header {
        padding: 10px 0;
    }
    
    .header .container {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-brand {
        text-align: center;
        margin-bottom: 10px;
    }
    
    .search-box {
        width: 100%;
        margin: 10px 0;
    }
    
    .search-form {
        width: 100%;
    }
    
    .search-input {
        width: 100%;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    .user-menu {
        justify-content: center;
        gap: 15px;
    }
    
    /* 侧边栏移动端优化 */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    
    .sidebar.mobile-open {
        left: 0;
    }
    
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }
    
    .mobile-overlay.active {
        display: block;
    }
    
    /* 主要内容区域移动端优化 */
    .main-content {
        margin-left: 0;
        padding: 15px;
    }
    
    /* 卡片布局优化 */
    .card {
        margin: 10px 0;
        width: 100%;
    }
    
    .card-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* 搜索页面移动端优化 */
    .search-results {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .search-item {
        flex-direction: column;
        padding: 15px;
    }
    
    .result-icon {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .result-content {
        text-align: center;
    }
    
    /* 表格响应式 */
    .table-responsive {
        overflow-x: auto;
    }
    
    .table {
        font-size: 14px;
    }
    
    /* 表单优化 */
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-control {
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    /* 按钮优化 */
    .btn {
        padding: 12px 20px;
        font-size: 16px;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        margin: 5px 0;
    }
    
    /* 模态框优化 */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-content {
        border-radius: 10px;
    }
    
    /* 页脚优化 */
    .footer {
        text-align: center;
        padding: 20px 10px;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 10px;
    }
}

/* 平板设备优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .navbar-nav {
        flex-wrap: wrap;
    }
    
    .search-form {
        min-width: 300px;
    }
}

/* 大屏幕优化 */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
    }
    
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .btn, .nav-link, .card {
        min-height: 44px; /* 最小触摸目标尺寸 */
    }
    
    .dropdown-menu {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 50vh;
        overflow-y: auto;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --text-primary: #ffffff;
        --text-secondary: #b0b0b0;
        --border-color: #404040;
    }
    
    body {
        background-color: var(--bg-primary);
        color: var(--text-primary);
    }
    
    .card {
        background-color: var(--bg-secondary);
        border-color: var(--border-color);
    }
    
    .form-control {
        background-color: var(--bg-secondary);
        border-color: var(--border-color);
        color: var(--text-primary);
    }
    
    .table {
        color: var(--text-primary);
    }
    
    .table th,
    .table td {
        border-color: var(--border-color);
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    :root {
        --text-primary: #000000;
        --text-secondary: #333333;
        --border-color: #000000;
    }
    
    .btn {
        border-width: 2px;
    }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 打印样式 */
@media print {
    .navbar,
    .footer,
    .btn,
    .search-form {
        display: none;
    }
    
    .card {
        border: 1px solid #000;
        break-inside: avoid;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
    }
}

/* 移动端特定优化类 */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
}

/* 手势导航支持 */
.touch-gesture {
    -webkit-overflow-scrolling: touch;
}

/* 弹性图片 */
img {
    max-width: 100%;
    height: auto;
}

/* 响应式嵌入内容 */
.embed-responsive {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
}

.embed-responsive::before {
    display: block;
    content: "";
    padding-top: 56.25%; /* 16:9 比例 */
}

.embed-responsive iframe,
.embed-responsive embed,
.embed-responsive object {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* 移动端底部导航 */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: none;
    z-index: 1000;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
    }
    
    body {
        padding-bottom: 60px; /* 为底部导航留出空间 */
    }
}

/* 加载状态优化 */
.loading-state {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 错误状态 */
.error-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.error-state .icon {
    font-size: 48px;
    margin-bottom: 20px;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state .icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}