/* ===== 图床样式 (兼容IE11+) ===== */
/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    font-size: 14px; color: #333; background: #f5f5f5;
    min-height: 100vh;
}
a { color: #2196F3; text-decoration: none; }
a:hover { text-decoration: underline; }
img { border: none; }

/* Layout */
.header {
    background: #fff; border-bottom: 1px solid #e0e0e0;
    padding: 12px 20px; position: sticky; top: 0; z-index: 100;
    display: -ms-flexbox; display: flex;
    -ms-flex-align: center; align-items: center;
    -ms-flex-pack: justify; justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.header h1 {
    margin: 0; font-size: 18px; font-weight: 600;
    display: -ms-flexbox; display: flex;
    -ms-flex-align: center; align-items: center;
    gap: 8px;
}
.header h1 .logo { color: #2196F3; }
.header .nav-btns {
    display: -ms-flexbox; display: flex;
    gap: 6px; -ms-flex-wrap: wrap; flex-wrap: wrap;
}
.btn {
    display: inline-block; padding: 7px 16px; cursor: pointer;
    font-size: 13px; border: 1px solid #ccc; border-radius: 4px;
    background: #fff; color: #333;
    transition: background 0.15s, border-color 0.15s;
    -ms-user-select: none; user-select: none;
    white-space: nowrap;
}
.btn:hover { background: #f0f0f0; border-color: #aaa; }
.btn-primary { background: #2196F3; color: #fff; border-color: #1976D2; }
.btn-primary:hover { background: #1976D2; }
.btn-danger { background: #f44336; color: #fff; border-color: #d32f2f; }
.btn-danger:hover { background: #d32f2f; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Main content */
.container { max-width: 1200px; margin: 0 auto; padding: 16px; }

/* Upload Zone */
.upload-zone {
    border: 2px dashed #bbb; border-radius: 8px;
    padding: 40px 20px; text-align: center;
    background: #fafafa; margin-bottom: 20px;
    cursor: pointer; transition: border-color 0.2s, background 0.2s;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: #2196F3; background: #E3F2FD;
}
.upload-zone .icon { font-size: 48px; color: #bbb; margin-bottom: 10px; }
.upload-zone p { margin: 0; color: #666; font-size: 15px; }
.upload-zone .sub { font-size: 12px; color: #999; margin-top: 6px; }
.upload-progress {
    margin-top: 12px; display: none;
}
.upload-progress .bar {
    height: 4px; background: #e0e0e0; border-radius: 2px; overflow: hidden;
}
.upload-progress .bar-inner {
    height: 100%; background: #2196F3; width: 0%;
    transition: width 0.3s;
}
.upload-progress .text { font-size: 12px; color: #666; margin-top: 4px; }

/* Toolbar */
.toolbar {
    display: -ms-flexbox; display: flex;
    -ms-flex-align: center; align-items: center;
    -ms-flex-pack: justify; justify-content: space-between;
    margin-bottom: 16px; gap: 8px; -ms-flex-wrap: wrap; flex-wrap: wrap;
}
.toolbar .left { display: -ms-flexbox; display: flex; gap: 6px; -ms-flex-align: center; align-items: center; }
.toolbar .right { display: -ms-flexbox; display: flex; gap: 6px; -ms-flex-align: center; align-items: center; }
.search-box {
    display: -ms-flexbox; display: flex; gap: 0;
}
.search-box input {
    padding: 7px 10px; border: 1px solid #ccc;
    border-right: none; border-radius: 4px 0 0 4px; font-size: 13px;
    width: 180px; outline: none;
}
.search-box input:focus { border-color: #2196F3; }
.search-box button {
    border-radius: 0 4px 4px 0; margin: 0;
}

/* Stats bar */
.stats-bar {
    background: #fff; border: 1px solid #e0e0e0;
    border-radius: 6px; padding: 12px 16px; margin-bottom: 16px;
    display: -ms-flexbox; display: flex;
    gap: 20px; -ms-flex-wrap: wrap; flex-wrap: wrap;
    font-size: 13px; color: #666;
}
.stats-bar strong { color: #333; }

/* Gallery Grid */
.gallery {
    display: -ms-flexbox; display: flex;
    -ms-flex-wrap: wrap; flex-wrap: wrap;
    gap: 10px; margin-bottom: 20px;
}
.gallery-item {
    width: calc(20% - 8px); position: relative;
    border-radius: 6px; overflow: hidden;
    background: #fff; border: 1px solid #e0e0e0;
    cursor: pointer; transition: box-shadow 0.2s, transform 0.15s;
    aspect-ratio: 1 / 1;
}
.gallery-item:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}
.gallery-item img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
}
.gallery-item .overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    padding: 8px; color: #fff; font-size: 11px; opacity: 0;
    transition: opacity 0.2s; pointer-events: none;
}
.gallery-item:hover .overlay { opacity: 1; }
.gallery-item .check {
    position: absolute; top: 6px; right: 6px;
    width: 22px; height: 22px; border-radius: 50%;
    background: rgba(255,255,255,0.9); border: 2px solid #ccc;
    display: none; -ms-flex-align: center; align-items: center;
    -ms-flex-pack: center; justify-content: center;
    font-size: 12px; color: #fff; z-index: 2;
}
.gallery-item .check.checked { display: -ms-flexbox; display: flex; background: #2196F3; border-color: #2196F3; }
.select-mode .gallery-item .check { display: -ms-flexbox; display: flex; }

/* Empty state */
.empty-state {
    text-align: center; padding: 60px 20px; color: #999; width: 100%;
}
.empty-state .icon { font-size: 64px; margin-bottom: 12px; }

/* Pagination */
.pagination {
    text-align: center; margin: 20px 0;
}
.pagination .btn {
    min-width: 36px; text-align: center;
}
.pagination .current { 
    display: inline-block; padding: 7px 12px; font-size: 13px; color: #666;
}

/* Modal */
.modal-mask {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: none; -ms-flex-align: center; align-items: center;
    -ms-flex-pack: center; justify-content: center;
}
.modal-mask.active { display: -ms-flexbox; display: flex; }
.modal {
    background: #fff; border-radius: 8px; width: 90%; max-width: 500px;
    max-height: 80vh; overflow: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-header {
    display: -ms-flexbox; display: flex;
    -ms-flex-pack: justify; justify-content: space-between;
    -ms-flex-align: center; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid #e0e0e0;
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; }
.modal-footer {
    padding: 12px 18px; border-top: 1px solid #e0e0e0;
    text-align: right; display: -ms-flexbox; display: flex;
    -ms-flex-pack: end; justify-content: flex-end; gap: 6px;
}
.modal input[type="text"] {
    width: 100%; padding: 8px 10px; border: 1px solid #ccc;
    border-radius: 4px; font-size: 13px;
    outline: none; margin-bottom: 10px;
}
.modal input[type="text"]:focus { border-color: #2196F3; }

/* Collections sidebar */
.collections-panel {
    background: #fff; border: 1px solid #e0e0e0;
    border-radius: 6px; margin-bottom: 16px; overflow: hidden;
}
.collections-panel .panel-header {
    padding: 10px 14px; background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
    font-weight: 600; font-size: 13px;
    display: -ms-flexbox; display: flex;
    -ms-flex-pack: justify; justify-content: space-between;
    -ms-flex-align: center; align-items: center;
}
.collections-list {
    display: -ms-flexbox; display: flex;
    -ms-flex-wrap: wrap; flex-wrap: wrap; gap: 4px;
    padding: 8px 10px;
}
.collection-tag {
    display: inline-block; padding: 4px 12px;
    background: #f0f0f0; border-radius: 12px;
    font-size: 12px; cursor: pointer; transition: background 0.15s;
    border: none; color: #333;
}
.collection-tag:hover { background: #e0e0e0; }
.collection-tag.active { background: #2196F3; color: #fff; }
.collection-tag .count {
    font-size: 11px; opacity: 0.7; margin-left: 4px;
}

/* Image Detail Modal */
.detail-modal .modal { max-width: 90vw; max-height: 90vh; }
.detail-modal .modal-body { text-align: center; padding: 0; }
.detail-modal .modal-body img {
    max-width: 100%; max-height: 70vh; display: block;
}
.detail-modal .info-bar {
    padding: 10px 16px; display: -ms-flexbox; display: flex;
    -ms-flex-align: center; align-items: center;
    -ms-flex-pack: justify; justify-content: space-between;
    gap: 10px; -ms-flex-wrap: wrap; flex-wrap: wrap;
    font-size: 12px; color: #666;
    border-top: 1px solid #e0e0e0;
}
.detail-modal .info-bar .actions {
    display: -ms-flexbox; display: flex; gap: 6px;
}

/* Viewer / Reading Mode */
.viewer-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: #111; z-index: 2000;
    display: none; -ms-flex-direction: column; flex-direction: column;
}
.viewer-overlay.active { display: -ms-flexbox; display: flex; }
.viewer-toolbar {
    display: -ms-flexbox; display: flex;
    -ms-flex-align: center; align-items: center;
    -ms-flex-pack: justify; justify-content: space-between;
    padding: 10px 16px; background: rgba(0,0,0,0.8);
    color: #fff; font-size: 13px; position: relative; z-index: 10;
}
.viewer-toolbar .left, .viewer-toolbar .right {
    display: -ms-flexbox; display: flex;
    -ms-flex-align: center; align-items: center; gap: 8px;
}
.viewer-toolbar .btn {
    background: transparent; color: #fff; border-color: rgba(255,255,255,0.3);
}
.viewer-toolbar .btn:hover { background: rgba(255,255,255,0.15); }
.viewer-toolbar .btn-close {
    font-size: 20px; padding: 4px 12px;
}
.viewer-body {
    -ms-flex: 1; flex: 1;
    display: -ms-flexbox; display: flex;
    -ms-flex-align: center; align-items: center;
    -ms-flex-pack: center; justify-content: center;
    overflow: hidden; position: relative;
    -ms-touch-action: pan-x pan-y; touch-action: pan-x pan-y;
}
.viewer-body img {
    max-width: 100%; max-height: 100%;
    object-fit: contain; transition: transform 0.15s;
    -ms-user-select: none; user-select: none;
    -webkit-user-drag: none;
}
.viewer-body img.zoomed {
    cursor: grab;
    max-width: none; max-height: none;
}
.viewer-body img.zoomed:active { cursor: grabbing; }
.viewer-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    font-size: 36px; color: rgba(255,255,255,0.6);
    cursor: pointer; padding: 20px 10px;
    transition: color 0.15s; z-index: 5;
    -ms-user-select: none; user-select: none;
}
.viewer-nav:hover { color: #fff; }
.viewer-nav.prev { left: 10px; }
.viewer-nav.next { right: 10px; }
.viewer-counter {
    position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
    color: rgba(255,255,255,0.6); font-size: 13px;
    background: rgba(0,0,0,0.5); padding: 4px 12px; border-radius: 12px;
}

/* Toast notifications */
.toast {
    position: fixed; top: 60px; right: 20px; z-index: 3000;
    padding: 10px 18px; border-radius: 6px; font-size: 13px;
    color: #fff; max-width: 350px;
    transform: translateX(120%); transition: transform 0.3s;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}
.toast.show { transform: translateX(0); }
.toast.success { background: #4CAF50; }
.toast.error { background: #f44336; }
.toast.info { background: #2196F3; }

/* Responsive */
@media (max-width: 992px) {
    .gallery-item { width: calc(25% - 8px); }
}
@media (max-width: 768px) {
    .gallery-item { width: calc(33.33% - 8px); }
    .search-box input { width: 120px; }
    .header { -ms-flex-direction: column; flex-direction: column; gap: 8px; }
    .header .nav-btns { width: 100%; -ms-flex-pack: center; justify-content: center; }
}
@media (max-width: 480px) {
    .gallery-item { width: calc(50% - 5px); }
}

/* IE11 specific fixes */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .gallery-item { height: 200px; }
    .gallery-item .overlay { opacity: 1; background: rgba(0,0,0,0.5); }
    .btn { padding: 6px 14px; }
}
