:root {
    --primary-color: #0073aa;
    --secondary-color: #f1f1f1;
    --text-color: #333;
    --border-color: #ddd;
    --font-family: 'Arial', sans-serif;
}

body {
    font-family: 'Arial', sans-serif; /* fallback */
    font-size: 14px;
    color: var(--text-color);
    background: #eaecf0;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

h1, h2, h3, h4, p {
    margin: 0 0 10px 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

.layout-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Form Panel */
.form-panel {
    flex: 1;
    min-width: 400px;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    height: fit-content;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: inherit;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-col {
    flex: 1;
}

.btn {
    display: inline-block;
    padding: 10px 15px;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.btn:hover { background: #005a87; }
.btn-danger { background: #dc3232; }
.btn-danger:hover { background: #a02121; }
.btn-success { background: #46b450; }
.btn-success:hover { background: #358b3d; }

.section-title {
    background: #f8f9fa;
    padding: 10px;
    border-left: 4px solid #0073aa;
    margin-top: 20px;
    margin-bottom: 15px;
    font-size: 16px;
}

/* Dynamic Line Items Form */
.item-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
    background: #fafafa;
    padding: 10px;
    border: 1px solid #eee;
}

/* Preview Panel */
.preview-panel {
    flex: 1.5;
    min-width: 600px;
}

.invoice-preview-container {
    background: #fff;
    width: 100%;
    min-height: 800px;
    padding: 40px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    font-family: var(--font-family);
}

/* Watermarks */
.watermark-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.1;
    z-index: 0;
    pointer-events: none;
    max-width: 60%;
    max-height: 60%;
}
.watermark-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 80px;
    color: #000;
    opacity: 0.05;
    z-index: 0;
    pointer-events: none;
    white-space: nowrap;
}

/* Invoice Content Container (above watermark) */
.invoice-content {
    position: relative;
    z-index: 1;
}

/* --- Template 1: Modern Digital --- */
.template-modern .inv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 20px;
    margin-bottom: 30px;
}
.template-modern .inv-logo { max-height: 80px; }
.template-modern .inv-title {
    font-size: 36px;
    color: var(--primary-color);
    text-transform: uppercase;
}
.template-modern .inv-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
}
.template-modern .inv-bill-to {
    background: var(--secondary-color);
    padding: 15px;
    border-left: 4px solid var(--primary-color);
    width: 45%;
}
.template-modern .inv-details {
    width: 45%;
    text-align: right;
}
.template-modern .inv-table th {
    background-color: var(--primary-color);
    color: #fff;
    padding: 12px;
    text-align: left;
}
.template-modern .inv-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}
.template-modern .inv-totals {
    width: 40%;
    float: right;
    margin-top: 20px;
}
.template-modern .inv-totals table td {
    padding: 8px;
    border-bottom: 1px solid #eee;
}
.template-modern .inv-totals table tr:last-child td {
    font-weight: bold;
    font-size: 18px;
    color: var(--primary-color);
    border-bottom: none;
    border-top: 2px solid var(--primary-color);
}

/* --- Template 2: Traditional Store --- */
.template-traditional {
    border: 1px solid #000;
    padding: 30px;
}
.template-traditional .inv-header {
    text-align: center;
    border-bottom: 2px dashed #000;
    padding-bottom: 10px;
    margin-bottom: 20px;
}
.template-traditional .inv-logo { max-height: 100px; display: block; margin: 0 auto 10px; }
.template-traditional .inv-title {
    font-size: 28px;
    font-weight: bold;
    letter-spacing: 2px;
}
.template-traditional .inv-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}
.template-traditional .inv-bill-to, .template-traditional .inv-details {
    width: 48%;
    border: 1px solid #000;
    padding: 10px;
}
.template-traditional .inv-table {
    border: 1px solid #000;
    margin-bottom: 20px;
}
.template-traditional .inv-table th, .template-traditional .inv-table td {
    border: 1px solid #000;
    padding: 8px;
}
.template-traditional .inv-table th {
    background-color: #f0f0f0;
}
.template-traditional .inv-totals {
    width: 50%;
    float: right;
}
.template-traditional .inv-totals table th, .template-traditional .inv-totals table td {
    border: 1px solid #000;
    padding: 5px 8px;
}
.template-traditional .inv-totals table tr:last-child td {
    font-weight: bold;
    font-size: 16px;
    background-color: #f0f0f0;
}

/* Helper Classes */
.clear { clear: both; }
.text-right { text-align: right; }
.amount-in-words-box {
    margin-top: 30px;
    padding: 15px;
    background: #fdfdfd;
    border: 1px dashed #ccc;
    font-style: italic;
    color: #555;
}

@media print {
    .form-panel, .no-print { display: none !important; }
    body { background: #fff; padding: 0; }
    .layout-wrapper { display: block; }
    .preview-panel { width: 100%; margin: 0; padding: 0; }
    .invoice-preview-container { box-shadow: none; padding: 0; }
}
