/**
 * 响应式增强样式
 * LAN Transfer - Responsive Enhancement
 * 针对各种屏幕比例的优化，保持桌面端不变
 */

/* ========== 大屏幕优化 (1200px - 1920px) ========== */
@media (min-width: 1200px) and (max-width: 1919px) {
    .container {
        max-width: 1200px;
        margin: 0 auto;
    }
    
    /* 表格列宽优化 */
    .file-list-container table,
    .table-wrapper table {
        width: 100%;
    }
    
    /* 操作列保持合适宽度 */
    td.file-actions,
    th:last-child {
        min-width: 140px;
        white-space: nowrap;
    }
}

/* ========== 中等屏幕优化 (901px - 1199px) ========== */
@media (min-width: 901px) and (max-width: 1199px) {
    .container {
        padding: 16px 24px;
    }
    
    .main-content {
        padding: 16px 20px;
    }
    
    /* 隐藏次要列 */
    .col-device,
    th.col-device,
    td.device-name {
        display: none !important;
    }
    
    /* 调整表格列宽 */
    th:first-child,
    td:first-child {
        width: 45%;
    }
    
    th:nth-child(2),
    td:nth-child(2) {
        width: 15%;
    }
    
    th:nth-child(3),
    td:nth-child(3) {
        width: 20%;
    }
    
    th:last-child,
    td:last-child {
        width: 20%;
        min-width: 120px;
    }
    
    /* 侧边栏收缩 */
    .sidebar {
        width: 220px;
    }
    
    .main-content {
        margin-left: 220px;
    }
}

/* ========== 小平板优化 (769px - 900px) ========== */
@media (min-width: 769px) and (max-width: 900px) {
    body {
        padding-top: 64px;
    }
    
    .header {
        height: 64px;
        padding: 0 16px;
    }
    
    .container {
        padding: 12px 16px;
    }
    
    .main-content {
        margin-left: 0;
        padding: 12px 16px;
        width: 100%;
    }
    
    /* 完全隐藏侧边栏 */
    .sidebar {
        display: none;
    }
    
    /* 调整存储条 */
    .storage-bar-container {
        min-width: 180px;
        max-width: 250px;
    }
    
    .storage-bar-label {
        display: none;
    }
    
    /* 调整网络状态 */
    .network-status {
        font-size: 11px;
    }
    
    .network-ip {
        display: none;
    }
    
    /* ========== 所有表格统一只显示3列：文件名 | 大小/类型 | 操作 ========== */
    
    /* 表格基础设置 */
    table {
        width: 100% !important;
        table-layout: fixed !important;
    }
    
    th, td {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    /* ========== 所有文件 ========== */
    #publicFilesTable th:nth-child(3),
    #publicFilesTable td:nth-child(3),
    #publicFilesTable th:nth-child(4),
    #publicFilesTable td:nth-child(4) {
        display: none !important;
    }
    
    #publicFilesTable th:first-child,
    #publicFilesTable td:first-child {
        width: 50%;
    }
    #publicFilesTable th:nth-child(2),
    #publicFilesTable td:nth-child(2) {
        width: 25%;
    }
    #publicFilesTable th:last-child,
    #publicFilesTable td:last-child {
        width: 25%;
    }
    
    /* ========== 我的传输 ========== */
    #myFilesTable th:nth-child(3),
    #myFilesTable td:nth-child(3),
    #myFilesTable th:nth-child(4),
    #myFilesTable td:nth-child(4) {
        display: none !important;
    }
    
    #myFilesTable th:first-child,
    #myFilesTable td:first-child {
        width: 50%;
    }
    #myFilesTable th:nth-child(2),
    #myFilesTable td:nth-child(2) {
        width: 25%;
    }
    #myFilesTable th:last-child,
    #myFilesTable td:last-child {
        width: 25%;
    }
    
    /* ========== 私发文件 ========== */
    #privateFilesTable th:nth-child(3),
    #privateFilesTable td:nth-child(3),
    #privateFilesTable th:nth-child(4),
    #privateFilesTable td:nth-child(4),
    #privateFilesTable th:nth-child(5),
    #privateFilesTable td:nth-child(5) {
        display: none !important;
    }
    
    #privateFilesTable th:first-child,
    #privateFilesTable td:first-child {
        width: 50%;
    }
    #privateFilesTable th:nth-child(2),
    #privateFilesTable td:nth-child(2) {
        width: 25%;
    }
    #privateFilesTable th:last-child,
    #privateFilesTable td:last-child {
        width: 25%;
    }
    
    /* ========== 文件管理 ========== */
    #adminFilesTable th:nth-child(3),
    #adminFilesTable td:nth-child(3),
    #adminFilesTable th:nth-child(5),
    #adminFilesTable td:nth-child(5) {
        display: none !important;
    }
    
    #adminFilesTable th:first-child,
    #adminFilesTable td:first-child {
        width: 50%;
    }
    #adminFilesTable th:nth-child(2),
    #adminFilesTable td:nth-child(2) {
        width: 25%;
    }
    #adminFilesTable th:nth-child(4),
    #adminFilesTable td:nth-child(4) {
        display: none !important;
    }
    #adminFilesTable th:last-child,
    #adminFilesTable td:last-child {
        width: 25%;
    }
    
    /* ========== 访问记录 ========== */
    #logsTable th:first-child,
    #logsTable td:first-child,
    #logsTable th:nth-child(4),
    #logsTable td:nth-child(4),
    #logsTable th:nth-child(5),
    #logsTable td:nth-child(5) {
        display: none !important;
    }
    
    #logsTable th:nth-child(2),
    #logsTable td:nth-child(2) {
        width: 50%;
    }
    #logsTable th:nth-child(3),
    #logsTable td:nth-child(3) {
        width: 25%;
    }
    #logsTable th:last-child,
    #logsTable td:last-child {
        width: 25%;
    }
    
    /* 按钮紧凑 */
    .action-btns .btn,
    .file-actions .btn {
        padding: 5px 10px;
        font-size: 11px;
        min-height: 30px;
        white-space: nowrap;
    }
    
    /* 防止文字换行 */
    td .folder-badge,
    td .public-badge,
    td .private-badge {
        white-space: nowrap;
        font-size: 10px;
        padding: 2px 6px;
    }
    
    /* 文件名省略 */
    .file-name-text {
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ========== 小屏幕手机优化 (< 480px) ========== */
@media (max-width: 480px) {
    /* 更紧凑的头部 */
    .header {
        padding: 8px 10px;
    }
    
    /* 标签页更紧凑 */
    .tab {
        padding: 8px 10px;
        font-size: 11px;
    }
    
    /* 面板内边距减少 */
    .panel-body {
        padding: 10px;
    }
    
    /* 文件卡片更紧凑 */
    table tbody tr {
        padding: 12px;
        margin-bottom: 8px;
    }
    
    /* 批量操作栏紧凑 */
    .batch-action-inner {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 10px;
    }
    
    .batch-buttons {
        width: 100%;
        justify-content: flex-end;
    }
    
    /* 下拉选择器全宽 */
    .custom-dropdown-trigger {
        width: 100%;
    }
    
    /* 存储指示器更小 */
    .storage-mini .storage-bar {
        width: 24px;
    }
}

/* ========== 超小屏幕优化 (< 360px) ========== */
@media (max-width: 360px) {
    .brand-text {
        font-size: 11px;
    }
    
    .mobile-btn {
        width: 26px;
        height: 26px;
    }
    
    .tab {
        padding: 6px 8px;
        font-size: 10px;
    }
    
    table tbody tr {
        padding: 10px;
    }
    
    td.filename {
        font-size: 13px;
    }
    
    .file-icon {
        width: 32px;
        height: 40px;
    }
}

/* ========== 横向屏幕优化 (手机横屏) ========== */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        min-height: 48px;
        padding: 6px 10px;
    }
    
    .mobile-header-row {
        min-height: 32px;
    }
    
    .sidebar {
        margin-bottom: 8px;
    }
    
    .online-user-item {
        padding: 4px 6px;
        min-width: 48px;
    }
    
    .user-avatar {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }
}

/* ========== 文件类型网格优化 (填充宽度) ========== */
@media (min-width: 769px) and (max-width: 1200px) {
    .file-types-grid {
        grid-template-columns: repeat(6, 1fr) !important;
        gap: 12px;
    }
    
    .file-type-item {
        padding: 16px 8px;
    }
}

@media (min-width: 1201px) and (max-width: 1600px) {
    .file-types-grid {
        grid-template-columns: repeat(6, 1fr) !important;
        gap: 16px;
    }
}

@media (min-width: 1601px) {
    .file-types-grid {
        grid-template-columns: repeat(6, 1fr) !important;
        gap: 20px;
    }
}

/* ========== 私发用户选择下拉动画 ========== */
#targetUserRow {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    padding: 0;
    margin: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease, margin 0.3s ease;
}

#targetUserRow.show {
    max-height: 300px;
    opacity: 1;
    padding: 12px 0;
    margin-top: 12px;
}

/* 自定义下拉框样式 - 用户卡片式设计 */
.custom-select {
    position: relative;
    width: 100%;
}

/* 触发器样式 - 类似右图顶部卡片 */
.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
    font-size: 14px;
}

.custom-select-trigger:hover {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}

.custom-select-trigger.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

.custom-select-arrow {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.custom-select-trigger.active .custom-select-arrow {
    transform: rotate(180deg);
}

/* 选中项在触发器中的显示 */
.selected-user-preview {
    display: flex;
    align-items: center;
    gap: 10px;
}

.selected-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #238636 0%, #2ea043 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.selected-user-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.selected-user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.selected-user-status {
    font-size: 11px;
    color: #3fb950;
}

/* 下拉选项容器 - 卡片列表 - 修复裁剪问题 */
.custom-select-options {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: max-height 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    padding: 4px;
    min-width: 280px;
}

.custom-select-options.show {
    max-height: 280px;
    opacity: 1;
    transform: translateY(0);
    overflow-y: auto;
}

/* 单个选项卡片 */
.custom-select-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 10px;
    margin-bottom: 4px;
}

.custom-select-option:last-child {
    margin-bottom: 0;
}

.custom-select-option:hover {
    background: var(--bg-tertiary);
}

.custom-select-option.selected {
    background: rgba(88, 166, 255, 0.15);
    border: 1px solid rgba(88, 166, 255, 0.3);
}

/* 用户头像 - 缩小尺寸 */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1f6feb 0%, #58a6ff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(31, 111, 235, 0.3);
}

/* 默认选项的头像样式 */
.user-avatar.default {
    background: linear-gradient(135deg, #484f58 0%, #6e7681 100%);
    box-shadow: none;
}

/* 用户信息区域 */
.user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.user-device-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-device-id {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 在线状态指示 */
.user-status-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #3fb950;
    font-weight: 500;
    flex-shrink: 0;
}

.user-status-indicator::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #3fb950;
    border-radius: 50%;
    box-shadow: 0 0 4px #3fb950;
}

/* 下拉选择框样式优化 */
#targetUserSelect {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

#targetUserSelect:hover {
    border-color: var(--accent-primary);
}

#targetUserSelect:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.3);
    outline: none;
}

/* ========== 高分辨率屏幕优化 (> 2560px) ========== */
@media (min-width: 2560px) {
    :root {
        font-size: 16px;
    }
    
    .container {
        max-width: 1800px;
    }
    
    .header {
        height: 80px;
        padding: 0 40px;
    }
    
    body {
        padding-top: 80px;
    }
    
    th, td {
        padding: 18px 24px;
    }
}

/* ========== 打印优化 ========== */
@media print {
    .header,
    .sidebar,
    .mobile-header-content,
    .batch-action-bar,
    .action-btns,
    .file-actions,
    .btn {
        display: none !important;
    }
    
    body {
        padding-top: 0;
        background: white;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    table {
        width: 100%;
    }
    
    tr {
        page-break-inside: avoid;
    }
}
