/* ========================================
   电池检测报价查询 - 样式表
   ======================================== */

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #e8f0fe;
    --accent: #ea4335;
    --success: #0f9d58;
    --text: #202124;
    --text-secondary: #5f6368;
    --text-tertiary: #9aa0a6;
    --bg: #f8f9fa;
    --card-bg: #ffffff;
    --border: #e0e0e0;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
    --safe-bottom: env(safe-area-inset-bottom, 16px);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    line-height: 1.6;
}

#app {
    max-width: 100%;
    margin: 0 auto;
    min-height: 100vh;
    padding-bottom: var(--safe-bottom);
}

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, var(--primary), #4285f4);
    color: white;
    padding: 12px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.header h1 {
    font-size: 20px;
    font-weight: 700;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.header-btn {
    padding: 6px 14px;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 20px;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.header-btn:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.7);
}

.header-btn:active {
    transform: scale(0.95);
}

.export-btn {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
    font-weight: 600;
}

/* ===== Search ===== */
.search-section {
    padding: 12px 16px 8px;
    position: sticky;
    top: 56px;
    z-index: 99;
    background: var(--bg);
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border-radius: 24px;
    padding: 2px 6px;
    box-shadow: var(--shadow-lg);
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.search-box:focus-within {
    border-color: var(--primary);
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 10px 12px;
    background: transparent;
    color: var(--text);
    min-width: 0;
}

.search-input::placeholder {
    color: var(--text-tertiary);
    font-size: 14px;
}

.clear-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: #e0e0e0;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    flex-shrink: 0;
}

.search-hints {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.hint-tag {
    background: var(--primary-light);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.hint-tag:active {
    background: var(--primary);
    color: white;
    transform: scale(0.95);
}

/* ===== Suggestions ===== */
.suggestions {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    margin-top: 8px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.suggestion-item:last-child { border-bottom: none; }

.suggestion-item:active { background: var(--primary-light); }

.suggestion-code {
    font-weight: 700;
    color: var(--primary);
    font-size: 14px;
    min-width: 70px;
}

.suggestion-name {
    font-size: 13px;
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestion-cat {
    font-size: 11px;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 10px;
    color: var(--text-secondary);
}

/* ===== Result Section - 线性排版 ===== */
.result-section {
    padding: 16px;
    animation: fadeIn 0.3s ease;
    max-width: 600px;
    margin: 0 auto;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-line {
    padding: 8px 0;
    font-size: 15px;
    line-height: 1.7;
    border-bottom: 1px solid #f0f0f0;
    color: var(--text);
}

.result-line:last-child {
    border-bottom: none;
}

.name-line {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
    padding: 4px 0 12px;
    border-bottom: 2px solid var(--primary-light);
    margin-bottom: 8px;
}

.result-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.result-value {
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

/* ===== 可编辑价格区域 ===== */
.edit-price-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
    box-shadow: var(--shadow);
    border: 1px solid #f0f0f0;
}

.edit-price-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.edit-price-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.edit-price-item label {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}

.price-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    background: var(--card-bg);
    outline: none;
    transition: border-color 0.2s;
}

.price-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.price-input::placeholder {
    color: var(--text-tertiary);
    font-size: 13px;
}

/* 保存按钮 */
.save-area {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.save-btn {
    padding: 10px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.save-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(26,115,232,0.3);
}

.save-btn:active {
    transform: scale(0.97);
}

.save-btn:disabled {
    background: #a0c4f1;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.save-msg {
    font-size: 14px;
    font-weight: 500;
}

.save-msg.success {
    color: var(--success);
}

.save-msg.error {
    color: var(--accent);
}

/* Excel路径提示 */
.excel-path-info {
    width: 100%;
    margin-top: 8px;
    padding: 10px 14px;
    background: #e8f5e9;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #2e7d32;
    animation: fadeIn 0.3s ease;
}

.excel-path-info code {
    background: #c8e6c9;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 12px;
    word-break: break-all;
}

/* ===== Empty State / 首页 ===== */
.empty-state {
    padding: 0;
}

/* ===== Sheet 标签栏 ===== */
.sheet-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom: 2px solid #f0f0f0;
    background: var(--card-bg);
    scroll-behavior: smooth;
}

.sheet-tabs::-webkit-scrollbar {
    height: 3px;
}

.sheet-tabs::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.sheet-tab {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.sheet-tab:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary-light);
}

.sheet-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 600;
}

.sheet-tab small {
    font-size: 11px;
    opacity: 0.7;
    font-weight: 400;
}

.sheet-tabs-loading,
.sheet-tabs-error {
    padding: 12px 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

.sheet-tabs-error {
    color: var(--accent);
    line-height: 1.6;
}

.sheet-tabs-error small {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.8;
}

/* ===== 表格 ===== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    background: var(--card-bg);
    max-height: 70vh;
    overflow-y: auto;
}

.excel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 700px;
}

.excel-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.excel-table th {
    background: #f1f5f9;
    color: #334155;
    font-weight: 600;
    padding: 8px 6px;
    border-bottom: 2px solid #cbd5e1;
    text-align: center;
    white-space: nowrap;
    font-size: 12px;
    line-height: 1.4;
}

.excel-table th small {
    display: block;
    font-weight: 400;
    color: #64748b;
    font-size: 11px;
}

.excel-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text);
    vertical-align: top;
    line-height: 1.5;
    max-width: 200px;
    word-break: break-word;
}

.excel-table tbody tr:hover {
    background: #f8fafc;
}

.excel-table tbody tr:last-child td {
    border-bottom: none;
}

/* 价格列高亮 */
.price-cell {
    font-weight: 700;
    color: #d97706;
    background: #fffbeb;
    text-align: right;
    white-space: nowrap;
}

/* 威凯报价列 */
.weikai-cell {
    font-size: 12px;
    color: #1e40af;
    background: #eff6ff;
    max-width: 250px;
}

.table-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.table-loading .spinner {
    margin-bottom: 16px;
}

.table-info {
    padding: 8px 20px;
    font-size: 12px;
    color: var(--text-tertiary);
    border-top: 1px solid #f0f0f0;
    background: var(--card-bg);
}

.table-error {
    padding: 16px;
    text-align: center;
    color: var(--accent);
    font-size: 14px;
    background: #fef2f2;
    border-radius: var(--radius-sm);
}

/* ===== Not Found ===== */
.not-found {
    padding: 60px 24px;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.not-found p {
    font-size: 16px;
    color: var(--text-secondary);
}

.not-found-hint {
    font-size: 13px;
    margin-top: 8px;
    color: var(--text-tertiary);
}

/* ===== Loading ===== */
.loading {
    padding: 40px;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 0.8s linear infinite;
}

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

.loading p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ===== 登录模态框 ===== */
.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.login-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    animation: fadeIn 0.2s ease;
}

.login-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease;
}

.login-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.login-header h3 {
    font-size: 18px;
    color: var(--text);
}

.login-body {
    padding: 20px;
}

.login-field {
    margin-bottom: 16px;
}

.login-field label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.login-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.login-error {
    padding: 8px 12px;
    background: #fef2f2;
    color: var(--accent);
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}

.login-submit {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.login-submit:hover {
    background: var(--primary-dark);
}

.close-modal-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f0f0f0;
    color: #666;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-modal-btn:hover {
    background: #e0e0e0;
    color: #333;
}

/* 导出提示 Toast */
.export-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.export-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== Responsive ===== */
@media (max-width: 380px) {
    .header h1 { font-size: 16px; }
    .header-btn { font-size: 12px; padding: 5px 10px; }
    .result-section { padding: 12px; }
    .name-line { font-size: 15px; }
    .result-line { font-size: 14px; }
    .edit-price-row { gap: 8px; }
    .excel-table { font-size: 11px; }
    .excel-table th, .excel-table td { padding: 4px; }
    .sheet-tab { font-size: 12px; padding: 6px 12px; }
}
