/* ===== 文件柜样式 — 全面移动端适配 ===== */

/* ---------- 全局重置 ---------- */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 50%, #fdf4ff 100%);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
                 "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    color: #1f2937;
}

/* 隐藏文件输入框（用自定义按钮触发） */
input[type="file"] {
    display: none;
}

/* 通用隐藏 */
.hidden {
    display: none !important;
}

/* 显示在桌面端（≥ 768px） */
.md-only {
    display: none;
}
@media (min-width: 768px) {
    .md-only {
        display: block;
    }
}

/* ---------- 顶部导航 ---------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
    /* 全面屏安全区 */
    padding-top: env(safe-area-inset-top, 0);
}

.app-header-inner {
    max-width: 72rem;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-header-logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.app-header-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1.2;
}

.app-header-subtitle {
    font-size: 11px;
    color: #9ca3af;
    margin: 2px 0 0;
}

/* 桌面端导航放大 */
@media (min-width: 768px) {
    .app-header-inner {
        padding: 16px 24px;
        gap: 14px;
    }
    .app-header-logo {
        width: 44px;
        height: 44px;
        font-size: 22px;
    }
    .app-header-title {
        font-size: 22px;
    }
    .app-header-subtitle {
        font-size: 12px;
    }
}

/* ---------- 主体区域 ---------- */
.app-main {
    max-width: 72rem;
    margin: 0 auto;
    padding: 16px 12px 40px;
    /* 底部安全区 */
    padding-bottom: calc(env(safe-area-inset-bottom, 0) + 40px);
}

.app-grid {
    display: grid;
    gap: 16px;
}

@media (min-width: 768px) {
    .app-main {
        padding: 32px 24px 60px;
    }
    .app-grid {
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
}

/* ---------- 通用卡片 ---------- */
.app-card {
    background: #ffffff;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    padding: 18px 16px;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.08),
                0 1px 3px rgba(0, 0, 0, 0.04);
}

.upload-section {
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.08),
                0 1px 3px rgba(0, 0, 0, 0.04);
}

.download-section {
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.08),
                0 1px 3px rgba(0, 0, 0, 0.04);
}

@media (min-width: 768px) {
    .app-card {
        padding: 24px;
        border-radius: 24px;
    }
}

.app-card-title {
    font-size: 17px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 4px;
}

.app-card-desc {
    font-size: 12px;
    color: #9ca3af;
    margin: 0 0 16px;
}

@media (min-width: 768px) {
    .app-card-title {
        font-size: 18px;
    }
    .app-card-desc {
        font-size: 13px;
        margin-bottom: 20px;
    }
}

/* ---------- 按钮 ---------- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    color: #ffffff;
    border: none;
    cursor: pointer;
    min-height: 48px;                    /* 触摸目标 ≥ 44px */
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    touch-action: manipulation;          /* 消除点击延迟 */
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:disabled {
    background: linear-gradient(135deg, #d1d5db, #d1d5db);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.8;
}

/* ---------- 拖拽上传区 ---------- */
.drop-zone {
    border-radius: 16px;
    border: 2px dashed #c7d2fe;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s, transform 0.2s;
    background: linear-gradient(135deg, #f5f7ff, #faf5ff);
    overflow: hidden;
}

.drop-zone:hover {
    border-color: #a5b4fc;
    background: linear-gradient(135deg, #eef2ff, #f3f0ff);
}

.drop-zone.dragover {
    border-color: #6366f1;
    background: linear-gradient(135deg, #e0e7ff, #ede9fe);
    transform: scale(1.01);
}

.drop-zone.dragover .drop-icon {
    transform: scale(1.15) rotate(-5deg);
}

.drop-zone-inner {
    padding: 32px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

@media (min-width: 768px) {
    .drop-zone-inner {
        padding: 40px 20px;
    }
}

.drop-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #eef2ff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
    margin-bottom: 4px;
}

.drop-icon-svg {
    width: 28px;
    height: 28px;
    color: #6366f1;
}

@media (min-width: 768px) {
    .drop-icon {
        width: 64px;
        height: 64px;
    }
    .drop-icon-svg {
        width: 32px;
        height: 32px;
    }
}

.drop-text-primary {
    font-size: 15px;
    font-weight: 600;
    color: #4b5563;
    margin: 0;
}

.drop-text-secondary {
    font-size: 13px;
    color: #9ca3af;
    margin: 0;
}

.drop-warn {
    font-size: 11px;
    color: #d97706;
    margin: 12px 0 0;
}

/* 上传区里的按钮不应该满宽（拖拽区里已经有一个） */
#dropZone .btn-primary {
    width: auto;
    padding: 10px 28px;
    font-size: 14px;
    min-height: 44px;
}

/* ---------- 取件码输入区 ---------- */
.code-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@media (min-width: 768px) {
    .code-input-wrapper {
        flex-direction: row;
        align-items: flex-start;
        gap: 20px;
    }
}

.code-input-area {
    flex: 1;
    min-width: 0;
}

.code-display {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 64px;
    border-radius: 14px;
    border: 2px solid #e5e7eb;
    background: #f9fafb;
    font-family: 'SF Mono', 'Menlo', 'Consolas', 'Courier New', monospace;
    font-size: 22px;
    letter-spacing: 0.28em;
    transition: border-color 0.2s, box-shadow 0.2s;
    user-select: none;
}

@media (min-width: 768px) {
    .code-display {
        height: 68px;
        font-size: 28px;
        letter-spacing: 0.35em;
    }
}

.code-dots {
    color: #4f46e5;
    font-weight: 700;
}

.code-dots.empty {
    color: #cbd5e1;
    font-weight: 400;
}

.code-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fee2e2;
    color: #dc2626;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.15s;
}

.code-clear:active {
    background: #fecaca;
}

/* 查询按钮上边距 */
.code-input-area .btn-primary {
    margin-top: 14px;
}

/* ---------- 小键盘 ---------- */
.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .numpad {
        width: 180px;
        max-width: 180px;
        flex-shrink: 0;
        margin: 0;
    }
}

.numpad-btn {
    height: 56px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 18px;
    color: #374151;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    background: #ffffff;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: transform 0.08s, box-shadow 0.08s, background 0.1s;
    font-family: inherit;
}

.numpad-btn:hover {
    background: #f9fafb;
}

.numpad-btn:active,
.numpad-btn.pressed {
    transform: scale(0.93);
    background: #eef2ff;
    box-shadow: 0 1px 3px rgba(99, 102, 241, 0.15);
    color: #4f46e5;
}

/* 特殊按键颜色 */
.numpad-clear {
    color: #dc2626;
    background: #fff1f2;
    border-color: #fecaca;
}
.numpad-clear:active, .numpad-clear.pressed {
    background: #fee2e2;
    color: #dc2626;
}

.numpad-back {
    color: #b45309;
    background: #fffbeb;
    border-color: #fde68a;
}
.numpad-back:active, .numpad-back.pressed {
    background: #fef3c7;
    color: #b45309;
}
.numpad-back svg {
    width: 22px;
    height: 22px;
    margin: 0 auto;
}

/* ---------- 进度条 ---------- */
.progress-item {
    background: #f9fafb;
    border-radius: 10px;
    padding: 12px;
}

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

.progress-item .truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 999px;
    transition: width 0.3s ease-out;
}

/* ---------- 结果卡片 ---------- */
.result-card {
    border-radius: 12px;
    padding: 14px;
    border: 1px solid;
}

.result-card.success {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border-color: #bbf7d0;
}

.result-card.error {
    background: linear-gradient(135deg, #fef2f2, #fff1f2);
    border-color: #fecaca;
}

.code-card {
    position: relative;
    overflow: hidden;
    border-radius: 14px;
    padding: 18px 16px;
    text-align: center;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    margin-top: 10px;
}

.code-card::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.code-card::after {
    content: '';
    position: absolute;
    bottom: -40px;
    left: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.code-label {
    font-size: 11px;
    opacity: 0.8;
    letter-spacing: 0.15em;
    margin-bottom: 4px;
}

.code-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.3em;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

@media (min-width: 768px) {
    .code-value {
        font-size: 32px;
    }
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 12px;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
    backdrop-filter: blur(4px);
    min-height: 36px;
}

.copy-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

/* ---------- 查询结果 ---------- */
.file-info-card {
    border-radius: 12px;
    padding: 14px;
    border: 1px solid #e9d5ff;
    background: linear-gradient(135deg, #faf5ff, #fdf4ff);
}

@media (min-width: 768px) {
    .file-info-card {
        padding: 16px;
    }
}

.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    color: #ffffff;
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
    text-decoration: none;
    border: none;
    cursor: pointer;
    min-height: 48px;
    transition: transform 0.15s, box-shadow 0.15s;
    touch-action: manipulation;
}

.download-btn:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0) + 20px);
    left: 50%;
    transform: translate(-50%, -120%);
    padding: 12px 24px;
    border-radius: 12px;
    color: #ffffff;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: linear-gradient(135deg, #1f2937, #374151);
    max-width: 90vw;
    font-size: 14px;
    text-align: center;
}

.toast.show {
    transform: translate(-50%, 0);
}

.toast.success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.toast.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* ---------- 通用动画 ---------- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.25s ease-out;
}

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 禁用 iOS 上的长按选中/菜单 */
.numpad-btn,
.btn-primary,
.code-clear,
.drop-zone,
.copy-btn,
.download-btn {
    -webkit-user-select: none;
    user-select: none;
}
