/* ==========================================================================
   TG图床 用户端样式 — Clean & Modern
   ========================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --success: #10b981;
    --info: #3b82f6;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ====== 用户导航栏 ====== */
.user-nav {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    height: 56px;
    padding: 0 24px;
}
.user-nav-inner {
    display: flex;
    align-items: center;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
}
.user-nav-brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    margin-right: 32px;
}
.user-nav-links {
    display: flex;
    list-style: none;
    gap: 4px;
}
.user-nav-links li a {
    display: block;
    padding: 8px 16px;
    color: var(--text-light);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.15s;
}
.user-nav-links li a:hover { background: var(--bg); color: var(--text); }
.user-nav-links li a.active { background: var(--primary); color: #fff; }
.user-nav-actions { margin-left: auto; }

/* ====== 登录/注册卡片 ====== */
.user-auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 24px;
}
.user-auth-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    padding: 40px 40px 36px;
    width: 100%;
    max-width: 420px;
}
.user-auth-card h2 {
    text-align: center;
    margin-bottom: 6px;
    font-size: 26px;
    color: var(--text);
    font-weight: 700;
}
.user-auth-card .auth-subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 28px;
}

/* ====== 表单元素 ====== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}
.form-row {
    display: flex;
    gap: 16px;
}
.form-row .form-group { flex: 1; }
.form-input, .form-select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}
.form-input:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-input::placeholder { color: #cbd5e1; }
.form-msg {
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
}
.form-msg:not(:empty) { color: var(--danger); }
.form-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-light);
}
.form-footer a { color: var(--primary); text-decoration: none; }
.form-footer a:hover { text-decoration: underline; }
.form-hint { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* ====== 按钮 ====== */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    text-align: center;
    line-height: 1.4;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: var(--warning-hover); }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { background: #2563eb; }
.btn-outline {
    background: transparent;
    color: var(--text-light);
    border-color: var(--border);
}
.btn-outline:hover {
    background: var(--bg);
    color: var(--text);
}

/* ====== 用户主体 ====== */
.user-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}
.user-page-header {
    margin-bottom: 24px;
}
.user-page-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}
.page-desc {
    color: var(--text-light);
    font-size: 14px;
    margin-top: 4px;
}

/* ====== 上传区 ====== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
    background: var(--card-bg);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: #eef2ff;
}
.upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-zone-inner p { color: var(--text-light); margin-bottom: 4px; }
.upload-hint { font-size: 13px; }
.upload-zone-inner .btn { margin-top: 16px; }

.upload-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}
.upload-preview-item {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
.upload-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.upload-preview-item .remove-preview {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 14px;
    line-height: 22px;
    text-align: center;
}
.upload-progress {
    margin-top: 12px;
}

/* ====== 媒体库 ====== */
.user-media-toolbar {
    margin-bottom: 16px;
}
.toolbar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 12px;
}
.toolbar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 420px;
}
.large-search .form-input {
    padding-left: 40px;
    padding-right: 36px;
    height: 44px;
    font-size: 15px;
}
.large-search .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-light);
    pointer-events: none;
}
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.sort-group .form-select {
    width: auto;
    height: 44px;
}

/* 批量操作悬浮栏 */
.batch-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--primary);
    color: #fff;
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    animation: fadeSlideIn 0.2s ease;
}
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.batch-bar-count {
    font-size: 14px;
    font-weight: 500;
}
.batch-bar-actions {
    display: flex;
    gap: 8px;
}
.batch-bar-actions .btn {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}
.batch-bar-actions .btn:hover {
    background: rgba(255,255,255,0.35);
}
.batch-bar-actions .btn-danger { background: rgba(239,68,68,0.8); }
.batch-bar-actions .btn-danger:hover { background: rgba(239,68,68,1); }

.media-stats-total {
    font-size: 13px;
    color: var(--text-light);
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.media-card {
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
    position: relative;
    border: 2px solid transparent;
}
.media-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}
.media-card.selected-card {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79,70,229,0.2);
}

.media-card .media-img {
    width: 100%;
    height: 170px;
    object-fit: cover;
    display: block;
    background: #f1f5f9;
}

.media-card .media-select-check {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 2px solid #fff;
    background: rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.15s;
    color: #fff;
    font-size: 13px;
}
.media-card:hover .media-select-check,
.media-card.selected-card .media-select-check {
    opacity: 1;
}
.media-card.selected-card .media-select-check {
    background: var(--primary);
    border-color: var(--primary);
}

.media-card .media-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.5) 100%);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.media-card:hover .media-overlay {
    opacity: 1;
}

.media-card .media-quick-actions {
    position: absolute;
    bottom: 50px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.2s;
}
.media-card:hover .media-quick-actions {
    opacity: 1;
}
.media-card .media-quick-actions button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255,255,255,0.9);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.media-card .media-quick-actions button:hover {
    background: #fff;
}

.media-card .media-info {
    padding: 10px 12px;
}
.media-card .media-name {
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}
.media-card .media-meta {
    color: var(--text-light);
    font-size: 11px;
    margin-top: 3px;
}
.media-card .media-actions {
    display: none;
}

.media-pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 24px;
    flex-wrap: wrap;
}
.media-pager button {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    transition: all 0.15s;
}
.media-pager button:hover { background: var(--bg); border-color: var(--primary); }
.media-pager button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.media-pager button.nav-btn { font-size: 14px; font-weight: 600; }
.media-pager .pager-ellipsis {
    width: 36px;
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
}

/* ====== 用户中心 ====== */
.user-profile-cards {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.profile-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 28px 32px;
}
.profile-card h3 {
    margin-bottom: 16px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.profile-info {
    font-size: 14px;
}
.profile-info table { width: 100%; border-collapse: collapse; }
.profile-info table td {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.profile-info table td:first-child { color: var(--text-light); width: 120px; font-weight: 500; }
.profile-info table tr:last-child td { border-bottom: none; }
.quota-value { font-weight: 600; }
.quota-full { color: var(--danger); }

.input-copy-group {
    display: flex;
    gap: 8px;
    align-items: center;
}
.input-copy-group input { flex: 1; }

/* ====== 页脚 ====== */
.user-footer {
    text-align: center;
    padding: 32px 24px;
    color: var(--text-light);
    font-size: 13px;
}

/* ====== 进度条 ====== */
.progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}
.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    border-radius: 4px;
    transition: width 0.3s ease;
}
.progress-label {
    font-size: 13px;
    color: var(--text-light);
    min-width: 36px;
    text-align: right;
}

/* ====== 加载转圈 ====== */
.upload-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    text-align: center;
    z-index: 10;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ====== 上传结果弹窗 ====== */
.upload-result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.upload-result-modal {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 32px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
}
.upload-result-modal h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 16px;
    text-align: center;
}
.result-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}
.result-close:hover { color: var(--text); }
.result-preview {
    width: 100%;
    height: 200px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg);
    margin-bottom: 12px;
}
.result-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.result-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 12px;
}
.result-link-group {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.result-link-group input { flex: 1; font-size: 13px; }
.result-remaining {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 16px;
    text-align: center;
}
.result-actions {
    text-align: center;
}

/* ====== 统计卡片 ====== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.stat-card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 20px 12px;
    text-align: center;
    border: 1px solid var(--border);
}
.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}
.stat-label {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}
.stat-recent-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.stat-recent-item:last-child { border-bottom: none; }
.stat-recent-name {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 12px;
}
.stat-recent-size {
    color: var(--text-light);
    white-space: nowrap;
}

/* 纯 CSS 柱状图 */
.css-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    height: 120px;
    padding: 0 4px;
}
.chart-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}
.chart-bar-val {
    font-size: 11px;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 2px;
}
.chart-bar-fill {
    width: 100%;
    max-width: 36px;
    background: linear-gradient(180deg, var(--primary) 0%, #818cf8 100%);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.5s ease;
}
.chart-bar-label {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 6px;
}

/* ====== API 文档 ====== */
.api-endpoint {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.api-method {
    background: var(--success);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.api-url {
    font-size: 14px;
    color: var(--text);
    word-break: break-all;
}
.api-params {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.api-params th {
    background: var(--bg);
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text);
}
.api-params td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-light);
}
.api-params tr:last-child td { border-bottom: none; }
.api-code {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
