/* ── Business Card Scanner ── */

/* Trigger button shown above name fields */
.tbpp-bcs-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    margin: 0 0 12px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    box-sizing: border-box;
}

.tbpp-bcs-trigger:hover,
.tbpp-bcs-trigger:focus {
    background: #135e96;
    color: #fff;
}

.tbpp-bcs-trigger svg {
    flex-shrink: 0;
}

.tbpp-bcs-trigger-note {
    display: block;
    font-size: 11px;
    color: #757575;
    text-align: center;
    margin: -8px 0 12px;
    line-height: 1.4;
}

/* Modal overlay */
.tbpp-bcs-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.tbpp-bcs-modal.is-open {
    display: flex;
}

.tbpp-bcs-modal-content {
    background: #fff;
    border-radius: 12px;
    max-width: 560px;
    width: 100%;
    max-height: 95vh;
    max-height: 95dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
}

.tbpp-bcs-modal-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
}

.tbpp-bcs-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
}

.tbpp-bcs-modal-close {
    background: #f0f0f1;
    border: 1px solid #c3c4c7;
    font-size: 22px;
    line-height: 1;
    color: #1d2327;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tbpp-bcs-modal-close:hover,
.tbpp-bcs-modal-close:focus {
    background: #e0e0e0;
    color: #1d2327;
    outline: none;
}

.tbpp-bcs-modal-body {
    padding: 16px 20px 20px;
}

/* Camera viewport — landscape aspect for business cards */
.tbpp-bcs-camera-wrap {
    position: relative;
    width: 100%;
    margin: 0 auto 12px;
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16 / 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tbpp-bcs-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.tbpp-bcs-canvas {
    display: none;
}

.tbpp-bcs-captured {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
    background: #000;
}

/* Card guide overlay */
.tbpp-bcs-card-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    aspect-ratio: 1.75 / 1;
    border: 2px dashed rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    pointer-events: none;
    z-index: 2;
    display: none;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.2);
}

.tbpp-bcs-card-guide-text {
    position: absolute;
    bottom: -26px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Tap-to-act overlay */
.tbpp-bcs-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    z-index: 3;
    background: rgba(0, 0, 0, 0.35);
    transition: background 0.2s;
    color: #fff;
    text-align: center;
    padding: 16px;
    box-sizing: border-box;
}

.tbpp-bcs-overlay span {
    font-size: 14px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.tbpp-bcs-overlay svg {
    opacity: 0.85;
}

/* Progress / status text */
.tbpp-bcs-status {
    text-align: center;
    font-size: 13px;
    color: #50575e;
    min-height: 18px;
    margin: 8px 0;
}

.tbpp-bcs-status.is-error {
    color: #b32d2e;
    font-weight: 500;
}

.tbpp-bcs-progress-bar {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
    margin: 8px 0;
    display: none;
}

.tbpp-bcs-progress-bar.is-visible {
    display: block;
}

.tbpp-bcs-progress-fill {
    height: 100%;
    background: #2271b1;
    width: 0%;
    transition: width 0.2s;
}

/* Action buttons row */
.tbpp-bcs-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 12px;
}

.tbpp-bcs-actions button,
.tbpp-bcs-actions label.tbpp-bcs-file-label {
    flex: 1 1 auto;
    min-width: 120px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid #c3c4c7;
    background: #f6f7f7;
    color: #2c3338;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.tbpp-bcs-actions button:hover,
.tbpp-bcs-actions label.tbpp-bcs-file-label:hover {
    background: #f0f0f1;
    border-color: #8c8f94;
}

.tbpp-bcs-actions button.is-primary {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.tbpp-bcs-actions button.is-primary:hover {
    background: #135e96;
    border-color: #135e96;
}

.tbpp-bcs-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tbpp-bcs-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

/* Result preview after parsing */
.tbpp-bcs-results {
    margin-top: 12px;
    padding: 12px;
    background: #f0f6fc;
    border-radius: 6px;
    border: 1px solid #c3d4e8;
    font-size: 13px;
    display: none;
}

.tbpp-bcs-results.is-visible {
    display: block;
}

.tbpp-bcs-results h3 {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
}

.tbpp-bcs-results dl {
    margin: 0;
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 4px 12px;
}

.tbpp-bcs-results dt {
    font-weight: 500;
    color: #50575e;
}

.tbpp-bcs-results dd {
    margin: 0;
    color: #1d2327;
    word-break: break-word;
}

.tbpp-bcs-results dd.is-empty {
    color: #a7aaad;
    font-style: italic;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .tbpp-bcs-modal {
        padding: 0;
        align-items: stretch;
    }
    .tbpp-bcs-modal-content {
        border-radius: 0;
        max-height: 100vh;
        max-height: 100dvh;
        height: 100vh;
        height: 100dvh;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .tbpp-bcs-modal-header {
        padding-top: max(12px, env(safe-area-inset-top, 12px));
    }
    .tbpp-bcs-actions button,
    .tbpp-bcs-actions label.tbpp-bcs-file-label {
        flex: 1 1 100%;
    }
}
