/**
 * PDF Export Overlay Styles
 *
 * @package Utleiekalk_FINN
 * @since 2.5.0
 */

/* ───── Overlay Container ───── */
.pdf-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
}

.pdf-overlay.active {
    display: flex;
    justify-content: flex-end;
}

.pdf-overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: pdfFadeIn 0.2s ease;
}

.pdf-overlay-content {
    position: relative;
    width: 600px;
    max-width: 100%;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
    animation: pdfSlideIn 0.3s ease;
}

/* ───── Header ───── */
.pdf-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--uk-border, #E6E8EC);
    background: #fff;
    flex-shrink: 0;
}

.pdf-overlay-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: #111827;
}

.pdf-overlay-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pdf-overlay-close {
    background: transparent !important;
    border: none;
    font-size: 28px;
    color: #6b7280 !important;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    line-height: 1;
}

.pdf-overlay-close:hover {
    background: #f3f4f6 !important;
    color: #111827 !important;
}

/* ───── Body (scrollable) ───── */
.pdf-overlay-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    overscroll-behavior: contain;
}

/* ───── Footer ───── */
.pdf-overlay-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--uk-border, #E6E8EC);
    background: #f9fafb;
    flex-shrink: 0;
}

/* ───── Generate PDF Button ───── */
.pdf-overlay-generate {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.pdf-overlay-generate svg {
    flex-shrink: 0;
}

/* ───── Sections ───── */
.pdf-section {
    border: 1px solid var(--uk-border, #E6E8EC);
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.pdf-section:hover {
    border-color: #d1d5db;
}

.pdf-section.disabled {
    opacity: 0.5;
}

.pdf-section.disabled .pdf-section-content {
    display: none;
}

.pdf-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f9fafb;
    cursor: pointer;
    user-select: none;
}

.pdf-section-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.pdf-section-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--uk-primary, #09B87D);
    cursor: pointer;
    flex-shrink: 0;
}

.pdf-section-title {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    outline: none;
    border-radius: 4px;
    padding: 2px 4px;
    transition: background 0.2s ease;
}

.pdf-section-title:focus {
    background: #e0f2fe;
}

.pdf-section-collapse {
    background: transparent !important;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #6b7280;
    display: flex;
    align-items: center;
    transition: transform 0.2s ease;
}

.pdf-section.collapsed .pdf-section-collapse {
    transform: rotate(-90deg);
}

.pdf-section.collapsed .pdf-section-content {
    display: none;
}

.pdf-section-content {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--uk-border, #E6E8EC);
}

.pdf-section-hint {
    font-size: 13px;
    color: var(--uk-muted, #6b7280);
    margin: 0 0 10px;
}

/* ───── Textarea Toolbar ───── */
.pdf-textarea-wrapper {
    position: relative;
}

.pdf-textarea-toolbar {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}

.pdf-textarea-toolbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    border: 1px solid var(--uk-border-input, #e2e8f0);
    border-radius: 6px;
    background: #f9fafb;
    cursor: pointer;
    color: #555;
    font-size: 14px;
    transition: all 0.15s ease;
    padding: 0;
}

.pdf-textarea-toolbar button:hover {
    background: var(--uk-primary, #09B87D);
    color: #fff;
    border-color: var(--uk-primary, #09B87D);
}

.pdf-textarea-toolbar button svg {
    width: 16px;
    height: 16px;
}

/* ───── Textareas ───── */
.pdf-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--uk-border-input, #e2e8f0);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    min-height: 60px;
}

.pdf-textarea:focus {
    outline: none;
    border-color: var(--uk-primary, #09B87D);
    box-shadow: 0 0 0 3px rgba(9, 184, 125, 0.1);
}

.pdf-textarea::placeholder {
    color: #9ca3af;
}

/* ───── Rich Text Editor (contenteditable) ───── */
.pdf-richtext-editor {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--uk-border-input, #e2e8f0);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    box-sizing: border-box;
    min-height: 60px;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    overflow-y: auto;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.pdf-richtext-editor:focus {
    outline: none;
    border-color: var(--uk-primary, #09B87D);
    box-shadow: 0 0 0 3px rgba(9, 184, 125, 0.1);
}

.pdf-richtext-editor:empty::before {
    content: attr(data-placeholder);
    color: #9ca3af;
    pointer-events: none;
}

.pdf-richtext-editor ul {
    margin: 4px 0;
    padding-left: 22px;
    list-style-type: disc;
}

.pdf-richtext-editor ul li {
    margin-bottom: 2px;
}

.pdf-richtext-editor b,
.pdf-richtext-editor strong {
    font-weight: 700;
}

.pdf-richtext-source {
    display: none !important;
}

/* ───── Nøkkeltall Scenario Picker ───── */
.pdf-nokkeltall-scenario-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.pdf-nokkeltall-scenario-picker label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.pdf-nokkeltall-scenario-picker select {
    flex: 1;
    max-width: 250px;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #374151;
    background: #fff;
}

/* ───── Nøkkeltall Checklist ───── */
.pdf-nokkeltall-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.pdf-nokkeltall-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 13px;
    color: #374151;
    transition: background 0.15s ease;
}

.pdf-nokkeltall-item:hover {
    background: #f3f4f6;
}

.pdf-nokkeltall-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--uk-primary, #09B87D);
    cursor: pointer;
    flex-shrink: 0;
}

.pdf-nokkeltall-item label {
    cursor: pointer;
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}

.pdf-nokkeltall-value {
    font-weight: 600;
    color: var(--uk-primary, #09B87D);
    margin-left: 4px;
    white-space: nowrap;
}

/* ───── Comparable Properties ───── */
.pdf-comparable-input {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.pdf-comparable-input .uk-input {
    flex: 1;
}

.pdf-comparable-input .uk-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

.pdf-comparable-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pdf-comparable-entry {
    display: flex;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--uk-border, #E6E8EC);
    border-radius: 8px;
    background: #fafbfc;
    align-items: flex-start;
}

.pdf-comparable-thumb {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: #e5e7eb;
}

.pdf-comparable-info {
    flex: 1;
    min-width: 0;
}

.pdf-comparable-address {
    font-weight: 600;
    font-size: 14px;
    color: #111827;
    margin-bottom: 4px;
}

.pdf-comparable-details {
    font-size: 13px;
    color: var(--uk-muted, #6b7280);
    line-height: 1.4;
}

.pdf-comparable-details span {
    margin-right: 12px;
}

.pdf-comparable-desc {
    width: 100%;
    margin-top: 8px;
    min-height: 40px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

.pdf-comparable-remove {
    background: transparent !important;
    border: none;
    color: #ef4444 !important;
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.pdf-comparable-url {
    margin-top: 4px;
}

.pdf-comparable-url a {
    font-size: 12px;
    color: var(--uk-primary, #09B87D);
    word-break: break-all;
    text-decoration: none;
}

.pdf-comparable-url a:hover {
    text-decoration: underline;
}

.pdf-comparable-remove:hover {
    color: #dc2626 !important;
}

/* ───── Scenario Checklist (flipping) ───── */
.pdf-scenario-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pdf-scenario-group {
    border: 1px solid var(--uk-border, #E6E8EC);
    border-radius: 8px;
    padding: 12px;
}

.pdf-scenario-group-title {
    font-weight: 700;
    font-size: 14px;
    color: #111827;
    margin-bottom: 8px;
}

.pdf-scenario-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.pdf-scenario-field {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #374151;
    padding: 4px 6px;
    border-radius: 4px;
}

.pdf-scenario-field:hover {
    background: #f3f4f6;
}

.pdf-scenario-field input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--uk-primary, #09B87D);
    cursor: pointer;
}

.pdf-scenario-field label {
    cursor: pointer;
}

/* ───── Image Upload ───── */
.pdf-image-upload {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.pdf-image-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f3f4f6;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    transition: all 0.2s ease;
}

.pdf-image-upload-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.pdf-image-hint {
    font-size: 12px;
    color: var(--uk-muted, #6b7280);
}

.pdf-image-retention-notice {
    font-size: 12px;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 8px 12px;
    margin: 8px 0 12px;
    line-height: 1.4;
}

.pdf-image-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.pdf-image-entry {
    border: 1px solid var(--uk-border, #E6E8EC);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.pdf-image-preview {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.pdf-image-desc {
    padding: 8px;
}

.pdf-image-desc input,
.pdf-image-desc textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--uk-border-input, #e2e8f0);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.5;
    box-sizing: border-box;
    resize: vertical;
    min-height: 40px;
}

.pdf-image-desc input:focus,
.pdf-image-desc textarea:focus {
    outline: none;
    border-color: var(--uk-primary, #09B87D);
    box-shadow: 0 0 0 3px rgba(9, 184, 125, 0.1);
}

.pdf-image-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.6) !important;
    color: #fff !important;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s ease;
}

.pdf-image-remove:hover {
    background: rgba(239, 68, 68, 0.9) !important;
}

/* ───── Exit Strategies ───── */
.pdf-exit-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

.pdf-exit-entry {
    border: 1px solid var(--uk-border, #E6E8EC);
    border-radius: 8px;
    padding: 12px;
    position: relative;
}

.pdf-exit-title {
    margin-bottom: 8px !important;
    font-weight: 600;
}

.pdf-exit-entry .pdf-textarea {
    margin-top: 8px;
}

.pdf-exit-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent !important;
    border: none;
    color: #ef4444 !important;
    cursor: pointer;
    font-size: 18px;
    padding: 2px 6px;
    line-height: 1;
}

/* ───── Add Buttons ───── */
.pdf-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent !important;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    color: #6b7280 !important;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pdf-add-btn:hover {
    border-color: var(--uk-primary, #09B87D);
    color: var(--uk-primary, #09B87D) !important;
    background: rgba(9, 184, 125, 0.05) !important;
}

.pdf-add-custom {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
}

/* ───── Custom Sections ───── */
.pdf-custom-section {
    border: 1px solid var(--uk-border, #E6E8EC);
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
    position: relative;
}

.pdf-custom-section .pdf-section-header {
    padding-right: 40px;
}

.pdf-custom-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent !important;
    border: none;
    color: #ef4444 !important;
    cursor: pointer;
    font-size: 18px;
    padding: 2px 6px;
    line-height: 1;
    z-index: 1;
}

.pdf-custom-section .pdf-section-content {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--uk-border, #E6E8EC);
}

.pdf-custom-title {
    margin-bottom: 8px !important;
    font-weight: 600;
}

/* ───── Loading Spinner ───── */
.pdf-overlay-generate.loading {
    pointer-events: none;
    opacity: 0.7;
}

.pdf-overlay-generate.loading svg {
    display: none;
}

/* ───── Animations ───── */
@keyframes pdfFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pdfSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pdfSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ───── Responsive ───── */
@media (max-width: 768px) {
    .pdf-overlay-content {
        width: 100%;
    }

    .pdf-overlay-header h3 {
        font-size: 16px;
    }

    .pdf-nokkeltall-list {
        grid-template-columns: 1fr;
    }

    .pdf-image-list {
        grid-template-columns: 1fr;
    }

    .pdf-scenario-fields {
        grid-template-columns: 1fr;
    }

    .pdf-comparable-entry {
        flex-direction: column;
    }

    .pdf-comparable-thumb {
        width: 100%;
        height: 120px;
    }
}
