/* ============================================
   复材维修胶料储存系统 - 样式表
   版本: 1.0
   说明: 响应式设计，适配移动端(iOS/Android/华为) + PC端
   ============================================ */

/* ==================== CSS 变量 ==================== */
:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --success: #27ae60;
    --success-light: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --gray-50: #f8f9fa;
    --gray-100: #ecf0f1;
    --gray-200: #d5dbdb;
    --gray-300: #bdc3c7;
    --gray-600: #5d6d7e;
    --gray-800: #2c3e50;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-sm: 4px;
    --transition: all 0.2s ease;
}

/* ==================== Reset ==================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
                 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica,
                 Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ==================== 主导航 ==================== */
.main-nav {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 20px 16px;
    min-height: 100vh;
}

.nav-title {
    color: #fff;
    font-size: 1.25rem;
    text-align: center;
    margin-bottom: 24px;
    font-weight: 600;
}

.nav-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 400px;
    margin: 0 auto;
}

.nav-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 12px;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius);
    color: #fff;
    text-decoration: none;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}

.nav-card:active {
    background: rgba(255,255,255,0.3);
    transform: scale(0.96);
}

.nav-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.nav-label {
    font-size: 0.875rem;
    font-weight: 500;
}

/* ==================== 页面头 ==================== */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
}

.btn-back {
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--primary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.btn-back:active {
    background: var(--gray-100);
}

/* ==================== 搜索栏 ==================== */
.search-section {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid var(--gray-100);
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 120px;
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.938rem;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41,128,185,0.15);
}

/* ==================== Tab 切换 ==================== */
.tab-bar {
    display: flex;
    background: #fff;
    border-bottom: 2px solid var(--gray-100);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
    flex: none;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 0.875rem;
    color: var(--gray-600);
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.tab-content {
    display: none;
    padding: 16px;
}

.tab-content.active {
    display: block;
}

/* ==================== 卡片 ==================== */
.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 16px;
    margin: 12px 16px;
    box-shadow: var(--shadow);
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--gray-800);
    border-bottom: 1px solid var(--gray-100);
    padding-bottom: 8px;
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.938rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:active { background: var(--primary-light); }

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-800);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-full {
    width: 100%;
    margin-top: 8px;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.813rem;
}

/* ==================== 表单 ==================== */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.938rem;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41,128,185,0.15);
}

.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.938rem;
    background: #fff;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235d6d7e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

/* ==================== 数据列表 ==================== */
.data-list {
    padding: 16px;
}

.data-item {
    background: #fff;
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.data-item:active {
    box-shadow: var(--shadow-lg);
}

.data-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.data-item-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.data-item-info {
    font-size: 0.813rem;
    color: var(--gray-600);
    line-height: 1.8;
}

.data-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* ==================== 状态标签 ==================== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background: #d5f5e3; color: #1e8449; }
.badge-warning { background: #fdebd0; color: #b9770e; }
.badge-danger  { background: #fadbd8; color: #c0392b; }
.badge-info    { background: #d6eaf8; color: #2471a3; }

/* ==================== 用量计算结果 ==================== */
.calc-result {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 14px;
    margin-top: 12px;
}

.calc-result .result-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px dashed var(--gray-200);
    font-size: 0.875rem;
}

.calc-result .result-row:last-child { border-bottom: none; }
.calc-result .result-label { color: var(--gray-600); }
.calc-result .result-value { font-weight: 600; color: var(--gray-800); }
.calc-result .result-highlight { color: var(--danger); font-weight: 700; }

/* ==================== 单位转换 ==================== */
.convert-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.convert-input {
    flex: 1;
}

.convert-input label {
    display: block;
    font-size: 0.813rem;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.convert-arrow {
    font-size: 1.5rem;
    color: var(--primary-light);
    flex: none;
    margin-top: 16px;
}

.convert-actions {
    text-align: center;
}

/* ==================== 器材网格 ==================== */
.equip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 16px;
}

.equip-item {
    background: #fff;
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.equip-item:active {
    transform: scale(0.97);
}

.equip-item.selected {
    border-color: var(--success);
    background: #eafaf1;
}

.equip-item.prepared {
    border-color: var(--success);
    background: #d5f5e3;
}

.equip-name {
    font-size: 0.875rem;
    font-weight: 500;
    margin: 6px 0 2px;
}

.equip-pn {
    font-size: 0.75rem;
    color: var(--gray-600);
}

.equip-qty {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.equip-qty button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--gray-300);
    background: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.equip-qty button:active { background: var(--gray-100); }

.equip-qty span {
    font-size: 0.875rem;
    font-weight: 600;
    min-width: 40px;
}

/* ==================== 准备状态 ==================== */
.prepare-status {
    margin-top: 16px;
    padding: 16px;
    text-align: center;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
}

.prepare-status.complete {
    background: #d5f5e3;
    color: #1e8449;
    border: 2px solid #27ae60;
}

.prepare-status.incomplete {
    background: var(--gray-50);
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

/* ==================== 打印预览 ==================== */
.print-preview {
    background: #fff;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 16px;
    min-height: 80px;
    font-family: monospace;
    font-size: 0.875rem;
    line-height: 1.8;
    white-space: pre-wrap;
}

.print-controls {
    padding: 16px;
    display: flex;
    gap: 8px;
}

/* ==================== 蓝牙状态 ==================== */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.813rem;
    font-weight: 500;
}

.status-badge.connected {
    background: #d5f5e3;
    color: #1e8449;
}

.status-badge.disconnected {
    background: #fadbd8;
    color: #c0392b;
}

/* ==================== 记录列表 ==================== */
.record-item {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
    border-left: 3px solid var(--primary);
    font-size: 0.875rem;
}

.record-item .record-time {
    color: var(--gray-600);
    font-size: 0.75rem;
}

/* ==================== 弹窗 ==================== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-content {
    background: #fff;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 20px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--gray-600);
}

.modal-footer {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: #fff;
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 0.875rem;
    z-index: 2000;
    animation: fadeInOut 2.5s ease;
}

@keyframes fadeInOut {
    0% { opacity: 0; top: 10px; }
    15% { opacity: 1; top: 20px; }
    85% { opacity: 1; top: 20px; }
    100% { opacity: 0; top: 10px; }
}

/* ==================== 设置项 ==================== */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}

.setting-row label {
    font-size: 0.875rem;
    font-weight: 500;
}

.setting-row input {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.875rem;
}

/* ==================== 器材选择区 ==================== */
.equip-select-area {
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin: 12px 0;
}

.selected-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.selected-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #d6eaf8;
    border-radius: 16px;
    font-size: 0.813rem;
}

.selected-tag .remove {
    cursor: pointer;
    color: var(--danger);
    font-weight: 700;
}

/* ==================== PC 端适配 ==================== */
@media (min-width: 768px) {
    .main-nav {
        padding: 40px 24px;
    }

    .nav-title {
        font-size: 1.5rem;
    }

    .nav-grid {
        max-width: 600px;
        gap: 24px;
    }

    .nav-card {
        padding: 28px 16px;
    }

    .nav-icon { font-size: 2.5rem; }
    .nav-label { font-size: 1rem; }

    .page-header { padding: 16px 24px; }
    .search-section { padding: 16px 24px; }

    .card {
        margin: 16px 24px;
        padding: 20px;
    }

    .modal-content {
        border-radius: 16px;
        margin: auto;
        max-width: 600px;
    }

    .modal {
        align-items: center;
    }

    .data-list, .equip-grid {
        padding: 16px 24px;
    }
}

@media (min-width: 1024px) {
    .nav-grid {
        max-width: 800px;
        grid-template-columns: repeat(3, 1fr);
        gap: 32px;
    }
}

/* ==================== 华为设备适配 ==================== */
@supports (-webkit-touch-callout: none) {
    .main-nav { min-height: -webkit-fill-available; }
}

/* ==================== 暗黑模式支持 ==================== */
@media (prefers-color-scheme: dark) {
    :root {
        --gray-50: #1a1a2e;
        --gray-100: #2d2d44;
        --gray-200: #3d3d5c;
        --gray-600: #a0a0b8;
        --gray-800: #e8e8f0;
    }

    body { background: #0f0f23; color: #e8e8f0; }
    .card { background: #1a1a2e; border-color: #2d2d44; }
    .data-item { background: #1a1a2e; }
    .form-input, .form-select, .search-input {
        background: #2d2d44;
        border-color: #3d3d5c;
        color: #e8e8f0;
    }
}

/* ==================== 打印样式 ==================== */
@media print {
    .main-nav, .page-header, .search-section, .btn, .tab-bar { display: none !important; }
    .page { display: block !important; }
    body { background: #fff; }
}

.hint {
    font-size: 0.813rem;
    color: var(--gray-600);
    margin-bottom: 8px;
}

/* ==================== 胶膜借出打印预览 ==================== */
.film-label-preview {
    border: 2px solid #333;
    padding: 12px;
    margin: 12px 0;
    font-family: monospace;
    font-size: 0.875rem;
    background: #fff;
}

/* ==================== 已借出列表 ==================== */
.return-item {
    background: #fff;
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
    border-left: 3px solid var(--warning);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.return-item .return-info {
    flex: 1;
}

.return-item .return-btn {
    margin-left: 12px;
}

/* ==================== 设置页面 ==================== */
.setting-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 16px;
    margin: 12px 16px;
    box-shadow: var(--shadow);
}

.setting-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--gray-800);
    border-bottom: 1px solid var(--gray-100);
    padding-bottom: 8px;
}

/* ==================== 加载动画 ==================== */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--gray-600);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-600);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.875rem;
}
