/* ================================================================
   Axeane UI — Traitement Document Screen CSS
   V3 CARDS design (template-v-traitement-doc reference)
   ================================================================ */

/* ═══ SHARED INPUT (compact) ═══ */
.ti {
    width: 100%; height: 32px; padding: 5px 10px; font-size: 13px; font-weight: 400;
    color: var(--ax-text); background: #fff;
    border: 1px solid var(--ax-border-input); border-radius: 5px;
    outline: none; transition: border-color .15s, box-shadow .15s;
    font-family: inherit; box-sizing: border-box;
}
.ti:hover { border-color: var(--ax-border-hover) }
.ti:focus { border-color: var(--ax-border-focus); box-shadow: 0 0 0 2.5px rgba(37, 99, 235, .10) }
.ti::placeholder { color: var(--ax-text-light); font-weight: 400 }
.ti-off { background: #f3f4f6; color: var(--ax-text-sec); cursor: not-allowed }
.ti-n { text-align: right; font-variant-numeric: tabular-nums }
.ti-sl {
    appearance: none; -webkit-appearance: none; padding-right: 26px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: right 6px center; background-size: 10px 7px;
    background-color: #fff;
}
.ti-sl-select {
    display: block; width: 100%; height: 30px;
    border: 1px solid var(--ax-border-input); border-radius: 5px;
    background: #fff; font-size: 13px; transition: border-color .15s;
}
.ti-sl-select:hover { border-color: var(--ax-border-hover) }
.ti-sl-select .ui-select-match-text { padding: 4px 8px; line-height: 20px }

/* ═══ INFOS COMMUNES — ONE LINE ═══ */
.td-il {
    display: flex; align-items: flex-end; gap: 10px; flex-wrap: nowrap;
    padding: 0;
}
.td-f { display: flex; flex-direction: column; gap: 3px; min-width: 0 }
.td-f label {
    font-size: 14px; font-weight: 600; color: var(--ax-text-body);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    line-height: 1.3; margin: 0; letter-spacing: .01em;
}
.td-ig { display: flex; align-items: center; gap: 0 }
.td-ig .ti { border-radius: 5px 0 0 5px; border-right: none }
.td-igb {
    width: 32px; height: 32px; border: 1px solid var(--ax-border-input); border-left: none; border-radius: 0 5px 5px 0;
    background: #f8fafc; color: var(--ax-text-sec); cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 13px; transition: all .15s; flex-shrink: 0;
}
.td-igb:hover { background: var(--ax-primary-50); color: var(--ax-primary); border-color: var(--ax-border-focus) }

/* ═══ ACTION BUTTONS ROW ═══ */
.td-ab {
    display: flex; align-items: center; gap: 5px; flex-wrap: nowrap;
}
.td-rl {
    display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 500;
    color: var(--ax-text-sec); cursor: pointer; user-select: none; margin-left: 4px;
}
.td-rl input { margin: 0; cursor: pointer }

/* ═══ V3 — FULL WIDTH (like ax-container / ax-toolbar) ═══ */
.td-v3c {
    margin: 0; background: #fff;
    border: none; border-radius: 0;
    box-shadow: none; overflow: hidden;
    border-bottom: 1px solid var(--ax-border);
}
.td-v3h { padding: 0 }
.td-v3hd {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 24px;
    border-bottom: 1px solid var(--ax-border-strong);
    background: var(--ax-card);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
    flex-wrap: wrap; gap: 8px;
}
.td-v3t {
    font-size: 15px; font-weight: 700; color: var(--ax-text-strong);
    display: flex; align-items: center; gap: 7px;
    white-space: nowrap;
}
.td-v3t i { color: var(--ax-primary); font-size: 15px }
.td-v3-info-zone {
    padding: 10px 24px;
    border-bottom: 1px solid var(--ax-border-light);
    background: #fff;
    cursor: default;
}
.td-v3b { margin: 0; border-radius: 0; border: none; box-shadow: none }

/* ═══ TYPE FILTER DROPDOWN ═══ */
.td-type-filter-wrap {
    position: relative; display: inline-flex; align-items: center;
}
.td-type-filter-btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 12px; border-radius: var(--ax-radius-xs);
    border: 1.5px solid var(--ax-border-input);
    background: #fff; color: var(--ax-text-body);
    font-size: 12px; font-weight: 600; cursor: pointer;
    transition: all .15s; white-space: nowrap;
}
.td-type-filter-btn i.fa-filter { color: var(--ax-primary); font-size: 12px }
.td-type-filter-btn:hover { border-color: var(--ax-primary); color: var(--ax-primary); background: var(--ax-primary-50) }
.td-type-filter-btn.active { border-color: var(--ax-primary); color: var(--ax-primary); background: var(--ax-primary-50); box-shadow: 0 0 0 2px rgba(var(--ax-primary-rgb), .12) }
.td-type-filter-dd {
    display: none; position: absolute; left: 0; top: 100%; margin-top: 4px;
    min-width: 220px; padding: 4px 0; z-index: 500;
    background: var(--ax-card); border: 1px solid var(--ax-border);
    border-radius: var(--ax-radius-sm); box-shadow: var(--ax-shadow-lg);
    list-style: none;
}
.td-type-filter-dd.open { display: block }
.td-type-filter-dd li {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 14px; font-size: 12.5px; font-weight: 500;
    color: var(--ax-text-body); cursor: pointer;
    white-space: nowrap; transition: background .1s;
}
.td-type-filter-dd li:hover { background: var(--ax-border-light); color: var(--ax-text-bold) }
.td-type-filter-dd li.active { background: var(--ax-primary-50); color: var(--ax-primary); font-weight: 600 }
.td-type-filter-dd li i { width: 14px; text-align: center; font-size: 12px; color: var(--ax-primary) }

/* ═══ SPLIT ZONE ═══ */
.td-sp {
    display: flex; min-height: 0; overflow: hidden; position: relative;
    margin: 0; border: none; border-radius: 0;
    height: calc(100vh - var(--ax-header-h, 56px) - 200px);
}
.td-lf {
    display: flex; min-height: 0; overflow-y: hidden; overflow-x: hidden;
    min-width: 0;
}
.td-rt {
    display: flex; flex-direction: column; min-height: 0; overflow: hidden; position: relative;
    background: #fafbfc; min-width: 0;
}

/* Divider */
.td-dv {
    width: 5px; background: var(--ax-border-strong); cursor: col-resize; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s; position: relative; z-index: 5;
}
.td-dv:hover { background: var(--ax-primary) }
.td-gr { width: 3px; height: 40px; background: rgba(255, 255, 255, .5); border-radius: 4px }

/* ═══ CMD BAR VERTICAL (GAUCHE) ═══ */
.td-cmd {
    display: flex; flex-direction: column; align-items: center;
    padding: 6px 3px; gap: 2px;
    background: linear-gradient(180deg, #f8f9fc, #eef0f5);
    border-right: 1px solid var(--ax-border);
    flex-shrink: 0; width: 36px;
}
.td-cb {
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    border: none; background: transparent; cursor: pointer;
    color: var(--ax-text); font-size: 16px; border-radius: 5px;
    transition: all .15s;
}
.td-cb:hover { background: var(--ax-primary-50); color: var(--ax-primary) }
.td-cb:active { background: var(--ax-primary); color: #fff }

/* ═══ TABLE (inside split left) ═══ */
.td-li { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden }
.td-li .ax-table-footer { flex-shrink: 0 }
.td-tw { flex: 1; overflow-y: auto; overflow-x: auto; min-width: 0 }
.td-tw::-webkit-scrollbar { width: 5px; height: 5px }
.td-tw::-webkit-scrollbar-track { background: transparent }
.td-tw::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 10px }
.td-tw::-webkit-scrollbar-thumb:hover { background: #9CA3AF }

.td-t { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 1.45; table-layout: fixed; min-width: 680px }

/* THEAD — Modern professional header */
.td-thead-row { background: linear-gradient(180deg, #f8fafc 0%, #eef1f7 100%) }
.td-t thead th {
    font-weight: 700; text-align: left; padding: 0 8px; height: 40px;
    font-size: 13px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
    color: #475569;
    border-bottom: 2px solid var(--ax-primary-light);
    position: sticky; top: 0; z-index: 10; vertical-align: middle;
    background: linear-gradient(180deg, #f8fafc 0%, #eef1f7 100%);
}

/* Column widths */
.tc-ck { width: 34px; text-align: center !important }
.tc-ck input { margin: 0; cursor: pointer; width: 15px; height: 15px; accent-color: var(--ax-primary) }
.tc-nm { width: 44px; text-align: center !important }
.tc-cp { width: 22% }
.tc-lb { width: auto }
.tc-tr { width: 15% }
.tc-mt { width: 10%; text-align: right !important }

/* Add button inline in th */
.td-ai {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 4px; background: var(--ax-success); color: #fff;
    cursor: pointer; font-size: 12px; margin-right: 4px; transition: all .15s; vertical-align: middle;
    border: none; box-shadow: 0 1px 2px rgba(76, 175, 80, .3);
}
.td-ai:hover { background: #2e7d32; transform: scale(1.12); box-shadow: 0 2px 6px rgba(76, 175, 80, .35) }

/* TBODY — rows */
.td-t tbody tr.td-row {
    background: #fff;
    transition: background .12s ease, box-shadow .12s ease;
}
.td-t tbody tr.td-row:nth-child(even) { background: #fafbfe }
.td-t tbody tr.td-row:hover {
    background: rgba(63, 81, 181, .05) !important;
    box-shadow: inset 3px 0 0 var(--ax-primary);
}
.td-t tbody tr.td-row-sel {
    background: rgba(63, 81, 181, .08) !important;
    box-shadow: inset 3px 0 0 var(--ax-primary);
}
.td-t tbody td {
    padding: 2px 6px; height: 36px; vertical-align: middle;
    border-bottom: 1px solid #eef0f5;
    font-size: 13px; color: var(--ax-text-body);
}

/* Row number badge */
.td-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 22px; border-radius: 4px;
    background: #f1f3f9; color: var(--ax-text-sec);
    font-size: 13px; font-weight: 700;
}

/* Input inside cells */
.td-t .ti { height: 30px; font-size: 13px; border-radius: 5px }
.td-t .ti:focus { z-index: 2; position: relative; box-shadow: 0 0 0 2px rgba(37, 99, 235, .12) }

/* Th filter input */
.td-th-filter {
    height: 28px !important; font-size: 13px !important; font-weight: 600;
    border: 1px solid var(--ax-border-input); border-radius: 5px;
    padding: 3px 8px; background: #fff; color: var(--ax-text);
    width: 100%; outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.td-th-filter::placeholder { color: var(--ax-primary); font-weight: 700; letter-spacing: .02em; opacity: .65; text-transform: uppercase }
.td-th-filter:focus { border-color: var(--ax-border-focus); box-shadow: 0 0 0 2px rgba(37, 99, 235, .15) }
.td-th-filter:hover:not(:focus) { border-color: var(--ax-border-hover) }

/* Compte wrapper (input + eye btn) */
.ti-cw { display: flex; align-items: center; position: relative }
.ti-cw .ti { padding-right: 28px }
.ti-eye {
    position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
    border: none; background: transparent; cursor: pointer;
    color: var(--ax-primary); font-size: 13px; padding: 2px; transition: color .15s, opacity .15s;
    opacity: .85;
}
.ti-eye:hover { color: var(--ax-primary-dark); opacity: 1 }

/* ═══ RIGHT PANEL (PDF side) — Toolbar & forms ═══ */
.td-rh {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    padding: 5px 8px; border-bottom: 1px solid var(--ax-border);
    background: #f8fafc; flex-shrink: 0; min-height: 36px;
}
.td-rh-f { display: flex; flex-direction: column; gap: 2px; min-width: 0 }
.td-rh-f .ti { height: 28px; font-size: 12.5px; padding: 2px 8px }

.td-rdel {
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--ax-danger-border); background: var(--ax-danger-light);
    color: var(--ax-danger); cursor: pointer; border-radius: 5px; font-size: 14px; transition: all .15s;
}
.td-rdel:hover { background: var(--ax-danger); color: #fff }

/* ═══ PDF viewer ═══ */
.td-pv { flex: 1; display: flex; align-items: stretch; justify-content: center; background: #e8e8e8; min-height: 200px; position: relative; overflow: hidden }
.td-pvph { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; color: var(--ax-text-light) }
.td-pvph i { font-size: 48px; margin-bottom: 12px; color: var(--ax-text-muted) }
.td-pvph p { font-size: 14px; font-weight: 600; margin: 6px 0 4px; color: var(--ax-text-sec) }
.td-pvph small { font-size: 13px; color: var(--ax-text-light) }

/* ── PDF loader / spinner ── */
.pdf-loader {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.85);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    z-index: 5000; font-family: inherit; color: var(--ax-primary); font-size: 14px;
}
.spinner {
    border: 4px solid #e0e0e0; border-top: 4px solid var(--ax-primary);
    border-radius: 50%; width: 50px; height: 50px;
    animation: spin 1s linear infinite; margin-bottom: 15px;
}
.loader-text { text-align: center; font-size: 14px; font-weight: 500; color: #333; }
#loaderProgress { font-size: 16px; font-weight: bold; color: var(--ax-primary); display: block; margin-bottom: 5px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ── Canvas tools ── */
.canvas-tools-wrapper {
    position: absolute; top: 54px; right: 15px; z-index: 10;
    display: flex; flex-direction: row; align-items: center; gap: 8px;
}
.canvas-tools-menu {
    display: flex; flex-direction: row; align-items: center; gap: 6px;
    opacity: 1; transform: scale(1); transform-origin: right center;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.canvas-tools-menu.hidden { opacity: 0; transform: scale(0.8); pointer-events: none; }
.tools-icon-button, .tools-toggle-icon {
    background-color: rgba(255, 255, 255, 0.15); border: 1px solid rgba(180, 180, 180, 0.4);
    border-radius: 50%; width: 32px; height: 32px; font-size: 15px;
    display: flex; justify-content: center; align-items: center; cursor: pointer;
    backdrop-filter: blur(4px); color: #333; transition: background-color 0.2s ease, transform 0.2s ease;
}
.tools-icon-button:hover, .tools-toggle-icon:hover { background-color: rgba(255, 255, 255, 0.4); transform: scale(1.05); }

/* ── Tooltip ── */
.tooltip-card-pro {
    background: #fdfaf7; border: 1px solid #e0d5c2; border-radius: 5px;
    padding: 6px 8px; font-size: 11.5px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    min-width: 140px; max-width: 200px; color: #333; font-family: inherit; line-height: 1.2;
}
.tooltip-header { display: flex; align-items: center; margin-bottom: 2px; }
.tooltip-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.tooltip-title { font-weight: 600; font-size: 11.5px; color: #2d2d2d; }
.tooltip-content div { display: flex; justify-content: space-between; margin: 1px 0; font-size: 11.5px; }
.tooltip-content strong { font-weight: 500; color: #555; margin-right: 6px; }
.tooltip-content span { font-weight: 500; color: #000; text-align: right; }

#pdfContainer { cursor: grab; overflow: auto !important; width: 100%; height: 100%; position: relative; }
#pdfContainer.dragging { cursor: grabbing !important; }
#pdfCanvas, #pdfOverlay { transition: transform 0.2s ease-in-out; transform-origin: top left; }

/* ═══ LAST ECRITURES ═══ */
.td-last-scroll { overflow-x: auto; overflow-y: auto; min-width: 0; flex-shrink: 1 }
.td-last-scroll::-webkit-scrollbar { width: 5px; height: 5px }
.td-last-scroll::-webkit-scrollbar-track { background: transparent }
.td-last-scroll::-webkit-scrollbar-thumb { background: #E5E7EB; border-radius: 10px }
.td-last-scroll::-webkit-scrollbar-thumb:hover { background: #D1D5DB }
.td-lc { background: #fff; border: 1px solid var(--ax-border); border-radius: var(--ax-radius-xs); box-shadow: var(--ax-shadow-xs); margin: 8px; overflow: hidden; min-width: 600px }
.td-lt { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 600px; table-layout: fixed; }
.td-lt th { padding: 6px 8px; background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; font-weight: 700; text-align: left; border-bottom: 1px solid var(--ax-border) }
.td-lt td { padding: 4px 8px; border-bottom: 1px solid #f1f5f9; color: var(--ax-text-body); font-size: 13px }

/* ═══ INFO SUMMARY PANEL (last ecritures header) ═══ */
.td-info-panel {
    display: flex; align-items: stretch; gap: 0; flex-wrap: nowrap;
    padding: 8px 12px; background: linear-gradient(135deg, #f8fafc 0%, #f1f4f9 100%);
    border-bottom: 1px solid var(--ax-border); flex-shrink: 0; overflow-x: auto; min-width: 600px;
}
.td-info-item { display: flex; flex-direction: column; gap: 2px; padding: 0 16px; flex: 1; min-width: 0; }
.td-info-lbl { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #64748b; line-height: 1.3; }
.td-info-lbl i { color: var(--ax-primary); margin-right: 4px; font-size: 12px; }
.td-info-val { font-size: 13px; font-weight: 600; color: var(--ax-text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-info-val-accent { color: var(--ax-primary); font-weight: 700; }
.td-info-val-solde { color: var(--ax-success-text); font-weight: 700; }
.td-info-sep { width: 1px; align-self: stretch; margin: 6px 0; background: var(--ax-border); flex-shrink: 0; }

/* ═══ LAST ECRITURES ACTION BUTTONS ═══ */
.td-lec-acts { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.td-ra {
    width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-size: 12px;
    transition: all .18s; outline: none;
}
.td-ra:active { opacity: .75 }
.td-ra-edit { background: var(--ax-info-light); color: var(--ax-info); border-color: rgba(var(--ax-info-rgb, 59, 130, 246), .25) }
.td-ra-edit:hover { background: var(--ax-info); color: #fff; border-color: var(--ax-info) }
.td-ra-del { background: var(--ax-danger-light); color: var(--ax-danger); border-color: rgba(var(--ax-danger-rgb, 239, 68, 68), .25) }
.td-ra-del:hover { background: var(--ax-danger); color: #fff; border-color: var(--ax-danger) }

/* ═══ HINT CHIP (OCR) ═══ */
.hint-chip {
    background: #fffbeb; border: 1px solid #fcd34d; color: #92400e;
    padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 500;
    box-shadow: 0 2px 10px rgba(251, 191, 36, .15); transition: opacity 0.4s ease, transform 0.4s ease;
    opacity: 0; transform: translateY(-8px);
}
.hint-chip.show { opacity: 1; transform: translateY(0); }

/* ═══ TOTAUX ═══ */
:root { --ax-totaux-h: 54px; }
.pl-page-has-totaux { padding-bottom: calc(var(--ax-totaux-h, 54px) + 12px) !important }

/* ═══ TOOLBAR SPACER ═══ */
.td-rh-spacer { flex: 1 }

/* ═══ FIXED EDGE BUTTONS ═══ */

/* Left edge — Journals shortcut */
.td-fixed-left {
    position: fixed; left: 0; top: 50%;
    transform: translateY(-50%);
    z-index: 1200;
    width: 28px; height: 72px;
    display: flex; align-items: center; justify-content: center;
    background: var(--ax-primary); color: #fff;
    border-radius: 0 8px 8px 0;
    cursor: pointer; font-size: 15px;
    box-shadow: 2px 0 8px rgba(0,0,0,.18);
    transition: width .2s, background .15s;
    writing-mode: vertical-rl; letter-spacing: .04em;
}
.td-fixed-left:hover { width: 34px; background: var(--ax-primary-dark) }

/* Right edge — OCR + new-window */
.td-fixed-right {
    position: fixed; right: 0; top: 50%;
    transform: translateY(-50%);
    z-index: 1200;
    display: flex; flex-direction: column; align-items: center;
    gap: 4px; padding: 6px 4px;
    background: #1e293b; border-radius: 10px 0 0 10px;
    box-shadow: -2px 0 10px rgba(0,0,0,.22);
}

/* Drag handle inside fixed-right */
.td-fixed-drag {
    display: flex; align-items: center; justify-content: center;
    gap: 1px; color: rgba(255,255,255,.45); cursor: grab;
    font-size: 12px; padding: 2px 4px; border-radius: 4px;
    transition: color .15s;
}
.td-fixed-drag:hover { color: rgba(255,255,255,.8) }
.td-fixed-drag:active { cursor: grabbing }

/* Fixed-right buttons */
.td-fixed-rb {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 7px;
    background: rgba(255,255,255,.1); color: #fff;
    cursor: pointer; font-size: 14px;
    transition: background .15s, transform .1s;
}
.td-fixed-rb:hover { background: rgba(255,255,255,.22); transform: scale(1.08) }
.td-fixed-rb:active { transform: scale(.95) }

.td-fixed-rb-danger { color: #fca5a5 }
.td-fixed-rb-danger:hover { background: rgba(239,68,68,.25); color: #ef4444 }

.td-fixed-rb-success { color: #86efac }
.td-fixed-rb-success:hover { background: rgba(34,197,94,.25); color: #22c55e }
