/* ============================================
   文档管理系统 - 前台样式（紧凑版）
   ============================================ */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
svg { width: 1em; height: 1em; vertical-align: middle; flex-shrink: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
    background: #f0f2f5;
    color: #1f2937;
    line-height: 1.5;
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* Layout */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #4f46e5;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
}
.logo-text {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
}
.logo-sub {
    font-size: 12px;
    color: #6b7280;
    margin-top: -2px;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.btn-logout {
    padding: 4px 12px;
    font-size: 12px;
    color: #6b7280;
    border-radius: 4px;
    transition: all .15s;
}
.btn-logout:hover {
    background: #f3f4f6;
    color: #1f2937;
}

/* Main */
.main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 20px;
    width: 100%;
}
.layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    align-items: start;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 64px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.stat-card {
    color: #fff;
    padding: 10px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.stat-card .stat-label {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}
.stat-card .stat-icon {
    width: 14px;
    height: 14px;
    opacity: 0.9;
}
.stat-card .stat-value {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}
.stat-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-green { background: linear-gradient(135deg, #10b981, #059669); }
.stat-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

/* Category Panel */
.panel {
    background: #fff;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    overflow: hidden;
}
.panel-header {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #111827;
}
.panel-header .icon {
    width: 14px;
    height: 14px;
    color: #4f46e5;
}
.panel-body { padding: 6px; }

.category-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    height: 34px;
    line-height: 34px;
    border-radius: 4px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: all .15s;
}
.category-item:hover { background: #f3f4f6; }
.category-item.active {
    background: #4f46e5;
    color: #fff;
    font-weight: 500;
}
.category-item .count {
    font-size: 12px;
    opacity: 0.7;
    background: rgba(0, 0, 0, 0.1);
    padding: 0 6px;
    height: 18px;
    line-height: 18px;
    border-radius: 9px;
    min-width: 18px;
    text-align: center;
}
.category-item:not(.active) .count {
    background: #f3f4f6;
    color: #6b7280;
    opacity: 1;
}

/* Main Content */
.content { min-width: 0; }

/* Search Bar */
.search-bar {
    margin-bottom: 12px;
    position: relative;
}
.search-bar input {
    width: 100%;
    height: 38px;
    padding: 0 14px 0 40px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.search-bar input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.search-bar .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: #9ca3af;
}

/* Result Bar */
.result-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 12px;
    color: #6b7280;
}
.result-bar strong { color: #111827; font-weight: 600; }
.result-bar .trend {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #4f46e5;
}

/* Document List */
.doc-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.doc-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: all .15s;
}
.doc-card:hover {
    border-color: #c7d2fe;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.08);
}
.doc-card.top { border-left: 3px solid #f59e0b; }

.doc-icon {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: #eef2ff;
    color: #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.doc-icon svg { width: 20px; height: 20px; }

.doc-info {
    flex: 1;
    min-width: 0;
}
.doc-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.doc-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 4px;
    line-height: 1.5;
    white-space: nowrap;
    flex-shrink: 0;
}
.badge-txt { background: #eef2ff; color: #4f46e5; }
.badge-cat { background: #f3f4f6; color: #6b7280; border: 1px solid #e5e7eb; }
.badge-hot { background: #fef3c7; color: #b45309; }
.badge-top { background: #fef3c7; color: #b45309; }

.doc-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #6b7280;
}
.doc-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.doc-meta .meta-item svg {
    width: 12px;
    height: 12px;
}

.doc-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 10px;
    height: 30px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    transition: all .15s;
    white-space: nowrap;
    border: 1px solid transparent;
    line-height: 1;
}
.btn svg { width: 13px; height: 13px; }
.btn-secondary {
    background: #fff;
    color: #4b5563;
    border-color: #d1d5db;
}
.btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #111827;
}
.btn-primary {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
}
.btn-primary:hover {
    background: #4338ca;
    border-color: #4338ca;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-loading {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-watermark-baidu {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}
.btn-watermark-baidu:hover { background: #dbeafe; }
.btn-watermark-360 {
    background: #ecfdf5;
    color: #059669;
    border-color: #a7f3d0;
}
.btn-watermark-360:hover { background: #d1fae5; }
.btn-watermark-bing {
    background: #fffbeb;
    color: #d97706;
    border-color: #fde68a;
}
.btn-watermark-bing:hover { background: #fef3c7; }

/* Watermark tag (display-only) */
.watermark-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 10px;
    height: 30px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid transparent;
    line-height: 1;
    cursor: default;
    user-select: none;
}
.watermark-tag svg { width: 13px; height: 13px; }
.watermark-tag.btn-watermark-baidu {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}
.watermark-tag.btn-watermark-360 {
    background: #ecfdf5;
    color: #059669;
    border-color: #a7f3d0;
}
.watermark-tag.btn-watermark-bing {
    background: #fffbeb;
    color: #d97706;
    border-color: #fde68a;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}
.pagination button {
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    background: #fff;
    font-size: 12px;
    color: #4b5563;
    transition: all .15s;
}
.pagination button:hover:not(:disabled) {
    border-color: #4f46e5;
    color: #4f46e5;
}
.pagination button.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}
.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.page-info {
    margin: 0 10px;
    font-size: 12px;
    color: #6b7280;
}

/* Empty State */
.empty-state {
    padding: 50px 20px;
    text-align: center;
    color: #9ca3af;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}
.empty-state .icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
    opacity: 0.3;
}
.empty-state p { font-size: 13px; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn .2s ease;
}
.modal {
    background: #fff;
    border-radius: 8px;
    width: 100%;
    max-width: 680px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    animation: slideUp .2s ease;
}
.modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.modal-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: #111827;
}
.modal-title svg { width: 16px; height: 16px; color: #4f46e5; flex-shrink: 0; }
.modal-title .t {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.modal-meta { font-size: 12px; color: #6b7280; margin-top: 2px; }
.modal-close {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.modal-close:hover { background: #f3f4f6; color: #374151; }
.modal-close svg { width: 16px; height: 16px; }
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
}
.modal-footer {
    padding: 10px 16px;
    border-top: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.preview-content {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 12px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 12px;
    line-height: 1.6;
    color: #1f2937;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 55vh;
    overflow-y: auto;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 10px 16px;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 3px solid #10b981;
    animation: toastIn .25s ease;
    min-width: 180px;
    max-width: 320px;
}
.toast.error { border-left-color: #ef4444; }
.toast.info { border-left-color: #3b82f6; }
.toast.success { border-left-color: #10b981; }
.toast .t-icon { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success .t-icon { color: #10b981; }
.toast.error .t-icon { color: #ef4444; }
.toast.info .t-icon { color: #3b82f6; }

/* Password page */
.password-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #eef2ff 0%, #f5f7fa 50%, #fae8ff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.password-card {
    width: 100%;
    max-width: 360px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(79, 70, 229, 0.12);
    padding: 28px 26px;
    text-align: center;
}
.password-card .logo-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.password-card h1 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #111827;
}
.password-card p {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 22px;
}
.password-card .form-group {
    text-align: left;
    margin-bottom: 16px;
}
.password-card label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}
.password-card input {
    width: 100%;
    height: 38px;
    padding: 0 14px 0 38px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: all .15s;
}
.password-card input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.password-card .input-wrap { position: relative; }
.password-card .input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: #9ca3af;
}
.password-card .btn-primary {
    width: 100%;
    height: 38px;
    font-size: 13px;
    border-radius: 6px;
}
.password-card .hint {
    margin-top: 12px;
    font-size: 11px;
    color: #9ca3af;
}
.error-msg {
    background: #fef2f2;
    color: #dc2626;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 14px;
    display: none;
}
.error-msg.show { display: block; }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Responsive */
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .category-list {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .category-item { flex: 0 0 auto; }
}
@media (max-width: 640px) {
    .header-inner { padding: 0 14px; }
    .main { padding: 14px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .doc-card { flex-direction: column; align-items: stretch; }
    .doc-actions { justify-content: flex-end; }
    .modal { margin: 10px; }
}
