/* ═══════════════════════════════════════════════════
 * document_generator.css — Dual-Pane Document Generator Modal
 * Dark mode, responsive, glassmorphism, premium design
 * ═══════════════════════════════════════════════════ */

/* ── OVERLAY ── */
.docgen-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.docgen-overlay.docgen-active {
    opacity: 1;
    pointer-events: auto;
}

/* ── CONTAINER ── */
.docgen-container {
    width: 92vw;
    height: 88vh;
    max-width: 1500px;
    background: #1a1f2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s ease;
}

.docgen-active .docgen-container {
    transform: scale(1) translateY(0);
}

.docgen-container.docgen-fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
}

/* ── HEADER ── */
.docgen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: linear-gradient(135deg, #1e2433 0%, #252d3f 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.docgen-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.docgen-header-left h2 {
    font-size: 16px;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0;
}

.docgen-icon {
    font-size: 20px;
}

.docgen-header-right {
    display: flex;
    gap: 6px;
}

/* ── BODY (DUAL PANE) ── */
.docgen-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.docgen-left {
    width: 40%;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    background: #161b27;
}

.docgen-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #12161f;
}

/* ── LEFT: SECTIONS ── */
.docgen-sections {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.docgen-section {
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
    transition: border-color 0.2s;
}

.docgen-section:hover {
    border-color: rgba(230, 57, 70, 0.3);
}

.docgen-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    user-select: none;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.2s;
}

.docgen-section-header:hover {
    background: rgba(255, 255, 255, 0.06);
}

.docgen-chevron {
    transition: transform 0.25s;
    font-size: 11px;
    color: #64748b;
}

.docgen-collapsed .docgen-chevron {
    transform: rotate(-90deg);
}

.docgen-section-body {
    padding: 10px 14px;
    max-height: 600px;
    overflow-y: auto;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.25s;
}

.docgen-collapsed .docgen-section-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
    opacity: 0;
}

/* ── FORM FIELDS ── */
.docgen-field {
    margin-bottom: 8px;
}

.docgen-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 3px;
}

.docgen-field input,
.docgen-field textarea,
.docgen-field select {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 7px 10px;
    color: #e2e8f0;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.docgen-field input:focus,
.docgen-field textarea:focus {
    outline: none;
    border-color: #E63946;
    box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.15);
}

.docgen-field-row {
    display: flex;
    gap: 8px;
}

.docgen-field-row .docgen-field {
    flex: 1;
}

/* ── SERVICE LINES ── */
.docgen-services-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.docgen-service-line {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 8px 10px;
}

.docgen-service-line.docgen-line-info {
    border-left: 3px solid #f59e0b;
}

.docgen-line-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: #e2e8f0;
}

.docgen-badge-info {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.docgen-line-details {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 3px;
}

.docgen-line-details strong {
    color: #22c55e;
}

.docgen-line-notes {
    font-size: 10px;
    color: #64748b;
    margin-top: 3px;
    font-style: italic;
}

/* ── COST SUMMARY ── */
.docgen-cost-summary {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 10px;
}

.docgen-cost-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
    color: #94a3b8;
}

.docgen-cost-row strong {
    color: #e2e8f0;
}

.docgen-cost-total {
    border-top: 1px solid rgba(230, 57, 70, 0.3);
    margin-top: 4px;
    padding-top: 6px;
}

.docgen-cost-total span,
.docgen-cost-total strong {
    color: #E63946;
    font-size: 14px;
}

/* ── ACTION BAR ── */
.docgen-actions {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* ── BUTTONS ── */
.docgen-btn {
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
}

.docgen-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

.docgen-btn:active {
    transform: translateY(0);
}

.docgen-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.docgen-btn-sm {
    padding: 4px 10px;
    font-size: 13px;
    border-radius: 6px;
}

.docgen-btn-primary {
    background: linear-gradient(135deg, #E63946, #c4303b);
    border-color: #E63946;
    color: white;
    flex: 1;
}

.docgen-btn-primary:hover {
    background: linear-gradient(135deg, #f04955, #E63946);
    box-shadow: 0 4px 15px rgba(230, 57, 70, 0.3);
}

.docgen-btn-success {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.docgen-btn-success:hover {
    background: rgba(34, 197, 94, 0.25);
}

.docgen-btn-accent {
    background: rgba(69, 123, 157, 0.15);
    border-color: rgba(69, 123, 157, 0.3);
    color: #457B9D;
}

.docgen-btn-accent:hover {
    background: rgba(69, 123, 157, 0.25);
}

.docgen-btn-close {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    font-size: 16px;
    line-height: 1;
}

.docgen-btn-close:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* ── BADGE ── */
.docgen-badge {
    background: rgba(69, 123, 157, 0.2);
    color: #457B9D;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── RIGHT: PREVIEW ── */
.docgen-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.docgen-preview-title {
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
}

.docgen-zoom-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.docgen-zoom-controls span {
    font-size: 11px;
    color: #64748b;
    min-width: 40px;
    text-align: center;
}

.docgen-preview-area {
    flex: 1;
    overflow: auto;
    position: relative;
}

.docgen-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #475569;
}

.docgen-placeholder-icon {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 10px;
}

.docgen-placeholder p {
    font-size: 13px;
}

.docgen-iframe {
    width: 100%;
    height: 100%;
    border: none;
    transform-origin: top left;
}

/* ── LOADING ── */
.docgen-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #64748b;
}

.docgen-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(230, 57, 70, 0.2);
    border-top-color: #E63946;
    border-radius: 50%;
    animation: docgen-spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes docgen-spin {
    to { transform: rotate(360deg); }
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
    .docgen-body {
        flex-direction: column;
    }

    .docgen-left {
        width: 100%;
        min-width: auto;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .docgen-right {
        min-height: 40vh;
    }

    .docgen-container {
        width: 98vw;
        height: 95vh;
    }
}

@media (max-width: 600px) {
    .docgen-actions {
        flex-direction: column;
    }

    .docgen-field-row {
        flex-direction: column;
    }
}

/* ── EDITABLE ZONES IN LIVE PREVIEW ── */
#docgen-live-preview [contenteditable="true"] {
    border: 1px dashed rgba(30, 64, 175, 0.3);
    border-radius: 3px;
    padding: 2px 4px;
    cursor: text;
    transition: all 0.2s ease;
    position: relative;
}

#docgen-live-preview [contenteditable="true"]:hover {
    border-color: rgba(30, 64, 175, 0.6);
    background: rgba(30, 64, 175, 0.05);
    box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.1);
}

#docgen-live-preview [contenteditable="true"]:focus {
    outline: none;
    border-color: #1e40af;
    border-style: solid;
    background: rgba(30, 64, 175, 0.08);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15);
}

#docgen-live-preview [contenteditable="true"]:hover::after {
    content: "✏️";
    position: absolute;
    right: 2px;
    top: -2px;
    font-size: 10px;
    opacity: 0.6;
}

/* ── EDIT MODE (toggled via ✏️ button) ── */
.docgen-edit-active [contenteditable="true"] {
    border: 1.5px dashed #E63946 !important;
    background: rgba(230, 57, 70, 0.04) !important;
    border-radius: 3px;
    padding: 2px 4px;
    position: relative;
    transition: all 0.2s ease;
}

.docgen-edit-active [contenteditable="true"]:hover {
    background: rgba(230, 57, 70, 0.1) !important;
    border-color: #C1121F !important;
    box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.15);
}

.docgen-edit-active [contenteditable="true"]:focus {
    border-color: #1D3557 !important;
    border-style: solid !important;
    background: rgba(29, 53, 87, 0.06) !important;
    box-shadow: 0 0 0 3px rgba(29, 53, 87, 0.15);
    outline: none;
}
