:root {
    --primary-color: #4a90e2;
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --text-color: #333;
    --bg-light: #f4f6f8;
    --border-color: #ddd;
}

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

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-color);
    background-color: #fff;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100%;
}

/* Left Panel */
.left-panel {
    width: 40%;
    min-width: 350px;
    background-color: #fff;
    padding: 40px 60px; /* Increased padding to move content away from edge */
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
    z-index: 10;
}

.left-panel h1 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #2c3e50;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row .form-group {
    flex: 1;
}

label {
    font-weight: 600;
    font-size: 14px;
    color: #555;
}

input[type="text"],
input[type="number"],
textarea,
select {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.image-preview-box {
    width: 100px;
    height: 100px;
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    overflow: hidden;
    margin-top: 5px;
    background-color: #fafafa;
}

.image-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
}
.primary-btn:hover { background-color: #357abd; }

.secondary-btn {
    background-color: #f39c12;
    color: white;
}
.secondary-btn:hover { background-color: #d68910; }

.success-btn {
    background-color: var(--success-color);
    color: white;
}
.success-btn:hover { background-color: #27ae60; }

.text-btn {
    background: transparent;
    color: #777;
    text-decoration: underline;
}

hr {
    border: 0;
    border-top: 1px solid #eee;
    margin: 10px 0;
}

/* Product List in Left Panel */
.product-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 6px;
    background-color: #fafafa;
}

.list-item img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    background-color: #ddd;
}

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

.list-item-title {
    font-weight: bold;
    font-size: 14px;
}

.list-item-desc {
    font-size: 12px;
    color: #666;
}

.list-actions {
    display: flex;
    gap: 5px;
}

.action-btn {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
}
.edit-btn { background-color: #e0e0e0; color: #333; }
.del-btn { background-color: #ffe0e0; color: var(--danger-color); }

/* Right Panel */
.right-panel {
    flex: 1;
    background-color: #eef2f5;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
}

.preview-header-actions {
    width: 100%;
    max-width: 450px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.order-preview {
    width: 100%;
    max-width: 450px;
    background: white;
    min-height: 600px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    padding: 30px;
    border-radius: 2px; /* Paper feel */
    display: flex;
    flex-direction: column;
    flex-shrink: 0; /* Prevent shrinking when content overflows viewport */
    height: auto;
}

.order-header {
    text-align: center;
    border-bottom: 2px solid #333;
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.order-header h2 {
    font-size: 24px;
    margin-bottom: 15px;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #666;
}

.header-row .customer {
    text-align: start;
    font-weight: 500;
    visibility: hidden; /* Default hidden until input */
}

.header-row .date {
    text-align: end;
}

.order-items {
    flex: 1;
}

.preview-item {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    border-bottom: 1px dashed #eee;
    padding-bottom: 15px;
}

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

.preview-img {
    width: 160px;
    height: 160px;
    border-radius: 4px;
    background-color: #f0f0f0;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.preview-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.preview-title {
    font-weight: bold;
    font-size: 16px;
    color: #000;
}

.preview-note {
    font-size: 13px;
    color: #777;
    margin-top: 2px;
    font-style: italic;
    white-space: pre-wrap;
    word-break: break-word;
}

.preview-price-row {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 14px;
}

.preview-price-row .price {
    color: #333;
}

.preview-price-row .subtotal {
    font-weight: bold;
    color: #e74c3c;
}

.empty-state {
    text-align: center;
    color: #ccc;
    margin-top: 50px;
    font-size: 16px;
}

.order-footer {
    border-top: 2px solid #333;
    padding-top: 20px;
    margin-top: auto;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
    color: #555;
}

#discountAmount {
     color: #333;
     font-weight: 500;
 }
 
 .original-price-value {
     position: relative;
     color: #999;
     margin-left: 2px;
 }
 
 .original-price-value::after {
     content: "";
     position: absolute;
     left: -45px; /* 延伸到货币符号 */
     right: 0;
     top: 50%;
     height: 1px;
     background-color: #999;
     transform: translateY(-50%);
 }
 
 .subtotal-currency-code,
 .subtotal-currency-symbol {
     color: #999;
 }
 
 .main-total {
    font-size: 20px;
    font-weight: bold;
    color: #000;
    margin-top: 10px;
}

.total-price-group {
    display: flex;
    align-items: baseline;
    gap: 5px; /* Gap between Code (USD) and Symbol ($) */
}

.final-amount {
    display: flex;
    align-items: baseline;
    gap: 0; /* Symbol ($) and Amount (0.00) tight */
}

.main-total .currency {
    font-size: inherit; /* Match parent font size */
    margin-right: 0;
}

/* Responsive adjustments */
@media (max-width: 800px) {
    .container {
        flex-direction: column;
        overflow-y: auto;
    }
    .left-panel, .right-panel {
        width: 100%;
        overflow: visible;
        padding: 20px;
        min-width: 0;
    }
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    .right-panel {
        height: auto;
    }
}
