/* ============================================
   族乐家智能家居方案报价系统 - 主样式表
   深蓝科幻风格 | 响应式 | A4打印
   ============================================ */

:root {
    --bg-primary: #060b18;
    --bg-secondary: #0d1525;
    --bg-card: #111b2e;
    --bg-card-hover: #152036;
    --bg-input: #0a1020;
    --border-primary: #1a3050;
    --border-glow: #2a5080;
    --border-accent: #3b82f6;
    --accent: #3b82f6;
    --accent-light: #60a5fa;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-orange: #f59e0b;
    --accent-purple: #8b5cf6;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #60a5fa;
    --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.08);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.25s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at 10% 20%, rgba(59,130,246,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 80%, rgba(6,182,212,0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(139,92,246,0.03) 0%, transparent 60%);
}

a { color: var(--accent-light); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-cyan); }

img { max-width: 100%; height: auto; }

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-primary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-glow); }

/* ========== Layout ========== */
.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.app-header .logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-header .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), var(--accent-cyan));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    box-shadow: 0 0 20px rgba(59,130,246,0.3);
}

.app-header .logo-text {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-light), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* ========== Cards ========== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-glow), transparent);
    opacity: 0.5;
}

.card:hover { border-color: var(--border-glow); box-shadow: var(--shadow-glow), var(--shadow-card); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(30,58,95,0.5);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(6,182,212,0.2));
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #2563eb);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 2px 12px rgba(59,130,246,0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(59,130,246,0.4); }

.btn-cyan {
    background: linear-gradient(135deg, var(--accent-cyan), #0891b2);
    color: #fff;
}
.btn-cyan:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(6,182,212,0.4); }

.btn-success {
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: #fff;
}
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(16,185,129,0.4); }

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red), #dc2626);
    color: #fff;
}
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(239,68,68,0.4); }

.btn-outline {
    background: transparent;
    border-color: var(--border-primary);
    color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent-light); background: rgba(59,130,246,0.05); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }

/* ========== Form Elements ========== */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.form-input::placeholder { color: var(--text-muted); }

.form-textarea { min-height: 80px; resize: vertical; }

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

.form-inline {
    display: flex;
    gap: 10px;
    align-items: center;
}
.form-inline .form-input, .form-inline .form-select { flex: 1; }

/* ========== Tables ========== */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-primary);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead { background: var(--bg-secondary); }

th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-primary);
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(26,48,80,0.4);
    color: var(--text-primary);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(59,130,246,0.03); }

.table-num { text-align: right; font-variant-numeric: tabular-nums; font-family: 'SF Mono', 'Consolas', monospace; }

/* ========== Badges / Tags ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-blue { background: rgba(59,130,246,0.15); color: var(--accent-light); }
.badge-green { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.badge-cyan { background: rgba(6,182,212,0.15); color: var(--accent-cyan); }
.badge-purple { background: rgba(139,92,246,0.15); color: var(--accent-purple); }

/* ========== Product Search Dropdown ========== */
.search-container { position: relative; }

.search-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    z-index: 200;
    max-height: 320px;
    overflow-y: auto;
    margin-top: 4px;
}

.search-dropdown.active { display: block; }

.search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(26,48,80,0.3);
    transition: var(--transition);
}

.search-item:last-child { border-bottom: none; }
.search-item:hover { background: rgba(59,130,246,0.08); }

.search-item-img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.search-item-info { flex: 1; min-width: 0; }
.search-item-name { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.search-item-code { font-size: 12px; color: var(--text-muted); }
.search-item-price { font-size: 14px; font-weight: 600; color: var(--accent-cyan); }

.search-no-result {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

/* ========== Area Block ========== */
.area-block {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    overflow: hidden;
}

.area-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: rgba(59,130,246,0.05);
    border-bottom: 1px solid var(--border-primary);
    cursor: pointer;
}

.area-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.area-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(6,182,212,0.2));
}

.area-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.area-subtotal {
    font-size: 14px;
    color: var(--accent-cyan);
    font-weight: 600;
}

.area-body { padding: 16px 20px; }

.area-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ========== Item Row ========== */
.item-row {
    display: grid;
    grid-template-columns: 200px 50px 100px 100px 80px 120px 60px;
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(26,48,80,0.3);
    font-size: 13px;
}

.item-row:last-child { border-bottom: none; }
.item-row-header {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 0;
}

.item-img-preview {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    background: var(--bg-input);
}

.item-delete-btn {
    width: 30px;
    height: 30px;
    border: 1px solid rgba(239,68,68,0.3);
    background: transparent;
    border-radius: 4px;
    color: var(--accent-red);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition);
}
.item-delete-btn:hover { background: rgba(239,68,68,0.15); }

/* ========== Summary Section ========== */
.summary-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 20px;
    position: relative;
    overflow: hidden;
}

.summary-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-cyan), var(--accent-purple));
}

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

.summary-item {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.summary-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.summary-value { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.summary-value.highlight { color: var(--accent-cyan); }
.summary-value.total {
    font-size: 28px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* ========== Print Page (A4) ========== */
.print-page {
    max-width: 210mm;
    margin: 0 auto;
    background: #fff;
    color: #1a1a1a;
    padding: 15mm 12mm;
}

.print-page * { color: #1a1a1a !important; }

.print-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid #0d47a1;
}

.print-header h1 {
    font-size: 22px;
    color: #0d47a1 !important;
    margin-bottom: 4px;
    letter-spacing: 2px;
}

.print-header .subtitle {
    font-size: 13px;
    color: #666 !important;
}

.print-info-table {
    width: 100%;
    margin-bottom: 20px;
    border-collapse: collapse;
}

.print-info-table td {
    padding: 5px 10px;
    font-size: 13px;
    border: 1px solid #ddd;
}

.print-info-table .label {
    background: #f0f4ff;
    font-weight: 600;
    width: 100px;
    color: #0d47a1 !important;
}

.print-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 12px;
}

.print-table th {
    background: #0d47a1;
    color: #fff !important;
    padding: 8px 6px;
    font-weight: 600;
    text-align: center;
}

.print-table td {
    padding: 6px;
    border: 1px solid #ccc;
    text-align: center;
}

.print-table .text-left { text-align: left; }
.print-table .text-right { text-align: right; }

.print-area-title {
    background: #e8edf5;
    padding: 6px 10px;
    font-weight: 700;
    font-size: 13px;
    color: #0d47a1 !important;
    margin: 12px 0 4px;
}

.print-summary {
    margin-top: 16px;
    text-align: right;
}

.print-summary-row {
    display: flex;
    justify-content: flex-end;
    padding: 4px 0;
    font-size: 13px;
}

.print-summary-row .label { width: 100px; color: #666 !important; }
.print-summary-row .value { width: 120px; text-align: right; font-weight: 600; }
.print-summary-row.total {
    font-size: 16px;
    font-weight: 700;
    border-top: 2px solid #0d47a1;
    padding-top: 8px;
    margin-top: 8px;
}
.print-summary-row.total .value { color: #0d47a1 !important; }

.print-footer {
    margin-top: 30px;
    padding-top: 16px;
    border-top: 1px solid #ccc;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}

.print-footer > div { text-align: center; }
.print-footer .print-line { border-bottom: 1px solid #333; width: 120px; margin-top: 30px; }
.print-footer .print-label { color: #666 !important; margin-top: 4px; }

/* ========== Toast / Notification ========== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: #fff;
    animation: toastIn 0.3s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    max-width: 360px;
}

.toast-success { background: linear-gradient(135deg, #059669, #10b981); }
.toast-error { background: linear-gradient(135deg, #dc2626, #ef4444); }
.toast-info { background: linear-gradient(135deg, #2563eb, #3b82f6); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========== Modal ========== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-lg);
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 { font-size: 18px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* ========== Loading ========== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-primary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========== Utilities ========== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-cyan); }
.text-danger { color: var(--accent-red); }
.fw-bold { font-weight: 600; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .item-row {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 14px 0;
    }
    .item-row .form-input,
    .item-row .form-select {
        width: 100%;
    }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .app-header { padding: 0 16px; }
    .app-header .logo-text { font-size: 15px; }
    .app-container { padding: 16px; }

    .card { padding: 16px; }
    .card-header { flex-direction: column; align-items: flex-start; gap: 12px; }

    .form-row { grid-template-columns: 1fr; }
    .summary-grid { grid-template-columns: 1fr; }
    .summary-controls { grid-template-columns: 1fr; }

    .area-body { padding: 12px; }
    .area-header { padding: 10px 14px; }

    .btn { padding: 8px 16px; font-size: 13px; }
    .btn-lg { padding: 12px 20px; }

    .item-row-header { display: none; }

    .search-dropdown { max-height: 240px; }
}

@media (max-width: 480px) {
    html { font-size: 14px; }
    .app-header { height: 56px; }
    .app-header .logo-icon { width: 28px; height: 28px; font-size: 14px; }
    .summary-value { font-size: 16px; }
    .summary-value.total { font-size: 22px; }
}

/* ========== Print Styles ========== */
@media print {
    body { background: #fff !important; }
    .app-header, .btn, .no-print, .toast-container, .modal-overlay,
    .search-dropdown, .area-footer .btn-outline { display: none !important; }

    .app-container {
        max-width: 100%;
        padding: 0;
    }

    .card, .area-block, .summary-section {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 8px 0;
    }

    .card::before, .summary-section::before { display: none !important; }

    @page {
        size: A4;
        margin: 12mm;
    }
}

/* ========== Product Image Hover in List ========== */
.prod-img-cell {
    width: 60px;
    text-align: center;
}
.prod-img-cell img {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
}

/* ========== Drag Hint ========== */
.area-block.drag-over {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(6,182,212,0.2);
}

/* ========== Step Indicator ========== */
.steps {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
}

.step {
    flex: 1;
    text-align: center;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-muted);
    font-size: 13px;
    position: relative;
}

.step:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.step:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.step.active {
    background: rgba(59,130,246,0.1);
    border-color: var(--accent);
    color: var(--accent-light);
}
.step.done {
    background: rgba(16,185,129,0.1);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.step-num {
    display: inline-block;
    width: 22px;
    height: 22px;
    line-height: 22px;
    border-radius: 50%;
    background: var(--border-primary);
    margin-right: 6px;
    font-size: 12px;
}
.step.active .step-num { background: var(--accent); color: #fff; }
.step.done .step-num { background: var(--accent-green); color: #fff; }
