/* ============================================================
   TECHMO — Report Preview Panel (Shared Styles)
   Panneau d'aperçu rapport temps réel pour tous les modules
   ============================================================ */

/* --- Layout Flex Split --- */
.techmo-preview-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - 80px);
    overflow: hidden;
}

.techmo-preview-layout > .techmo-form-panel {
    flex: 1;
    overflow-y: auto;
    padding: 25px 35px;
    min-width: 0;
    transition: flex 0.35s ease;
}

.techmo-preview-layout > .techmo-doc-panel {
    flex: 0 0 48%;
    max-width: 48%;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e2e8f0;
    background: #edf0f5;
    transition: flex 0.35s ease, max-width 0.35s ease, opacity 0.3s ease;
    overflow: hidden;
}

.techmo-preview-layout > .techmo-doc-panel.collapsed {
    flex: 0 0 0%;
    max-width: 0%;
    opacity: 0;
    border-left: none;
    overflow: hidden;
}

/* --- Doc Panel Header --- */
.techmo-doc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.techmo-doc-header h5 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--primary, #002060);
    display: flex;
    align-items: center;
    gap: 8px;
}

.techmo-doc-header .techmo-doc-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.techmo-doc-header .btn-doc-action {
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 6px;
    padding: 5px 12px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.techmo-doc-header .btn-doc-action:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.techmo-doc-header .btn-doc-export {
    background: #16a34a;
    color: #fff;
    border-color: #16a34a;
}

.techmo-doc-header .btn-doc-export:hover {
    background: #15803d;
}

/* --- A4 Sheet --- */
.techmo-a4-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.techmo-a4-sheet {
    background: #fff;
    width: 100%;
    max-width: 800px;
    padding: 50px 45px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    border-radius: 3px;
    font-family: 'Times New Roman', 'Georgia', Times, serif;
    color: #000;
    font-size: 0.9rem;
    line-height: 1.55;
    min-height: 600px;
}

/* --- TECHMO Header in A4 --- */
.techmo-a4-sheet .tpl-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 3px solid var(--primary, #002060);
    padding-bottom: 15px;
    margin-bottom: 25px;
}

.techmo-a4-sheet .tpl-header-left {
    font-size: 0.75rem;
    color: #334155;
    line-height: 1.5;
}

.techmo-a4-sheet .tpl-header-left .tpl-company {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--primary, #002060);
    font-family: 'Segoe UI', sans-serif;
    letter-spacing: 1px;
}

.techmo-a4-sheet .tpl-header-right {
    text-align: right;
    font-size: 0.7rem;
    color: #64748b;
    line-height: 1.5;
}

.techmo-a4-sheet .tpl-header-right .tpl-affaire-num {
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary, #002060);
    font-family: 'Segoe UI', sans-serif;
}

/* --- Title Bar --- */
.techmo-a4-sheet .tpl-title-bar {
    text-align: center;
    margin-bottom: 25px;
}

.techmo-a4-sheet .tpl-title-bar h1 {
    font-size: 1.25rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--primary, #002060);
    margin: 0 0 5px;
    font-family: 'Segoe UI', sans-serif;
    letter-spacing: 1px;
}

.techmo-a4-sheet .tpl-title-bar h2 {
    font-size: 0.95rem;
    font-weight: 400;
    font-style: italic;
    color: #475569;
    margin: 0;
}

/* --- Meta Table --- */
.techmo-a4-sheet .tpl-meta-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
    font-size: 0.82rem;
}

.techmo-a4-sheet .tpl-meta-table td {
    padding: 5px 10px;
    border: 1px solid #cbd5e1;
    vertical-align: top;
}

.techmo-a4-sheet .tpl-meta-table td:first-child {
    font-weight: 700;
    color: #334155;
    width: 35%;
    background: #f8fafc;
}

/* --- Section Headers --- */
.techmo-a4-sheet .tpl-section {
    margin-bottom: 20px;
}

.techmo-a4-sheet .tpl-section h3 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary, #002060);
    border-bottom: 2px solid var(--primary, #002060);
    padding-bottom: 5px;
    margin-bottom: 12px;
    font-family: 'Segoe UI', sans-serif;
}

.techmo-a4-sheet .tpl-section h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: #334155;
    margin: 15px 0 8px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 4px;
}

/* --- Placeholder Spans --- */
.techmo-a4-sheet [data-tpl] {
    color: var(--primary, #002060);
    font-weight: 600;
    transition: background 0.3s;
}

.techmo-a4-sheet [data-tpl].tpl-empty {
    color: #94a3b8;
    font-style: italic;
    font-weight: 400;
}

.techmo-a4-sheet [data-tpl].tpl-highlight {
    background: #fef08a;
}

/* --- Tables in Template --- */
.techmo-a4-sheet table.tpl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin: 10px 0 20px;
}

.techmo-a4-sheet table.tpl-table th {
    background: var(--primary, #002060);
    color: #fff;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 7px 10px;
    text-align: left;
}

.techmo-a4-sheet table.tpl-table td {
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    vertical-align: top;
}

.techmo-a4-sheet table.tpl-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

/* --- Signature Block --- */
.techmo-a4-sheet .tpl-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    page-break-inside: avoid;
}

.techmo-a4-sheet .tpl-sig-block {
    width: 45%;
    text-align: center;
}

.techmo-a4-sheet .tpl-sig-space {
    height: 80px;
    border: 1px dashed #cbd5e1;
    margin-top: 8px;
    background: #fafafa;
    border-radius: 4px;
}

/* --- Toggle Button (Fixed) --- */
.techmo-preview-toggle {
    position: fixed;
    right: 20px;
    bottom: 25px;
    z-index: 999;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--primary, #002060);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}

.techmo-preview-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}

.techmo-preview-toggle .toggle-label {
    position: absolute;
    right: 56px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    font-family: 'Segoe UI', sans-serif;
}

.techmo-preview-toggle:hover .toggle-label {
    opacity: 1;
}

/* --- Print --- */
@media print {
    .techmo-form-panel,
    .techmo-doc-header,
    .techmo-preview-toggle { display: none !important; }
    .techmo-preview-layout { display: block !important; }
    .techmo-doc-panel {
        flex: unset !important;
        max-width: 100% !important;
        border: none !important;
        background: #fff !important;
    }
    .techmo-a4-container { padding: 0 !important; }
    .techmo-a4-sheet { box-shadow: none !important; padding: 20px !important; }
}

/* --- Responsive --- */
@media (max-width: 1200px) {
    .techmo-preview-layout > .techmo-doc-panel {
        flex: 0 0 42%;
        max-width: 42%;
    }
}

@media (max-width: 992px) {
    .techmo-preview-layout {
        flex-direction: column;
        height: auto;
    }
    .techmo-preview-layout > .techmo-form-panel {
        flex: none;
        height: auto;
        overflow: visible;
    }
    .techmo-preview-layout > .techmo-doc-panel {
        flex: none;
        max-width: 100%;
        height: 600px;
        border-left: none;
        border-top: 1px solid #e2e8f0;
    }
}
