/**
 * Report Template Preview Styles
 * Accurate A4 page dimensions and print-friendly styling
 */

/* A4 Page Dimensions at 96 DPI (screen)
 * 210mm × 297mm = 794px × 1123px at 96 DPI
 * Using slightly smaller for better screen fit: 750px × 1060px
 */

.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.preview-container {
    background: #525659;
    border-radius: 0.5rem;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

.preview-header {
    background: #fff;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    border-radius: 0.5rem 0.5rem 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

.preview-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: #525659;
}

.preview-pages {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
}

/* A4 Page */
.preview-page {
    width: 750px;
    min-height: 1060px;
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    padding: 40px 50px;
    box-sizing: border-box;
    position: relative;
}

.preview-page-label {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 10px;
    color: #9ca3af;
    font-weight: 500;
}

/* Zone Layouts within Pages */
.preview-zone {
    margin-bottom: 1.5rem;
    min-height: 40px;
}

.preview-zone:empty::after {
    content: '';
    display: block;
    height: 0;
}

/* Header zones (side by side) */
.preview-header-zones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 1.5rem;
    max-height: 95px; /* 2.5cm */
    overflow: hidden;
}

.preview-header-zones .preview-zone {
    max-height: 95px; /* 2.5cm */
    overflow: hidden;
    display: flex;
    align-items: center;
}

.preview-header-zones .preview-zone:first-child {
    justify-content: flex-start;
}

.preview-header-zones .preview-zone:last-child {
    justify-content: flex-end;
}

/* Footer zones (side by side) */
.preview-footer-zones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid #e5e7eb;
    margin-top: 1.5rem;
    max-height: 95px; /* 2.5cm */
    overflow: hidden;
}

.preview-footer-zones .preview-zone {
    max-height: 95px; /* 2.5cm */
    overflow: hidden;
    display: flex;
    align-items: center;
}

/* Detail zones (2x2 grid) */
.preview-detail-zones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

/* Headlines (side by side) */
.preview-headline-zones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

/* Element Styling */
.preview-element {
    margin-bottom: 1rem;
}

.preview-element:last-child {
    margin-bottom: 0;
}

/* Heading Elements */
.preview-heading {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.5rem;
}

.preview-heading.size-large {
    font-size: 2rem;
}

.preview-heading.size-medium {
    font-size: 1.5rem;
}

.preview-heading.size-small {
    font-size: 1.125rem;
}

/* Text Block Elements */
.preview-text-block {
    font-size: 0.875rem;
    line-height: 1.6;
    color: #374151;
    white-space: pre-wrap;
}

/* Image Elements */
.preview-image {
    max-width: 100%;
    height: auto;
    border-radius: 0.25rem;
}

.preview-image-wrapper {
    text-align: center;
}

/* Images in header/footer zones must fit height constraint */
.preview-header-zones .preview-image,
.preview-footer-zones .preview-image {
    max-height: 85px; /* Slightly less than zone height for padding */
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

/* Divider Elements */
.preview-divider {
    border: 0;
    border-top: 2px solid #e5e7eb;
    margin: 1.5rem 0;
}

.preview-divider.style-dashed {
    border-top-style: dashed;
}

.preview-divider.style-dotted {
    border-top-style: dotted;
}

/* Input Element Placeholders */
.preview-input {
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.75rem;
    background: #f9fafb;
    min-height: 2.5rem;
}

.preview-input-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    display: block;
}

.preview-input-intro {
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
    font-style: italic;
}

.preview-input-placeholder {
    color: #9ca3af;
    font-size: 0.875rem;
}

.preview-input.required .preview-input-label::after {
    content: '*';
    color: #ef4444;
    margin-left: 0.25rem;
}

/* Evaluation Input */
.preview-evaluation {
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 1rem;
    background: #f9fafb;
}

.preview-evaluation-scale {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    justify-content: space-between;
}

.preview-evaluation-item {
    width: 2.5rem;
    height: 2.5rem;
    border: 2px solid #d1d5db;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #6b7280;
    font-size: 0.875rem;
}

.preview-evaluation-item.positive {
    border-color: #10b981;
    background: #d1fae5;
    color: #065f46;
}

.preview-evaluation-item.neutral {
    border-color: #eab308;
    background: #fef3c7;
    color: #854d0e;
}

.preview-evaluation-item.negative {
    border-color: #ef4444;
    background: #fee2e2;
    color: #991b1b;
}

/* Statistics Input */
.preview-statistics {
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 1rem;
    background: #f9fafb;
    text-align: center;
}

.preview-statistics-placeholder {
    color: #9ca3af;
    font-size: 0.75rem;
}

/* Image-Text Input */
.preview-image-text {
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 1rem;
    background: #f9fafb;
}

.preview-image-text-image {
    width: 100%;
    height: 150px;
    background: #e5e7eb;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.preview-image-text-desc {
    min-height: 60px;
    border: 1px dashed #d1d5db;
    border-radius: 0.25rem;
    padding: 0.5rem;
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .preview-modal {
        position: static;
        background: white;
        padding: 0;
    }
    
    .preview-container {
        max-width: 100%;
        max-height: 100%;
        box-shadow: none;
    }
    
    .preview-header,
    .preview-actions {
        display: none;
    }
    
    .preview-body {
        padding: 0;
        background: white;
    }
    
    .preview-pages {
        gap: 0;
    }
    
    .preview-page {
        width: 210mm;
        min-height: 297mm;
        box-shadow: none;
        page-break-after: always;
        padding: 15mm 20mm;
    }
    
    .preview-page:last-child {
        page-break-after: auto;
    }
    
    .preview-page-label {
        display: none;
    }
}

/* Responsive */
@media (max-width: 900px) {
    .preview-page {
        width: 600px;
        min-height: 848px;
        padding: 30px 40px;
    }
}

@media (max-width: 700px) {
    .preview-page {
        width: 100%;
        min-height: auto;
        padding: 20px;
    }
    
    .preview-header-zones,
    .preview-footer-zones,
    .preview-detail-zones,
    .preview-headline-zones {
        grid-template-columns: 1fr;
    }
}
