/* Preview Layout */
.preview-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 0;
    background: var(--bg-color);
    height: 100%;
    position: relative;
}

.preview-content-wrapper {
    flex: 1;
    overflow: auto;
    padding: 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--bg-secondary);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.preview-content-wrapper::-webkit-scrollbar {
    width: 6px;
}

.preview-content-wrapper::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.preview-content-wrapper::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 3px;
}

.biodata-preview {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    width: 210mm; /* A4 width */
    min-height: 297mm; /* A4 height */
    position: relative;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.preview-content {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 2rem;
    flex: 1;
    position: relative;
    z-index: 1;
}

/* Preview Content */
.preview-content {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 2rem;
    padding: 1rem;
    background: white;
    min-height: calc(100vh - 180px); /* Account for header and buttons */
    position: relative;
}

.details-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.detail-group {
    margin-bottom: 1rem;
}

.detail-label {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    color: var(--text-color);
    line-height: 1.6;
}

/* Photo Section */
.photo-section {
    text-align: center;
}

.photo-container {
    width: 100%;
    max-width: 300px;
    aspect-ratio: 3/4;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin: 0 auto 1.5rem;
    box-shadow: var(--shadow-md);
}

.photo-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Form Section */
.form-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 0;
    padding: 0;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s ease;
    background: white;
}

.form-control:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(234, 93, 0, 0.1);
}

/* Download Buttons */
.download-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--border-color);
}

.download-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 1rem;
    text-align: center;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.download-pdf {
    background: var(--primary-color);
    color: white;
}

.download-png {
    background: var(--secondary-color);
    color: white;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.download-btn:active {
    transform: translateY(0);
}

/* Watermark */
.watermark {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    font-family: var(--font-primary);
    font-size: 0.75rem;
    color: var(--text-lighter);
    opacity: 0.7;
    pointer-events: none;
}

/* Mobile Responsive */
@media (max-width: 1200px) {
    .preview-section {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .preview-content {
        grid-template-columns: 1fr;
    }

    .photo-section {
        order: -1;
        margin-bottom: 2rem;
    }

    .photo-container {
        max-width: 200px;
    }
}

@media (max-width: 768px) {
    .preview-section {
        padding: 0.5rem;
    }

    .biodata-preview {
        padding: 1rem;
        border-radius: var(--radius-md);
        margin-bottom: 120px; /* Space for fixed download buttons */
    }

    .form-section {
        padding: 1rem;
        margin: 0.5rem;
        border-radius: var(--radius-md);
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .download-buttons {
        flex-direction: column;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 0;
    }

    .download-btn {
        width: 100%;
        margin: 0;
    }

    /* Fix iOS bottom safe area */
    @supports (padding: max(0px)) {
        .download-buttons {
            padding-bottom: max(1rem, env(safe-area-inset-bottom));
        }
    }
}

/* Print Styles */
@media print {
    .preview-section {
        display: block;
        padding: 0;
    }

    .biodata-preview {
        box-shadow: none;
        margin: 0;
        padding: 0;
    }

    .download-buttons {
        display: none;
    }

    .watermark {
        opacity: 0.5;
    }
}
