/**
 * 出库传票信息核对系统 - 自定义样式
 * 配合 Tailwind CSS 使用
 */

/* 基础样式 */
* {
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.5;
    color: #1f2937;
    background-color: #f3f4f6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 安全区域适配 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .pb-20 {
        padding-bottom: calc(5rem + env(safe-area-inset-bottom));
    }
    
    nav.fixed {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ===== 动画 ===== */

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* 淡入 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* 滑入上移 */
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.slide-up {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 弹窗内容滑入 */
@keyframes modalSlideUp {
    from { transform: translateY(30px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-content-animate {
    animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 微弹跳 */
@keyframes bounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.bounce-in {
    animation: bounceIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===== 滚动条美化 ===== */

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ===== 按钮样式增强 ===== */

button {
    -webkit-tap-highlight-color: transparent;
}

button:active:not(:disabled) {
    transform: scale(0.97);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

/* ===== 输入框焦点样式 ===== */

input:focus,
select:focus,
textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ===== 图片预览 ===== */

#previewImage {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

/* 所有图片自动根据EXIF方向显示 */
img {
    image-orientation: from-image;
}

/* ===== 底部导航固定 ===== */

nav.fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(229, 231, 235, 0.5);
}

/* ===== 弹窗背景 ===== */

.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* ===== 身份证号等宽字体 ===== */

.font-mono {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    letter-spacing: 0.05em;
}

/* ===== 触摸优化 ===== */

@media (hover: none) {
    button, a {
        -webkit-touch-callout: none;
    }
}

/* ===== 响应式调整 ===== */

@media (min-width: 640px) {
    .max-w-lg {
        max-width: 512px;
    }
}

/* ===== 打印样式 ===== */

@media print {
    nav.fixed {
        display: none;
    }
    .pb-20 {
        padding-bottom: 0;
    }
}

/* ===== 文字选中样式 ===== */

::selection {
    background-color: rgba(59, 130, 246, 0.2);
    color: inherit;
}

/* ===== 搜索框样式 ===== */

input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    height: 14px;
    width: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 18L18 6M6 6l12 12'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    cursor: pointer;
}

/* ===== 日期选择器样式 ===== */

input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
}

/* ===== 加载遮罩层 ===== */

#loadingOverlay {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* ===== 状态指示器 ===== */

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.success {
    background-color: #10b981;
}

.status-dot.error {
    background-color: #ef4444;
}

.status-dot.warning {
    background-color: #f59e0b;
}

/* ===== 文字截断 ===== */

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== 图片加载占位 ===== */

img[data-src] {
    background-color: #f3f4f6;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 48px;
}

/* ===== 禁用选择 ===== */

.no-select {
    -webkit-user-select: none;
    user-select: none;
}

/* ===== 快速点击优化 ===== */

.click-fast {
    touch-action: manipulation;
}

/* ===== 卡片悬浮效果 ===== */

.card-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

/* ===== 渐变文字 ===== */

.text-gradient {
    background: linear-gradient(135deg, #1e40af, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== 结果卡片动画 ===== */

#resultContainer > div {
    animation: slideUp 0.3s ease-out;
}

#resultContainer > div:nth-child(2) {
    animation-delay: 0.1s;
}

#resultContainer > div:nth-child(3) {
    animation-delay: 0.2s;
}

/* ===== 毛玻璃卡片 ===== */

.glass-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ===== iOS 风格安全区域 ===== */

@supports (padding: env(safe-area-inset-top)) {
    .safe-top {
        padding-top: env(safe-area-inset-top);
    }
    .safe-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
