/* 响应式样式文件 */

/* 小屏幕设备（手机） */
@media (max-width: 767px) {
    /* 侧边栏样式 */
    .sidebar {
        width: 100% !important;
        height: auto !important;
        position: relative !important;
        padding: 10px 0 !important;
    }
    
    .sidebar h3 {
        margin-bottom: 15px !important;
        font-size: 18px !important;
    }
    .surgery-info{
        margin-bottom: 0px !important;
    }
    
    /* 侧边栏导航菜单 - 移动端一行显示 */
    .sidebar ul.nav.flex-column {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        gap: 12px !important;
        margin-bottom: 15px !important;
        padding: 0 !important;
        list-style: none !important;
    }
    
    .sidebar ul.nav.flex-column .nav-item {
        margin: 0 !important;
        flex: 1 !important;
        min-width: 110px !important;
        max-width: 150px !important;
    }
    
    .sidebar .nav-link {
        padding: 10px 14px !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 8px !important;
        background: rgba(255, 255, 255, 0.1) !important;
        color: rgba(255, 255, 255, 0.9) !important;
        text-decoration: none !important;
        transition: all 0.3s ease !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
    }
    
    .sidebar .nav-link:hover {
        background: rgba(255, 255, 255, 0.2) !important;
        color: white !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
    }
    
    .sidebar .nav-link.active {
        background: rgba(255, 255, 255, 0.25) !important;
        color: white !important;
        border-color: rgba(255, 255, 255, 0.3) !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important;
    }
    
    .sidebar .nav-link i {
        margin-right: 6px !important;
        font-size: 15px !important;
        flex-shrink: 0 !important;
    }
    
    /* 对于极小屏幕，调整导航菜单 */
    @media (max-width: 360px) {
        .sidebar ul.nav.flex-column {
            gap: 8px !important;
        }
        
        .sidebar ul.nav.flex-column .nav-item {
            min-width: 100px !important;
        }
        
        .sidebar .nav-link {
            padding: 8px 10px !important;
            font-size: 13px !important;
        }
        
        .sidebar .nav-link i {
            font-size: 14px !important;
            margin-right: 4px !important;
        }
    }
    
    /* 确保侧边栏在移动端正确显示 */
    .sidebar {
        border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
        margin-bottom: 15px !important;
        padding-bottom: 15px !important;
    }
    
    /* 主内容区域 */
    .main-content {
        margin-left: 0 !important;
        padding: 10px !important;
    }
    
    /* 页面头部 */
    .header {
        padding: 10px 15px !important;
        margin-bottom: 15px !important;
    }
    
    .header h1 {
        font-size: 20px !important;
    }
    
    /* 隐藏移动端仪表盘标题 */
    @media (max-width: 767px) {
        /* 隐藏包含仪表盘图标的标题 */
        .header h1 {
            display: none !important;
        }
    }
    
    .header .d-flex.justify-content-between {
        flex-direction: column !important;
        gap: 15px !important;
        align-items: stretch !important;
    }
    
    /* 搜索表单和新增患者按钮容器 */
    .header .d-flex.align-items-center {
        flex-direction: row !important;
        gap: 10px !important;
        width: 100% !important;
        align-items: stretch !important;
        flex-wrap: nowrap !important;
    }
    
    /* 搜索表单 */
    .header form {
        max-width: none !important;
        width: 100% !important;
        display: flex !important;
        flex: 1 !important;
    }
    
    .header form .form-control {
        flex: 1 !important;
        font-size: 14px !important;
        padding: 8px 12px !important;
        height: 40px !important;
        min-width: 0 !important;
    }
    
    /* 搜索按钮 */
    .header form .btn-primary {
        height: 40px !important;
        padding: 8px 16px !important;
        min-width: auto !important;
        width: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* 新增患者按钮 */
    .header a.btn-primary {
        width: auto !important;
        justify-content: center !important;
        height: 40px !important;
        padding: 8px 16px !important;
        font-size: 14px !important;
        display: flex !important;
        align-items: center !important;
        min-width: 100px !important;
        white-space: nowrap !important;
    }
    
    .header a.btn-primary i {
        margin-right: 8px !important;
    }
    
    /* 当屏幕宽度很小时，调整为垂直排列 */
    @media (max-width: 480px) {
        .header .d-flex.align-items-center {
            flex-direction: column !important;
        }
        
        .header a.btn-primary {
            width: 100% !important;
        }
    }
    
    /* 统计卡片 */
    .row .col-md-3 {
        margin-bottom: 15px !important;
        padding: 5px !important;
        width: 50% !important;
        flex: 0 0 50% !important;
    }
    
    /* 确保卡片在移动端正确显示 */
    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .col-md-3 {
        padding-left: 5px !important;
        padding-right: 5px !important;
    }
    
    /* 仪表盘卡片样式优化 */
    .card.text-center.p-4 {
        padding: 15px !important;
        min-height: auto !important;
    }
    
    .card.text-center.p-4 .card-icon {
        font-size: 24px !important;
        margin-bottom: 8px !important;
    }
    
    .card.text-center.p-4 .card-title {
        font-size: 22px !important;
        margin-bottom: 4px !important;
    }
    
    .card.text-center.p-4 .card-text {
        font-size: 13px !important;
        margin: 0 !important;
    }
    
    /* 通用卡片样式 */
    .card {
        padding: 15px !important;
    }
    
    .card-title {
        font-size: 24px !important;
    }
    
    /* 快捷操作按钮 - 所有页面 */
    .d-flex.gap-3 {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .d-flex.gap-3 .btn {
        flex: 1 1 100% !important;
        min-width: auto !important;
        padding: 8px 12px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
        text-align: center !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    .d-flex.gap-3 .btn i {
        margin-right: 5px !important;
        font-size: 14px !important;
        flex-shrink: 0 !important;
    }
    
    /* 对于极小屏幕，每个按钮占满一行 */
    @media (max-width: 360px) {
        .d-flex.gap-3 .btn {
            flex: 1 1 100% !important;
            min-width: 100% !important;
            font-size: 12px !important;
            padding: 8px 8px !important;
        }
    }
    
    /* 对于较大的手机屏幕，可以显示两个按钮一排 */
    @media (min-width: 361px) and (max-width: 767px) {
        .d-flex.gap-3 .btn {
            flex: 1 1 calc(0% - 4px) !important;
            min-width: calc(50% - 4px) !important;
        }
    }
    
    /* 平板及以上屏幕可以显示三个按钮一排 */
    @media (min-width: 768px) {
        .d-flex.gap-3 .btn {
            flex: 1 1 auto !important;
        }
    }
    
    /* 优化btn-lg在移动端的显示 */
    .btn-lg {
        font-size: 16px !important;
        padding: 10px 15px !important;
    }
    
    /* 在移动端调整btn-lg的大小 */
    @media (max-width: 767px) {
        .btn-lg {
            font-size: 13px !important;
            padding: 8px 12px !important;
            min-height: 36px !important;
            height: auto !important;
        }
        
        /* 极小屏幕进一步缩小 */
        @media (max-width: 360px) {
            .btn-lg {
                font-size: 12px !important;
                padding: 8px 8px !important;
                min-height: 32px !important;
            }
        }
    }
    
    /* 患者卡片 */
    .col-md-4 {
        width: 100% !important;
        margin-bottom: 15px !important;
    }
    
    .patient-card {
        min-height: auto !important;
        padding: 15px !important;
    }
    
    .patient-name {
        font-size: 16px !important;
        margin-bottom: 5px !important;
    }
    
    .patient-meta {
        flex-direction: row !important;
        gap: 15px !important;
        margin-bottom: 0px !important;
        flex-wrap: wrap !important;
        align-items: center !important;
    }
    
    .patient-details {
        font-size: 13px !important;
        margin-bottom: 0px !important;
    }
    
    /* 患者卡片操作按钮优化 */
    .patient-actions {
        margin-top: auto !important;
        padding-top: 15px !important;
    }
    
    .patient-actions .d-flex {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
    }
    
    .patient-actions .btn {
        flex: 1 !important;
        padding: 6px 10px !important;
        height: 36px !important;
        font-size: 13px !important;
        min-width: 0 !important;
    }
    
    .patient-actions .btn i {
        margin: 0 !important;
        font-size: 14px !important;
    }
    
    .patient-actions .btn span {
        display: none !important;
    }
    
    /* 删除按钮容器 */
    .patient-actions .flex-fill {
        height: 36px !important;
    }
    
    .patient-actions form {
        height: 100% !important;
    }
    
    .patient-actions .btn-danger {
        width: 100% !important;
        height: 100% !important;
    }
    
    /* 表单样式 */
    .container {
        padding: 10px !important;
    }
    
    .row.justify-content-center {
        margin: 0 !important;
    }
    
    .col-md-6 {
        width: 100% !important;
    }
    
    .card-body {
        padding: 20px !important;
    }
    
    .mb-3 {
        margin-bottom: 15px !important;
    }
    
    /* 图片列表 */
    .image-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .image-item {
        padding: 8px !important;
    }
    
    /* 图片项内容样式 */
    .image-item .image-item-content {
        cursor: pointer !important;
    }
    
    .image-item .image-item-content img {
        width: 100% !important;
        height: auto !important;
        object-fit: cover !important;
    }
    
    .image-item .image-info {
        font-size: 12px !important;
    }
    
    .image-item .image-info p {
        margin: 5px 0 !important;
    }
    
    /* 图片备注样式 - 移动端全部显示 */
    .image-info .remark-content {
        white-space: normal !important;
        text-align: left !important;
        overflow: visible !important;
        text-overflow: clip !important;
        line-height: 1.4 !important;
    }
    
    /* 图片项内容样式 */
    .image-item-content {
        text-align: center !important;
    }
    
    /* 模态框 */
    .modal-dialog {
        margin: 10px !important;
        max-width: none !important;
    }
    
    /* 移动端横向滚动菜单 */
    .scrollable-menu {
        overflow-x: auto !important;
        white-space: nowrap !important;
    }
    
    .scrollable-menu::-webkit-scrollbar {
        height: 6px !important;
    }
    
    .scrollable-menu::-webkit-scrollbar-track {
        background: #f1f1f1 !important;
        border-radius: 10px !important;
    }
    
    .scrollable-menu::-webkit-scrollbar-thumb {
        background: #888 !important;
        border-radius: 10px !important;
    }
    
    .scrollable-menu::-webkit-scrollbar-thumb:hover {
        background: #555 !important;
    }
    
    /* 面包屑导航 */
    .breadcrumb {
        flex-wrap: wrap !important;
        font-size: 12px !important;
    }
    
    /* 患者信息表单 */
    .form-row {
        flex-direction: column !important;
    }
    
    .form-row .col-md-6 {
        width: 100% !important;
        margin-bottom: 15px !important;
    }
    
    /* 按钮组 */
    .btn-group {
        flex-direction: column !important;
        width: 100% !important;
    }
    
    .btn-group .btn {
        margin-bottom: 8px !important;
    }
    
    /* 图片操作按钮 */
    .image-actions {
        display: flex !important;
        flex-direction: row !important;
        gap: 5px !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .image-actions .btn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 32px !important;
        height: 32px !important;
        padding: 0 !important;
        font-size: 12px !important;
        min-width: auto !important;
        margin: 0 !important;
    }
    
    .image-actions .btn i {
        font-size: 12px !important;
        margin: 0 !important;
    }
    
    /* 目录卡片操作按钮 */
    .directory-card-actions {
        display: flex !important;
        flex-direction: row !important;
        gap: 5px !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .directory-card-actions .btn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 32px !important;
        height: 32px !important;
        padding: 0 !important;
        font-size: 12px !important;
        min-width: auto !important;
        margin: 0 !important;
    }
    
    .directory-card-actions .btn i {
        font-size: 12px !important;
        margin: 0 !important;
    }
    
    /* 搜索和操作栏 */
    .d-flex.justify-content-between {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    /* 图片搜索和批量删除按钮在移动端并列显示 */
    .d-flex.justify-content-between.align-items-center {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 10px !important;
    }
    
    /* 搜索容器样式 */
    .search-container {
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    /* 搜索输入框样式 */
    .search-container .form-control {
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
    }
    
    /* 批量删除按钮样式 */
    #bulkDeleteBtn {
        min-width: auto !important;
        white-space: nowrap !important;
        padding: 8px 12px !important;
        font-size: 13px !important;
        flex-shrink: 0 !important;
    }
    
    /* 对于极小屏幕，调整布局 */
    @media (max-width: 360px) {
        .d-flex.justify-content-between.align-items-center {
            flex-direction: column !important;
            align-items: stretch !important;
        }
        
        #bulkDeleteBtn {
            width: 100% !important;
        }
    }
    
    /* 下拉菜单 */
    .dropdown-menu {
        min-width: auto !important;
    }
    
    /* 文本对齐 */
    h2, h3 {
        font-size: 18px !important;
        margin-bottom: 15px !important;
    }
    
    /* 卡片内部间距 */
    .card p {
        margin-bottom: 10px !important;
    }
    
    /* 患者信息区域优化 */
    .patient-info {
        margin-bottom: 0px !important;
    }
    
    .patient-info h2 {
        font-size: 22px !important;
        margin-bottom: 15px !important;
        padding-bottom: 10px !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
    }
    
    /* 患者基本信息行优化 */
    .patient-info .row.mt-3 {
        margin-top: 15px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* 患者基本信息列优化 */
    .patient-info .col-md-4 {
        padding: 0 !important;
        margin-bottom: 0px !important;
        width: 100% !important;
    }
    
    /* 患者基本信息段落优化 */
    .patient-info p {
        margin: 5px 0 !important;
        font-size: 14px !important;
        line-height: 1.5 !important;
    }
    
    /* 同一列内的p标签在移动端智能布局 */
    .patient-info .col-md-4 {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 15px !important;
        align-items: center !important;
    }
    
    .patient-info .col-md-4 p {
        margin: 0 !important;
        padding: 5px 0 !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        flex: 1 !important;
        min-width: 120px !important;
    }
    
    /* 对于极小屏幕，调整为单列显示 */
    @media (max-width: 360px) {
        .patient-info .col-md-4 {
            flex-direction: column !important;
            gap: 8px !important;
            align-items: flex-start !important;
        }
        
        .patient-info .col-md-4 p {
            min-width: 100% !important;
            flex: 1 1 100% !important;
        }
    }
    
    /* 患者基本信息加粗文本优化 */
    .patient-info strong {
        color: #495057 !important;
        font-weight: 600 !important;
    }
    
    /* 诊断和术式信息优化 */
    .patient-info .mt-3 {
        margin-top: 15px !important;
        padding-top: 0px !important;
        /* border-top: 1px solid rgba(0, 0, 0, 0.1) !important; */
    }
    
    .patient-info .mt-3 strong {
        font-size: 15px !important;
        color: #333 !important;
    }
    
    .patient-info .mt-3 p {
        margin-top: 5px !important;
        font-size: 14px !important;
        line-height: 1.6 !important;
        color: #666 !important;
    }
    
    /* 图片查看器 */
    .image-viewer {
        padding: 10px !important;
    }
    
    .image-viewer img {
        max-height: 70vh !important;
    }
    
    /* 分页 */
    .pagination {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 4px !important;
    }
    
    .pagination .page-item {
        margin: 0 !important;
    }
    
    .pagination .page-link {
        padding: 4px 8px !important;
        font-size: 12px !important;
        min-width: 30px !important;
        height: 30px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 6px !important;
    }
    
    .pagination .page-link i {
        font-size: 12px !important;
        margin: 0 !important;
    }
    
    /* 分页和总数统计容器 */
    nav[aria-label="Page navigation"] {
        padding: 15px 0 !important;
    }
    
    nav[aria-label="Page navigation"] .d-flex {
        flex-direction: column-reverse !important;
        gap: 10px !important;
        align-items: center !important;
    }
    
    nav[aria-label="Page navigation"] .text-muted {
        font-size: 13px !important;
    }
}

/* 中等屏幕设备（平板） */
@media (min-width: 768px) and (max-width: 991px) {
    /* 侧边栏样式 */
    .sidebar {
        width: 200px !important;
    }
    
    /* 主内容区域 */
    .main-content {
        margin-left: 200px !important;
        padding: 15px !important;
    }
    
    /* 患者卡片 */
    .col-md-4 {
        width: 50% !important;
    }
    
    /* 统计卡片 */
    .row .col-md-3 {
        width: 50% !important;
    }
}

/* 适配所有屏幕尺寸的通用样式 - 仅针对移动端 */
@media (max-width: 767px) {
    /* 确保表单元素在所有屏幕上都能正确显示 */
    input, select, textarea, button {
        width: 100%;
        max-width: 100%;
    }

    /* 确保表格在小屏幕上可以滚动 */
    table {
        overflow-x: auto;
        display: block;
    }

    /* 确保容器不会超出屏幕 */
    .container {
        max-width: 100%;
        padding: 0 15px;
    }

    /* 确保行在小屏幕上正确换行 */
    .row {
        margin: 0 -15px;
    }

    /* 确保列在小屏幕上正确显示 */
    [class*="col-"] {
        padding: 0 15px;
    }
    
    /* 目录网格移动端样式优化 */
    .directory-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
        gap: 15px !important;
    }
    
    /* 对于较大的手机屏幕，显示两个一排 */
    @media (min-width: 480px) {
        .directory-grid {
            grid-template-columns: repeat(2, 1fr) !important;
        }
    }
}

/* 确保图片不会超出容器 - 所有屏幕适用 */
img {
    max-width: 100%;
    height: auto;
}

/* 图片查看器基础样式 - 所有屏幕适用 */
#customImageViewer .viewer-title {
    margin: 0;
}

#customImageViewer .viewer-remark {
    margin: 0;
}

/* 图片查看器移动端样式优化 */
@media (max-width: 767px) {
    /* 调整移动端元素位置，增加间距，防止重叠 */
    #customImageViewer .viewer-title {
        bottom: -50px !important;
        font-size: 13px !important;
        margin-bottom: 10px !important;
    }
    
    /* 隐藏移动端图片查看器中的备注信息 */
    #customImageViewer .viewer-remark {
        display: none !important;
    }
    
    /* 调整导航信息位置，因为备注已隐藏 */
    #customImageViewer .viewer-navigation-info {
        bottom: -95px !important;
        font-size: 11px !important;
        padding: 5px 12px !important;
        border-radius: 15px !important;
    }
    
    /* 调整关闭按钮位置 */
    #customImageViewer .viewer-close {
        top: -25px !important;
        right: -25px !important;
        width: 25px !important;
        height: 25px !important;
        font-size: 20px !important;
    }
    
    /* 调整导航按钮大小和位置 */
    #customImageViewer .viewer-nav {
        width: 40px !important;
        height: 40px !important;
        font-size: 24px !important;
    }
    
    #customImageViewer .viewer-prev {
        left: -20px !important;
    }
    
    #customImageViewer .viewer-next {
        right: -20px !important;
    }
}

/* 确保盒模型正确 - 所有屏幕适用 */
* {
    box-sizing: border-box;
}
