
/* Professional Document Templates - Modern Design System with PDF Optimization */

/* Template Base Styles - Optimized for PDF */
.document-template {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 32px;
    background: white;
    color: #111827;
    line-height: 1.4;
    font-size: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    position: relative;
}

/* Print & PDF Styles - Optimized */
@media print {
    .document-template {
        box-shadow: none;
        border-radius: 0;
        padding: 40px;
        margin: 0;
        max-width: none;
        font-size: 10px;
        line-height: 1.3;
    }
}

/* Company Logo Container - Smaller for PDF */
.company-logo-container {
    width: 100px;
    height: 50px;
    overflow: hidden;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f9fafb;
    margin-bottom: 12px;
    border: 1px solid #e5e7eb;
}

.company-logo {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
}

/* Typography Hierarchy - Reduced sizes */
.document-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 16px;
    letter-spacing: -0.025em;
}

.section-heading {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
    margin-top: 24px;
}

.sub-heading {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    margin-top: 12px;
}

.body-text {
    font-size: 12px;
    margin-bottom: 8px;
    line-height: 1.4;
}

/* Header Layouts - Optimized spacing */
.template-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    padding-bottom: 16px;
}

.company-info {
    flex: 1;
    margin-right: 24px;
}

.company-name {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 6px;
    line-height: 1.2;
}

.company-details {
    font-size: 12px;
    line-height: 1.4;
    color: #6b7280;
}

.document-info {
    text-align: right;
    min-width: 180px;
}

.document-number {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
}

.document-meta {
    font-size: 12px;
    line-height: 1.4;
    color: #6b7280;
}

/* Client Information - Reduced spacing */
.client-section {
    margin: 24px 0;
}

.client-info {
    background: #f9fafb;
    padding: 16px;
    border-radius: 6px;
    border-left: 4px solid var(--accent-color, #3b82f6);
}

.client-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin-bottom: 6px;
}

.client-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 3px;
    color: #111827;
}

.client-details {
    font-size: 12px;
    line-height: 1.4;
    color: #6b7280;
}

/* Payment Method Section */
.payment-section {
    margin: 24px 0;
}

.payment-info {
    background: #f0f9ff;
    padding: 16px;
    border-radius: 6px;
    border-left: 4px solid var(--accent-color, #3b82f6);
}

.payment-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin-bottom: 6px;
}

.payment-method {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 3px;
    color: #111827;
}

.payment-details {
    font-size: 12px;
    line-height: 1.4;
    color: #6b7280;
}

/* Items Table - Optimized for PDF */
.items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 12px;
}

.items-table th {
    background: #f9fafb;
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    border-bottom: 2px solid var(--accent-color, #3b82f6);
}

.items-table td {
    padding: 8px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}

.items-table tr:hover {
    background: #f9fafb;
}

.item-description {
    font-weight: 500;
    color: #111827;
}

.item-quantity,
.item-rate,
.item-amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.item-amount {
    font-weight: 600;
}

/* Totals Section - Compact */
.totals-section {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
}

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

.totals-table td {
    padding: 6px 10px;
    font-size: 12px;
    vertical-align: middle;
}

.totals-table .total-label {
    text-align: right;
    font-weight: 500;
    color: #6b7280;
}

.totals-table .total-amount {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    width: 100px;
}

.totals-table .final-total {
    border-top: 2px solid var(--accent-color, #3b82f6);
    background: #f9fafb;
}

.totals-table .final-total .total-label {
    font-weight: 700;
    color: #111827;
    font-size: 14px;
}

.totals-table .final-total .total-amount {
    font-weight: 800;
    color: var(--accent-color, #3b82f6);
    font-size: 16px;
}

/* Notes Section - Compact */
.notes-section {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.notes-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #111827;
}

.notes-content {
    font-size: 12px;
    line-height: 1.5;
    color: #6b7280;
    white-space: pre-line;
}

/* Template Variations */

/* Classic Template */
.template-classic {
    --accent-color: #1f2937;
    border-top: 4px solid var(--accent-color);
}

.template-classic .document-title {
    color: var(--accent-color);
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 8px;
}

.template-classic .template-header {
    border-bottom: 1px solid #e5e7eb;
}

.template-classic .company-name {
    color: var(--accent-color);
}

/* Modern Template */
.template-modern {
    --accent-color: #3b82f6;
    position: relative;
}

.template-modern::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-color), #1e40af);
    border-radius: 8px 8px 0 0;
}

.template-modern .document-title {
    color: var(--accent-color);
    position: relative;
}

.template-modern .document-title::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 50px;
    height: 2px;
    background: var(--accent-color);
    border-radius: 2px;
}

.template-modern .items-table th {
    background: var(--accent-color);
    color: white;
    border-bottom: none;
}

.template-modern .company-name {
    color: var(--accent-color);
}

/* Minimal Template */
.template-minimal {
    --accent-color: #6b7280;
    border: 1px solid #e5e7eb;
    padding: 48px;
}

.template-minimal .document-title {
    color: #111827;
    font-weight: 300;
    font-size: 28px;
    text-align: center;
    margin-bottom: 32px;
}

.template-minimal .template-header {
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 48px;
}

.template-minimal .items-table th {
    background: none;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 500;
}

.template-minimal .items-table td {
    border-bottom: 1px solid #f3f4f6;
}

.template-minimal .client-info,
.template-minimal .payment-info {
    background: none;
    border: 1px solid #e5e7eb;
    border-left: 4px solid var(--accent-color);
}

/* Corporate Template */
.template-corporate {
    --accent-color: #059669;
    background: linear-gradient(to bottom, #f9fafb 0%, #ffffff 150px);
}

.template-corporate .template-header {
    background: var(--accent-color);
    color: white;
    padding: 24px;
    margin: -32px -32px 32px -32px;
    border-radius: 8px 8px 0 0;
}

.template-corporate .company-name {
    color: white;
    font-size: 22px;
}

.template-corporate .company-details {
    color: rgba(255, 255, 255, 0.9);
}

.template-corporate .document-info {
    color: white;
}

.template-corporate .document-title {
    color: white;
    margin-bottom: 0;
}

.template-corporate .items-table th {
    background: var(--accent-color);
    color: white;
    border-bottom: none;
}

/* Creative Template */
.template-creative {
    --accent-color: #8b5cf6;
    position: relative;
    overflow: hidden;
}

.template-creative::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent 40%, rgba(139, 92, 246, 0.05) 50%, transparent 60%);
    pointer-events: none;
}

.template-creative .document-title {
    background: linear-gradient(45deg, var(--accent-color), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 900;
    font-size: 28px;
    text-align: center;
    margin-bottom: 24px;
}

.template-creative .template-header {
    border: none;
    position: relative;
    z-index: 1;
}

.template-creative .company-name {
    color: var(--accent-color);
    font-weight: 700;
}

.template-creative .items-table th {
    background: linear-gradient(45deg, var(--accent-color), #7c3aed);
    color: white;
    border-bottom: none;
}

.template-creative .client-info,
.template-creative .payment-info {
    background: linear-gradient(45deg, rgba(139, 92, 246, 0.1), rgba(124, 58, 237, 0.05));
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-left: 4px solid var(--accent-color);
}

.template-creative .totals-section {
    position: relative;
    z-index: 1;
}

/* Color Variations */
.color-blue { --accent-color: #3b82f6; }
.color-green { --accent-color: #10b981; }
.color-purple { --accent-color: #8b5cf6; }
.color-red { --accent-color: #ef4444; }
.color-orange { --accent-color: #f59e0b; }
.color-indigo { --accent-color: #6366f1; }

/* PDF Specific Optimizations */
@media print {
    .document-template {
        padding: 20px;
    }
    
    .template-header {
        margin-bottom: 20px;
        padding-bottom: 10px;
    }
    
    .client-section,
    .payment-section {
        margin: 16px 0;
    }
    
    .client-info,
    .payment-info {
        padding: 12px;
    }
    
    .items-table {
        margin: 16px 0;
        font-size: 10px;
    }
    
    .items-table th,
    .items-table td {
        padding: 6px 4px;
    }
    
    .totals-section {
        margin-top: 16px;
    }
    
    .totals-table td {
        padding: 4px 8px;
        font-size: 10px;
    }
    
    .notes-section {
        margin-top: 20px;
        padding-top: 12px;
    }
    
    .document-title {
        font-size: 20px;
        margin-bottom: 12px;
    }
    
    .company-name {
        font-size: 16px;
    }
    
    .template-creative::before {
        display: none;
    }
    
    .template-modern::before {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    
    .items-table th {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    
    .template-corporate .template-header {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
        margin: -20px -20px 20px -20px;
        padding: 16px;
    }
}

/* Responsive Template Design */
@media (max-width: 768px) {
    .document-template {
        padding: 20px;
        font-size: 11px;
    }
    
    .template-header {
        flex-direction: column;
        gap: 20px;
    }
    
    .company-info {
        margin-right: 0;
    }
    
    .document-info {
        text-align: left;
    }
    
    .document-title {
        font-size: 20px;
        text-align: center;
    }
    
    .items-table {
        font-size: 11px;
    }
    
    .items-table th,
    .items-table td {
        padding: 6px 4px;
    }
    
    .totals-section {
        justify-content: center;
    }
    
    .totals-table {
        min-width: 200px;
    }
    
    /* Stack table on very small screens */
    @media (max-width: 480px) {
        .items-table,
        .items-table thead,
        .items-table tbody,
        .items-table th,
        .items-table td,
        .items-table tr {
            display: block;
        }
        
        .items-table thead tr {
            position: absolute;
            top: -9999px;
            left: -9999px;
        }
        
        .items-table tr {
            border: 1px solid #ccc;
            margin-bottom: 6px;
            padding: 6px;
            border-radius: 4px;
        }
        
        .items-table td {
            border: none;
            position: relative;
            padding-left: 50% !important;
            padding-top: 6px;
            padding-bottom: 6px;
        }
        
        .items-table td::before {
            content: attr(data-label) ": ";
            position: absolute;
            left: 6px;
            width: 45%;
            padding-right: 8px;
            white-space: nowrap;
            font-weight: 600;
            color: #111827;
        }
        
        .template-corporate .template-header {
            margin: -20px -20px 20px -20px;
            padding: 20px;
        }
    }
}

/* Accessibility Improvements */
.items-table th {
    scope: col;
}

.totals-table .total-label {
    scope: row;
}

/* Focus styles for interactive elements */
.document-template:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 4px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .document-template {
        border: 2px solid #000000;
    }
    
    .items-table th {
        border: 2px solid #000000;
    }
    
    .items-table td {
        border-bottom: 1px solid #000000;
    }
}
