/* FinBizTools - Documents, PDF & Image Tools Styles */

.fbt-document-tool {
    border: 1px solid #d9e5df;
    border-radius: 20px;
    padding: clamp(16px, 3vw, 32px);
    background: #ffffff;
    max-width: 100%;
    min-width: 0;
    margin: 24px 0;
    box-sizing: border-box;
    font-family: inherit;
    color: #183c30;
}

.fbt-document-tool * {
    box-sizing: border-box;
}

/* Privacy Badge */
.fbt-privacy-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #edf6f0;
    border: 1px solid #c2dece;
    border-radius: 10px;
    margin-bottom: 24px;
    font-size: 0.92rem;
    color: #1b4b38;
    line-height: 1.4;
}

.fbt-privacy-badge .fbt-privacy-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Form Controls */
.fbt-document-tool form {
    margin-bottom: 24px;
}

.fbt-document-tool label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #183c30;
}

.fbt-document-tool input[type="text"],
.fbt-document-tool input[type="number"],
.fbt-document-tool select {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid #bccfc4;
    border-radius: 8px;
    font: inherit;
    background: #ffffff;
    color: #183c30;
}

.fbt-document-tool input[type="range"] {
    width: 100%;
    margin: 8px 0;
    accent-color: #23764c;
}

.fbt-document-tool [hidden] {
    display: none !important;
}

.fbt-document-tool .fbt-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 16px;
    margin: 20px 0;
}

/* Dropzone */
.fbt-dropzone {
    border: 2px dashed #9cbcae;
    border-radius: 14px;
    padding: clamp(24px, 4vw, 40px) 20px;
    text-align: center;
    background: #fafcfb;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    outline: none;
}

.fbt-dropzone:hover,
.fbt-dropzone:focus-visible,
.fbt-dropzone.is-dragover {
    border-color: #23764c;
    background: #f0f7f3;
}

.fbt-dropzone:focus-visible {
    outline: 3px solid #ad6700;
    outline-offset: 2px;
}

.fbt-dropzone-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: block;
}

.fbt-dropzone-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: #183c30;
    margin-bottom: 6px;
}

.fbt-dropzone-btn {
    display: inline-block;
    color: #23764c;
    text-decoration: underline;
    font-weight: 700;
    cursor: pointer;
}

.fbt-dropzone-hint {
    font-size: 0.85rem;
    color: #557265;
    margin-top: 8px;
}

/* File Previews & List */
.fbt-file-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.fbt-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: #f4f8f5;
    border: 1px solid #d9e5df;
    border-radius: 10px;
}

.fbt-file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.fbt-file-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    background: #e0e8e3;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.fbt-file-meta {
    min-width: 0;
    flex: 1;
}

.fbt-file-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fbt-file-size {
    font-size: 0.82rem;
    color: #557265;
}

.fbt-file-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.fbt-icon-btn {
    background: #ffffff;
    border: 1px solid #bccfc4;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #183c30;
    min-height: 36px;
    min-width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.fbt-icon-btn:hover:not(:disabled) {
    background: #edf6f0;
    border-color: #23764c;
}

.fbt-icon-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Compare / Metrics Grid */
.fbt-compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 16px;
    margin: 20px 0;
}

.fbt-compare-card {
    padding: 20px;
    border-radius: 14px;
    background: #f4f8f5;
    border: 1px solid #d9e5df;
    text-align: center;
}

.fbt-compare-card.fbt-result-card {
    background: #edf6f0;
    border-color: #9cbcae;
}

.fbt-compare-title {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #557265;
    margin-bottom: 8px;
}

.fbt-compare-size {
    font-size: 1.8rem;
    font-weight: 800;
    color: #183c30;
    margin-bottom: 6px;
}

.fbt-compare-meta {
    font-size: 0.88rem;
    color: #557265;
}

.fbt-saved-badge {
    display: inline-block;
    margin-top: 10px;
    padding: 4px 12px;
    background: #23764c;
    color: #ffffff;
    font-size: 0.88rem;
    font-weight: 700;
    border-radius: 20px;
}

.fbt-saved-badge.fbt-no-savings {
    background: #829b8b;
}

/* Crop Stage & Box */
.fbt-crop-wrapper {
    margin: 20px 0;
}

.fbt-crop-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.fbt-crop-stage {
    position: relative;
    max-width: 100%;
    max-height: 520px;
    overflow: hidden;
    background: #e5ece8;
    background-image: 
        linear-gradient(45deg, #d3ded7 25%, transparent 25%), 
        linear-gradient(-45deg, #d3ded7 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #d3ded7 75%), 
        linear-gradient(-45deg, transparent 75%, #d3ded7 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    border-radius: 12px;
    user-select: none;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fbt-crop-img {
    display: block;
    max-width: 100%;
    max-height: 520px;
    width: auto;
    height: auto;
    pointer-events: none;
}

.fbt-crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

.fbt-crop-box {
    position: absolute;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    cursor: move;
    touch-action: none;
}

.fbt-crop-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #ffffff;
    border: 2px solid #23764c;
    border-radius: 50%;
    touch-action: none;
}

.fbt-crop-handle.handle-nw { top: -8px; left: -8px; cursor: nwse-resize; }
.fbt-crop-handle.handle-ne { top: -8px; right: -8px; cursor: nesw-resize; }
.fbt-crop-handle.handle-se { bottom: -8px; right: -8px; cursor: nwse-resize; }
.fbt-crop-handle.handle-sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.fbt-crop-handle.handle-n  { top: -8px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.fbt-crop-handle.handle-s  { bottom: -8px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.fbt-crop-handle.handle-w  { left: -8px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.fbt-crop-handle.handle-e  { right: -8px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

/* PDF Page Grid */
.fbt-page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
    margin: 20px 0;
}

.fbt-page-card {
    border: 1px solid #cbdcd1;
    border-radius: 10px;
    padding: 8px;
    background: #ffffff;
    text-align: center;
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.fbt-page-thumb {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: #f8fbf9;
    border-radius: 6px;
    display: block;
    margin-bottom: 8px;
}

.fbt-page-card label {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    cursor: pointer;
}

/* Progress Bar */
.fbt-progress-wrap {
    margin: 20px 0;
    padding: 16px;
    background: #edf6f0;
    border-radius: 10px;
    border: 1px solid #c2dece;
}

.fbt-progress-label {
    font-weight: 600;
    font-size: 0.92rem;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.fbt-progress-bar {
    width: 100%;
    height: 10px;
    background: #cce0d5;
    border-radius: 5px;
    overflow: hidden;
}

.fbt-progress-fill {
    height: 100%;
    width: 0%;
    background: #23764c;
    border-radius: 5px;
    transition: width 0.2s ease-out;
}

/* Action Buttons */
.fbt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 24px 0 12px;
}

.fbt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    min-height: 48px;
    text-decoration: none;
    line-height: 1.2;
}

.fbt-btn-primary {
    background: #23764c;
    color: #ffffff !important;
}

.fbt-btn-primary:hover:not(:disabled) {
    background: #1a5c3a;
}

.fbt-btn-secondary {
    background: #edf6f0;
    color: #183c30 !important;
    border: 1px solid #bccfc4;
}

.fbt-btn-secondary:hover:not(:disabled) {
    background: #dbebe1;
    border-color: #23764c;
}

.fbt-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Status & Errors */
.fbt-error {
    color: #a62525;
    background: #fdf2f2;
    border: 1px solid #f2c7c7;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 16px 0;
    font-weight: 600;
    font-size: 0.92rem;
}

.fbt-error:empty {
    display: none;
}

.fbt-success-notice {
    color: #1b4b38;
    background: #edf6f0;
    border: 1px solid #c2dece;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 16px 0;
    font-weight: 600;
    font-size: 0.92rem;
}

/* Responsive */
@media (max-width: 640px) {
    .fbt-document-tool {
        padding: 16px;
        border-radius: 14px;
    }
    .fbt-document-tool .fbt-fields {
        grid-template-columns: 1fr;
    }
    .fbt-actions {
        flex-direction: column;
    }
    .fbt-btn {
        width: 100%;
    }
    .fbt-page-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

