/**
 * Invoice/Estimate Generator Styles
 */

.generator-section {
    padding: 40px 0;
}

.generator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: start;
}

/* Form Panel */
.generator-form {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.form-section {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Document Type Toggle */
.doc-type-toggle {
    display: flex;
    background: var(--bg-gray);
    border-radius: var(--radius-md);
    padding: 4px;
}

.doc-type-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.doc-type-btn.active {
    background: var(--bg-white);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.doc-type-btn:hover:not(.active) {
    color: var(--text-primary);
}

/* Logo Upload */
.logo-upload {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.logo-preview {
    width: 120px;
    height: 80px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    background: var(--bg-light);
}

.logo-preview:hover {
    border-color: var(--primary-color);
    background: var(--bg-white);
}

.logo-preview span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Line Items */
.line-items-container {
    margin-bottom: 16px;
}

.line-item {
    background: var(--bg-light);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
}

.line-item-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto auto;
    gap: 12px;
    align-items: end;
}

.line-item-row .form-group {
    margin-bottom: 0;
}

.line-item-desc {
    grid-column: 1;
}

.line-item-qty,
.line-item-rate {
    width: 100px;
}

.line-item-amount {
    width: 100px;
    text-align: right;
    font-weight: 600;
    padding: 12px 0;
    color: var(--text-primary);
}

.line-item-remove {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    padding: 8px;
    font-size: 1.25rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.line-item-remove:hover {
    opacity: 1;
}

/* Form Actions */
.form-actions {
    padding: 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--bg-light);
    border-top: 1px solid var(--border-color);
}

/* Preview Panel */
.generator-preview {
    position: sticky;
    top: calc(var(--header-height) + 20px);
}

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

.preview-header h3 {
    margin: 0;
    font-size: 1rem;
}

.preview-container {
    background: var(--bg-gray);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.preview-document {
    background: white;
    box-shadow: var(--shadow-lg);
    border-radius: 4px;
    padding: 40px;
    min-height: 800px;
    font-size: 12px;
    line-height: 1.5;
}

/* Preview Document Styles */
.preview-header-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--primary-color);
}

.preview-logo {
    max-width: 150px;
    max-height: 80px;
}

.preview-business {
    text-align: left;
}

.preview-business h2 {
    font-size: 18px;
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.preview-business p {
    margin: 0;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: pre-line;
}

.preview-doc-info {
    text-align: right;
}

.preview-doc-type {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0 0 12px 0;
    text-transform: uppercase;
}

.preview-doc-details {
    font-size: 11px;
    color: var(--text-secondary);
}

.preview-doc-details strong {
    color: var(--text-primary);
}

/* Addresses */
.preview-addresses {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

.preview-address h4 {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
    letter-spacing: 0.5px;
}

.preview-address p {
    margin: 0;
    font-size: 12px;
    white-space: pre-line;
}

/* Line Items Table */
.preview-table {
    width: 100%;
    margin-bottom: 24px;
    border-collapse: collapse;
}

.preview-table th {
    background: var(--bg-light);
    padding: 10px 12px;
    text-align: left;
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.preview-table th:last-child,
.preview-table td:last-child {
    text-align: right;
}

.preview-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
}

/* Totals */
.preview-totals {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 32px;
}

.preview-totals-table {
    width: 250px;
}

.preview-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 12px;
}

.preview-totals-row.subtotal {
    border-bottom: 1px solid var(--border-color);
}

.preview-totals-row.total {
    font-size: 16px;
    font-weight: 700;
    border-top: 2px solid var(--text-primary);
    padding-top: 12px;
    margin-top: 4px;
}

/* Notes & Terms */
.preview-notes {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.preview-notes h4 {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
}

.preview-notes p {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
    white-space: pre-line;
}

/* Responsive */
@media (max-width: 1200px) {
    .generator-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    
    .generator-preview {
        position: static;
        order: -1;
    }
    
    .preview-document {
        min-height: auto;
    }
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .line-item-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .line-item-qty,
    .line-item-rate {
        width: 100%;
    }
    
    .line-item-amount {
        width: 100%;
        text-align: left;
        padding: 8px 0 0 0;
    }
    
    .preview-document {
        padding: 24px;
        overflow-x: auto;
    }

    .preview-container {
        padding: 12px;
    }
    
    .preview-header-section {
        flex-direction: column;
        gap: 16px;
    }
    
    .preview-doc-info {
        text-align: left;
    }
    
    .preview-addresses {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* Print Styles for PDF */
@media print {
    .preview-document {
        box-shadow: none;
        padding: 0;
    }
}
