
/* === RESET & BASE === */
.p2i-module *,
.p2i-module *::before,
.p2i-module *::after {
    box-sizing: border-box;
}

/* === UPLOAD ZONE === */
.p2i-upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: var(--bs-body-bg, #fff);
    transition: border-color .2s, background .2s;
    cursor: pointer;
}

    .p2i-upload-zone:hover,
    .p2i-upload-zone.p2i-drag-over {
        border-color: #00924A;
        background: rgba(0,146,74,.04);
    }

/* === PDF CARD === */
.p2i-pdf-card {
    background: var(--bs-tertiary-bg, #f8f9fa);
    border-radius: 14px;
    padding: 18px;
    border: 1px solid var(--bs-border-color, #e9ecef);
    position: relative;
    overflow: hidden;
    transition: box-shadow .2s;
}

    .p2i-pdf-card.p2i-processing {
        background: var(--bs-info-bg-subtle, #cff4fc);
        border-left: 4px solid var(--bs-info, #0dcaf0);
    }

    .p2i-pdf-card.p2i-completed {
        border-left: 4px solid var(--bs-success, #198754);
    }

.p2i-pdf-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.p2i-pdf-icon {
    width: 90px;
    min-width: 90px;
    height: 120px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px dashed #607D8B;
    background: var(--bs-body-bg, #fff);
    flex-shrink: 0;
}

    .p2i-pdf-icon img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: top;
    }

.p2i-pdf-info {
    flex: 1;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.p2i-pdf-name {
    font-weight: 600;
    color: var(--bs-body-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 340px;
}

.p2i-pdf-meta {
    font-size: 12px;
    color: var(--bs-secondary-color);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* === BADGES === */
.p2i-badge-lang {
    background: #e7f1ff;
    color: #0c63e4;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 20px;
    white-space: nowrap;
}

.p2i-badge-pages {
    background: #fef3c7;
    color: #b45309;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 20px;
    white-space: nowrap;
}

    .p2i-badge-pages.custom {
        background: #198754;
        color: #fff;
    }

[data-bs-theme="dark"] .p2i-badge-lang {
    background: #1a3a6b;
    color: #90b8f8;
}

[data-bs-theme="dark"] .p2i-badge-pages {
    background: #4a3200;
    color: #fcd34d;
}

    [data-bs-theme="dark"] .p2i-badge-pages.custom {
        background: #0f5132;
        color: #75b798;
    }

/* === ACTION BUTTONS === */
.p2i-action-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.p2i-icon-btn {
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #e2e8f0);
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .15s, background .15s;
    font-size: 17px;
    position: relative;
    flex-shrink: 0;
}

    .p2i-icon-btn:hover {
        transform: translateY(-2px);
        background: var(--bs-secondary-bg, #f1f5f9);
    }

    .p2i-icon-btn.p2i-disabled {
        opacity: .35;
        pointer-events: none;
    }

    .p2i-icon-btn.p2i-lang-btn {
        color: #4f46e5;
    }

    .p2i-icon-btn.p2i-pages-btn {
        color: #d97706;
    }

    .p2i-icon-btn.p2i-view-btn {
        color: #7c3aed;
    }

    .p2i-icon-btn.p2i-whatsapp-btn {
        color: #25D366;
    }

    .p2i-icon-btn.p2i-download-btn {
        color: #ef4444;
    }

    .p2i-icon-btn.p2i-delete-btn {
        color: #94a3b8;
    }

    .p2i-icon-btn.p2i-sync-btn {
        color: #4285f4;
    }

        .p2i-icon-btn.p2i-sync-btn.synced {
            color: #198754;
        }

/* === CARD PROGRESS OVERLAY === */
.p2i-card-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, #4f46e5, #10b981);
    width: 0%;
    transition: width .4s ease;
    border-radius: 0 0 14px 14px;
}

/* === PAGE STATUS PILLS === */
.p2i-page-status-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
    overflow-y: auto;
}

.p2i-page-pill {
    background: var(--bs-secondary-bg, #e9ecef);
    color: var(--bs-secondary-color, #6c757d);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 500;
    display: none;
    transition: background .2s, color .2s;
}

    .p2i-page-pill.processing {
        display: inline-block;
        background: #4f46e5;
        color: #fff;
        animation: p2i-pulse .9s infinite;
    }

    .p2i-page-pill.done {
        display: inline-block;
        background: #198754;
        color: #fff;
    }

@keyframes p2i-pulse {
    0%, 100% {
        opacity: .7;
        transform: scale(.97);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* === GLOBAL PROGRESS BAR === */
.p2i-global-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 9999;
    display: none;
}

.p2i-global-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width .3s;
}

/* === TOAST === */
.p2i-toast-stack {
    position: fixed;
    top: 65px;
    right: 16px;
    z-index: 9999999 !important;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.p2i-toast {
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    padding: 10px 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    animation: p2i-slidein .25s ease;
    pointer-events: auto;
    min-width: 220px;
    max-width: 340px;
}

@keyframes p2i-slidein {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes p2i-slideout {
    to {
        transform: translateX(110%);
        opacity: 0;
    }
}

/* === TEXT PREVIEW === */
.p2i-text-wrap {
    position: relative;
    min-width: 200px;
    flex: 1;
}

.p2i-preview-ta {
    width: 100%;
    font-size: 11.5px;
    border-radius: 8px;
    font-family: 'Consolas','Monaco',monospace;
    resize: vertical;
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
    padding: 8px 60px 8px 10px;
    min-height: 80px;
}

    .p2i-preview-ta:disabled {
        cursor: default;
        opacity: 1;
    }

.p2i-copy-btn-inline {
    position: absolute;
    right: 8px;
    top: 8px;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color);
    border-radius: 5px;
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .2s;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--bs-body-color);
}

.p2i-text-wrap:hover .p2i-copy-btn-inline {
    opacity: 1;
}

.p2i-copy-btn-inline.copied {
    background: #198754;
    color: #fff;
    border-color: #198754;
}

/* === STICKY TOP BAR === */
.p2i-top-bar {
    position: sticky;
    top: 63px;
    z-index: 100;
    padding: 10px 0;
    background: #f2f2f2;
    border-bottom: 1px solid var(--bs-border-color);
    margin-bottom: 16px;
}

/* === LANGUAGE MODAL === */
.p2i-lang-item {
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .15s;
    background: var(--bs-body-bg);
    margin-bottom: 6px;
}

    .p2i-lang-item:hover {
        background: var(--bs-secondary-bg);
        transform: translateX(4px);
        border-color: #667eea;
    }

    .p2i-lang-item.selected {
        border-color: #667eea;
        border-left: 4px solid #667eea;
        background: var(--bs-info-bg-subtle);
    }

.p2i-lang-list {
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}

    .p2i-lang-list::-webkit-scrollbar {
        width: 6px;
    }

    .p2i-lang-list::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 6px;
    }

/* === PAGE THUMBNAILS === */
.p2i-pg-thumb {
    border: 2px solid var(--bs-border-color);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    transition: border-color .15s, transform .15s;
}

    .p2i-pg-thumb:hover {
        border-color: #667eea;
        transform: translateY(-2px);
    }

    .p2i-pg-thumb.selected {
        border-color: #198754;
        background: var(--bs-success-bg-subtle);
    }

    .p2i-pg-thumb img {
        width: 100%;
        height: 160px;
        object-fit: contain;
        border-radius: 6px;
    }

/* === TEXT VIEWER === */
#p2i-viewer-ta {
    width: 100%;
    min-height: 480px;
    max-height: calc(100vh - 220px);
    padding: 20px;
    font-size: 13.5px;
    font-family: 'Consolas','Monaco',monospace;
    line-height: 1.65;
    white-space: pre-wrap;
    resize: vertical;
    border: none;
    background: var(--bs-tertiary-bg, #f8f9fa);
    color: var(--bs-body-color);
    overflow-y: auto;
}

    #p2i-viewer-ta:focus {
        outline: none;
    }

    #p2i-viewer-ta::-webkit-scrollbar {
        width: 8px;
    }

    #p2i-viewer-ta::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 8px;
    }

/* === OCR CONFIDENCE === */
.p2i-confidence-bar {
    height: 8px;
    border-radius: 8px;
    transition: width .4s;
}

/* === COMPLETION BANNER === */
.p2i-done-banner {
    background: var(--bs-success-bg-subtle, #d1e7dd);
    border-radius: 10px;
    padding: 10px 16px;
    display: none;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .p2i-pdf-header {
        flex-direction: column;
    }

    .p2i-pdf-icon {
        width: 100%;
        height: 100px;
    }

    .p2i-conf {
        width: 100%;
    }

    #p2i-reset-btn {
        display: none;
    }

    .p2i-pdf-icon img {
        object-position: top;
    }

    .p2i-top-bar {
        top: 0;
    }

    .p2i-text-wrap {
        width: 100% !important;
        min-width: unset !important;
    }

    .p2i-pdf-name {
        max-width: 100%;
    }
}
/* === SPLIT DOWNLOAD BUTTON === */
.p2i-split-btn {
    display: inline-flex;
}

    .p2i-split-btn .btn-success:first-child {
        border-radius: 8px 0 0 8px;
    }

    .p2i-split-btn .dropdown-toggle-split {
        border-radius: 0 8px 8px 0;
        border-left: 1px solid rgba(255,255,255,0.3);
        padding-left: 10px;
        padding-right: 10px;
    }

        .p2i-split-btn .dropdown-toggle-split::after {
            margin-left: 0;
        }

.p2i-dropdown-menu {
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 6px;
    min-width: 250px;
}

.p2i-dropdown-item {
    border-radius: 7px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background .15s;
    font-size: 13px;
    border: none;
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--bs-body-color);
}

    .p2i-dropdown-item:hover {
        background: var(--bs-secondary-bg);
    }

    .p2i-dropdown-item i {
        font-size: 16px;
        width: 20px;
        text-align: center;
        flex-shrink: 0;
    }
