/* ============================================
   春联库存管理系统 - 样式表
   ============================================ */

:root {
    --primary: #c41e3a;
    --primary-dark: #a01830;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --white: #ffffff;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #adb5bd;
    --gray-700: #495057;
    --gray-800: #343a40;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    --radius: 10px;
    --radius-sm: 6px;
}

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

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: #f0f2f5;
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.5;
}

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

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 16px 24px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.header-main {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.sync-status {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.3s;
}

.status-success {
    background: var(--success);
    color: white;
}

.status-error {
    background: var(--danger);
    color: white;
}

.status-warning {
    background: var(--warning);
    color: var(--gray-800);
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tab-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    border: none;
    background: var(--white);
    color: var(--gray-700);
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.tab-btn:hover {
    background: var(--gray-100);
}

.tab-btn.active {
    background: var(--primary);
    color: var(--white);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Panel */
.panel {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

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

.panel-header h2 {
    font-size: 1.1rem;
    color: var(--gray-700);
}

.stats {
    display: flex;
    gap: 20px;
    font-size: 0.95rem;
    color: var(--gray-700);
}

.stats strong {
    color: var(--primary);
}

/* Mode Switch */
.mode-switch {
    display: flex;
    gap: 6px;
}

.mode-btn {
    background: var(--gray-200) !important;
    color: var(--gray-700) !important;
}

.mode-btn.active {
    background: var(--primary) !important;
    color: var(--white) !important;
}

/* Form */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    min-width: 100px;
    flex: 1;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.form-group input,
.form-group select {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(196, 30, 58, 0.15);
}

.form-group input[readonly] {
    background: var(--gray-100);
    color: var(--gray-500);
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

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

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

.btn-secondary:hover {
    background: var(--gray-300);
}

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

.btn-success:hover {
    background: #218838;
}

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

.btn-danger:hover {
    background: #c82333;
}

.btn-small {
    padding: 4px 10px;
    font-size: 0.8rem;
}

/* Table */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.85rem;
    white-space: nowrap;
}

tbody tr:hover {
    background: #fafafa;
}

.stock-low {
    color: var(--danger);
    font-weight: 600;
}

.action-btns {
    display: flex;
    gap: 4px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--gray-500);
    display: none;
}

.empty-state span {
    font-size: 3rem;
    display: block;
    margin-bottom: 8px;
}

/* Sale Grid */
.sale-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.sale-card {
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.sale-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.sale-card-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.sale-card-spec {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.sale-card-content {
    font-size: 0.75rem;
    color: var(--gray-600);
    margin-bottom: 8px;
    line-height: 1.3;
    max-height: 36px;
    overflow: hidden;
}

/* 春联内容主显示（放上面加粗） */
.sale-card-content-main {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 6px;
    line-height: 1.3;
}

/* 春联品名（放下面小字） */
.sale-card-category {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-bottom: 6px;
}

.sale-card-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.sale-card-stock {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.cart-qty-hint {
    background: var(--primary);
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: 6px;
    font-weight: 800;
    display: inline-block;
    vertical-align: middle;
}

/* 库存颜色等级 */
.sale-card-stock.stock-danger {
    color: #fff;
    background: #dc3545;
}

.sale-card-stock.stock-low {
    color: #856404;
    background: #fff3cd;
}

.sale-card-stock.stock-medium {
    color: #155724;
    background: #d4edda;
}

.sale-card-stock.stock-high {
    color: var(--gray-600);
    background: var(--gray-100);
}

.sale-card.out-of-stock {
    opacity: 0.4;
    pointer-events: none;
}

.sale-card.out-of-stock::after {
    content: '缺货';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--danger);
    color: var(--white);
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
}

/* Customer Info Row */
.customer-info-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
}

.customer-info-row .form-group {
    min-width: 150px;
    flex: 1;
}

/* Order Info */
.order-info {
    display: flex;
    gap: 30px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gray-800);
}

.order-info strong {
    color: var(--primary);
    font-size: 1.7rem;
    font-weight: 800;
}

/* Cart */
.cart-list {
    min-height: 100px;
}

.empty-cart {
    text-align: center;
    color: var(--gray-500);
    padding: 30px;
}

.cart-table {
    width: 100%;
    font-size: 1.1rem;
}

.cart-table th {
    background: transparent;
    border-bottom: 2px solid var(--gray-200);
    font-weight: 700;
}

.cart-table td {
    padding: 12px 8px;
    font-weight: 600;
}

.cart-table td:first-child {
    font-size: 1rem;
    font-weight: 700;
}

.cart-table td:nth-child(4) {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.qty-btn-sm {
    width: 24px;
    height: 24px;
    border: 1px solid var(--gray-300);
    background: var(--white);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin: 0 4px;
}

.qty-btn-sm:hover {
    background: var(--gray-100);
}

/* Orders List */
.orders-list {
    max-height: 600px;
    overflow-y: auto;
}

/* Stats Panel */
.stats-panel .panel-header {
    flex-wrap: wrap;
}

.stats-quick-btns {
    display: flex;
    gap: 6px;
}

.stats-quick-btns .btn {
    background: var(--gray-200);
    color: var(--gray-700);
}

.stats-quick-btns .btn:hover {
    background: var(--primary);
    color: var(--white);
}

.stats-filter-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.stats-filter-row .form-group {
    min-width: 140px;
    flex: 0;
}

.stats-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.stat-card {
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
}

.stat-card-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
}

.stat-card-primary .stat-label {
    color: rgba(255, 255, 255, 0.8);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.stat-card-profit {
    background: #e6fffa;
    border: 1px solid #38b2ac;
}

.stat-card-profit .stat-value {
    color: #2c7a7b;
}

/* Individual Order Profit Info */
.order-profit-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.75rem;
    color: var(--gray-500);
    margin: 0 10px;
    line-height: 1.2;
}

.order-profit-sm {
    color: #2c7a7b;
    font-weight: 700;
}

.order-cost-sm {
    color: var(--gray-400);
}

.order-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 12px;
    background: var(--white);
}

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

.order-no {
    font-weight: 700;
    color: var(--gray-800);
}

.order-time {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.order-time-big {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800);
}

.order-card {
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.order-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.cart-category {
    color: var(--gray-500);
    font-size: 0.75rem;
}

.order-total {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.order-discount {
    font-size: 0.85rem;
    color: var(--success);
    font-weight: 600;
}

.order-actions {
    display: flex;
    gap: 4px;
}

.order-customer {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.order-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.order-item {
    background: var(--gray-100);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--gray-700);
}

.order-items-readonly {
    background: var(--gray-100);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.order-items-readonly .order-item {
    display: inline-block;
    margin: 4px;
}

.order-items-total {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
    font-weight: 600;
    color: var(--gray-700);
}

.discount-price {
    color: var(--success) !important;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
}

.modal-small {
    max-width: 360px;
}

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

.modal-header h3 {
    font-size: 1.2rem;
}

.close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-200);
    color: var(--gray-700);
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: var(--danger);
    color: var(--white);
}

.modal .form-group {
    margin-bottom: 12px;
}

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

/* Sale Modal */
.sale-product-info {
    background: var(--gray-100);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.sale-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #fff5f5;
    border-radius: var(--radius-sm);
    margin-top: 12px;
}

.sale-amount {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
}

/* Quantity Control */
.quantity-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.qty-btn {
    width: 36px;
    height: 36px;
    border: 2px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-700);
    font-size: 1.3rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.quantity-control input {
    width: 60px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 6px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-sm);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: var(--white);
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 500;
    z-index: 2000;
    animation: toastIn 0.3s ease;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translate(-50%, 10px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 0 10px;
    }

    .header {
        flex-direction: column;
        gap: 12px;
        padding: 15px;
        text-align: center;
    }

    .header-left {
        flex-direction: column;
        gap: 8px;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .stats-filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .stats-quick-btns {
        justify-content: space-between;
    }

    .stats-results {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 12px 8px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .sale-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }

    .sale-card {
        padding: 10px;
    }

    .cart-table-wrapper {
        overflow-x: auto;
    }

    .order-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .order-total {
        align-self: flex-end;
    }

    .modal-content {
        width: 95%;
        padding: 15px;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 8px;
    }

    .btn {
        padding: 8px 16px;
    }
}

@media (max-width: 480px) {
    .stats-results {
        grid-template-columns: repeat(2, 1fr);
    }

    .header h1 {
        font-size: 1.4rem;
    }
}