/* 浏览页与通用样式（由 main.css 拆分） */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
/* 设计系统变量与主题 */
:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --primary: #6366f1;
    --primary-hover: #5458e6;
    --success: #22c55e;
    --danger: #ef4444;
    --radius: 12px;
    --shadow: 0 10px 25px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
    --bg: #0d1117;
    --surface: #0f172a;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --border: #1f2937;
    --primary: #818cf8;
    --primary-hover: #6d75f2;
    --success: #22c55e;
    --danger: #f87171;
    --shadow: 0 10px 25px rgba(0,0,0,0.35);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.25s ease, color 0.25s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
}

/* 登录界面样式（通用） */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-title {
    text-align: center;
    margin-bottom: 30px;
    font-size: 24px;
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.login-btn:hover {
    background: #5a6fd8;
}

.login-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.error-message {
    color: #e74c3c;
    text-align: center;
    margin-top: 10px;
    font-size: 14px;
}

/* 头部样式 */
.header {
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.title {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.username {
    color: #666;
    font-size: 14px;
}

.logout-btn {
    padding: 8px 16px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.logout-btn:hover {
    background: #c0392b;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}

.breadcrumb-item {
    padding: 6px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    text-decoration: none;
    color: #495057;
    font-size: 14px;
    transition: all 0.2s;
}

.breadcrumb-item:hover {
    background: #e9ecef;
    color: #212529;
}

.breadcrumb-item.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.breadcrumb-separator {
    color: #6c757d;
    margin: 0 5px;
}

.view-controls {
    display: flex;
    flex: 1;
    gap: 10px;
    justify-content: flex-end;
}

.view-btn {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    background: #f8f9fa;
    color: #495057;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.view-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.refresh-btn {
    padding: 8px 12px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.refresh-btn:hover {
    background: #218838;
}

/* 内容区域 */
.content {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    min-height: 400px;
}

.content-header {
    display: flex;
    flex-direction: column; /* 修复错误属性：direction → flex-direction */
    width: 100%;
    gap: 12px;
    justify-content: space-between;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.error {
    text-align: center;
    padding: 40px;
    color: #e74c3c;
}

.empty {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* 网格视图 */
.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.grid-item {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    background: #fff;
}

.grid-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.grid-item.folder {
    background: #f8f9fa;
}

.grid-item.file {
    background: white;
}

.item-thumbnail {
    width: 100%;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    position: relative;
    overflow: hidden;
}

.item-thumbnail img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.item-thumbnail .icon {
    font-size: 48px;
    color: #6c757d;
}

.item-info {
    padding: 12px;
}

.item-name {
    font-weight: 500;
    margin-bottom: 4px;
    word-break: break-word;
    font-size: 14px;
}

.item-meta {
    font-size: 12px;
    color: #6c757d;
}

/* 列表视图 */
.list-view {
    display: flex;
    flex-direction: column;
}

.list-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    transition: background 0.2s;
    cursor: pointer;
}

.list-item:hover {
    background: #f8f9fa;
}

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

.list-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 20px;
    color: #6c757d;
}

.list-info {
    flex: 1;
}

.list-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.list-meta {
    font-size: 12px;
    color: #6c757d;
}

/* 适配 index.html 使用的类名，专门处理长文件名在移动端的显示 */
.grid-item-content {
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 6px;
}

.grid-item-icon {
    font-size: 28px;
    line-height: 1;
}

.grid-item-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    /* 多行截断，最多 2 行 */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    word-break: break-all;
}

.grid-item-info {
    font-size: 12px;
    color: var(--text-muted);
}

.list-item-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 20px;
    color: #6c757d;
}

.list-item-content {
    flex: 1;
    min-width: 0; /* 允许子元素正确截断 */
}

.list-item-name {
    font-weight: 600;
    font-size: 14px;
    /* 单行省略号 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-info {
    font-size: 12px;
    color: var(--text-muted);
}

/* 模态框（图片预览） */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
}

.modal-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 20px;
}

/* 兼容两种命名（modal-nav 与 modal-navigation） */
.modal-nav,
.modal-navigation {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    font-size: 24px;
}

.modal-nav.prev,
.modal-navigation.prev {
    left: 20px;
}

.modal-nav.next,
.modal-navigation.next {
    right: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container { padding: 6px; }
    .header { padding: 10px 12px; }
    .user-info { flex-wrap: wrap; gap: 8px; }
    .view-controls { flex-wrap: wrap; gap: 8px; justify-content: flex-start; }
    .breadcrumb { margin-bottom: 6px; }
    .grid-view { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .grid-item-name { -webkit-line-clamp: 2; }
    .list-item-name { font-size: 13px; }
    .item-thumbnail { height: 120px; }
    .login-box { margin: 20px; padding: 30px; }
}

@media (max-width: 480px) {
    .grid-view { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .item-thumbnail { height: 100px; }
    .modal-nav, .modal-navigation { width: 40px; height: 40px; font-size: 20px; }
    .modal-close { width: 35px; height: 35px; margin-top: 10px; font-size: 18px; }
    .grid-item-name { font-size: 13px; }
    .list-item-name { font-size: 12.5px; }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .grid-item:hover,
    .list-item:hover { transform: none; background: #f8f9fa; }
    .view-btn:hover,
    .refresh-btn:hover,
    .logout-btn:hover { background: inherit; }
}

/* 安全组件样式（图片） */
.secure-image-container { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.secure-image-container img { width: 100%; height: 100%; object-fit: cover; }
.modal-image { max-width: 100%; max-height: 90vh; object-fit: contain; }

/* 延迟加载样式 */
.image-lazy-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    min-height: 120px;
    transition: all 0.3s ease;
}

.image-lazy-placeholder:hover { background: #e9ecef; border-color: #007bff; }
.lazy-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.6; }

.load-image-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 8px;
}

.load-image-btn:hover { background: #0056b3; transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3); }
.load-image-btn:active { transform: translateY(0); }
.lazy-hint { font-size: 11px; color: #6c757d; text-align: center; }

.retry-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover { background: #c82333; }
.error-icon { font-size: 24px; margin-bottom: 8px; }