/* 供客报价管理系统 - 响应式样式 */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --bg: #f1f5f9;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #3b82f6;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --radius: 8px;
    --sidebar-width: 240px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e40af 100%);
    padding: 20px;
}

.login-container { width: 100%; max-width: 420px; }

.login-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 22px; color: var(--text); margin-bottom: 8px; }
.login-header p { color: var(--text-muted); font-size: 13px; }

.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text); }
.login-form input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
}
.login-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }

.captcha-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 10px;
    align-items: center;
    width: 100%;
}
.login-form .captcha-input {
    flex: 1;
    min-width: 0;
    width: auto;
}
.captcha-img {
    flex-shrink: 0;
    width: 120px;
    height: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    object-fit: contain;
    background: #f8fafc;
}
.login-hint { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 16px; }

.permissions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 12px; }
.permission-module { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: #f8fafc; }
.permission-module-title { font-weight: 600; margin-bottom: 8px; font-size: 13px; }
.permission-actions { display: flex; flex-direction: column; gap: 6px; }

/* ===== Layout ===== */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h2 { font-size: 16px; color: #fff; font-weight: 600; }
.sidebar-close { display: none; background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; }

.sidebar-nav {
    flex: 1;
    min-height: 0;
    padding: 12px 6px 12px 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
    margin: 6px 0;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 999px;
    border: 1px solid transparent;
    background-clip: padding-box;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(203, 213, 225, 0.55);
    background-clip: padding-box;
}
.sidebar-nav:hover {
    scrollbar-color: rgba(148, 163, 184, 0.55) transparent;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 11px 20px;
    color: var(--sidebar-text);
    transition: all 0.2s;
    text-decoration: none;
    font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(59,130,246,0.2); color: #fff; border-right: 3px solid var(--sidebar-active); }
.nav-icon { margin-right: 10px; font-size: 16px; width: 22px; text-align: center; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info { font-size: 13px; margin-bottom: 8px; color: #94a3b8; }
.logout-btn {
    display: block;
    text-align: center;
    padding: 8px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-radius: var(--radius);
    font-size: 13px;
    text-decoration: none;
}
.logout-btn:hover { background: rgba(255,255,255,0.2); text-decoration: none; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    background: var(--card-bg);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
    font-size: 18px;
    cursor: pointer;
    color: var(--text);
}

.page-title { font-size: 18px; font-weight: 600; flex: 1; }
.current-user { font-size: 13px; color: var(--text-muted); }

.content-area { padding: 24px; flex: 1; }
.page-footer { padding: 12px 24px; text-align: center; color: var(--text-muted); font-size: 12px; border-top: 1px solid var(--border); background: var(--card-bg); }

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* ===== Dashboard ===== */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.stat-card-highlight {
    border-left: 3px solid var(--primary);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fef2f2; color: #991b1b; }
.badge-muted { background: #f1f5f9; color: #64748b; }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.checkbox-label input { width: auto; }

.attachment-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.attachment-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.attachment-thumb img { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; }
.attachment-icon { font-size: 28px; width: 48px; text-align: center; }
.attachment-info { flex: 1; min-width: 0; }
.attachment-info a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-size { font-size: 12px; color: var(--text-muted); }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px 24px;
}
.detail-item { display: flex; flex-direction: column; gap: 4px; }
.detail-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.detail-value { font-size: 15px; font-weight: 500; }
.detail-remark {
    margin-top: 20px;
    padding: 12px;
    background: #f8fafc;
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* ===== Forms ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.form-group { display: flex; flex-direction: column; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { margin-bottom: 6px; font-weight: 500; font-size: 13px; color: var(--text); }

.form-group input,
.form-group select,
.form-group textarea,
.form-control {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-control-sm { max-width: 80px; }
.readonly, input.readonly { background: #f8fafc; color: var(--text-muted); cursor: default; }

.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }

.inline-form { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-edit-form { display: flex; gap: 8px; align-items: center; }

.search-form { display: flex; gap: 8px; }
.search-form .form-control { width: 200px; }

.filter-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-form .form-control { width: auto; min-width: 120px; }

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

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; color: #fff; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-block { width: 100%; }

/* ===== Tables ===== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    background: #f8fafc;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tbody tr:hover { background: #f8fafc; }

.actions { white-space: nowrap; }
.actions .btn, .actions form { display: inline-flex; margin-right: 4px; }

.memo-content { max-width: 400px; word-break: break-word; }
.memo-quote-projects { font-size: 12px; margin-top: 4px; line-height: 1.4; }

/* ===== Quote Form ===== */
.quote-items-table .form-control { padding: 6px 8px; font-size: 13px; min-width: 0; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.summary-item label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; }
.summary-value { font-size: 20px; font-weight: 700; color: var(--primary); }
.summary-value.negative { color: var(--danger); }
.summary-value.positive { color: var(--success); }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.tab-item {
    padding: 10px 24px;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    text-decoration: none;
}
.tab-item:hover { color: var(--primary); text-decoration: none; }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.show { display: flex; }

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-lg { max-width: 640px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 16px 20px 20px; }

/* 采购商品选择 */
.purchase-picker-search { margin-bottom: 12px; }
.purchase-picker-list {
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.35) transparent;
}
.purchase-picker-list::-webkit-scrollbar { width: 6px; }
.purchase-picker-list::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.3);
    border-radius: 999px;
}
.purchase-picker-table { margin: 0; }
.purchase-picker-table td, .purchase-picker-table th { font-size: 13px; }
.quote-empty-hint td { padding: 28px 16px !important; background: #f8fafc; }
.product-sourced .form-control.readonly { background: #f1f5f9; cursor: default; }
.unit-display { display: inline-block; padding: 8px 0; font-size: 14px; color: var(--text); }

/* ===== Utilities ===== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }
.text-warning { color: #d97706; font-weight: 600; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .sidebar-overlay.show { display: block; }

    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }

    .content-area { padding: 16px; }
    .top-bar { padding: 10px 16px; }
    .current-user { display: none; }

    .form-grid { grid-template-columns: 1fr; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .summary-grid { grid-template-columns: 1fr 1fr; }

    .card-header { flex-direction: column; align-items: flex-start; }
    .header-actions { width: 100%; }
    .search-form { width: 100%; }
    .search-form .form-control { flex: 1; width: auto; }

    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 8px 6px; }

    .login-card { padding: 28px 20px; }
}

@media (max-width: 480px) {
    .stat-cards { grid-template-columns: 1fr; }
    .summary-grid { grid-template-columns: 1fr; }
    .tabs { overflow-x: auto; }
    .tab-item { padding: 8px 16px; white-space: nowrap; }
}
