/* ============================================================
   DIU TOOLS HUB - IMAGE RESIZER & PASSPORT PHOTO CROP STUDIO
   Matches XnTools Reference Design & Architecture
   ============================================================ */

/* Full tool flow wrapper */
#pdf-flow-imageresizer {
    width: 100%;
    min-height: 100vh;
    background: #060913;
    color: #f8fafc;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Centered modern app container */
.imageresizer-workspace {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 20px 60px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@media (max-width: 899px) {
    .imageresizer-workspace {
        max-width: 680px;
        padding: 12px 14px 48px;
        gap: 14px;
    }
}

@media (max-width: 520px) {
    .imageresizer-workspace {
        padding: 10px 10px 40px;
        gap: 12px;
    }
}

/* Header bar */
.imageresizer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding-bottom: 4px;
}

.imageresizer-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.imageresizer-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    border-radius: 9999px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.28);
    color: #fbbf24;
    font-size: 12px;
    font-weight: 700;
}

.imageresizer-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 8px #f59e0b;
}

/* Upload Dropzone */
.imageresizer-dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    padding: 56px 24px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    transition: all 0.2s ease;
    width: 100%;
    max-width: 680px;
    margin: 20px auto 40px;
    box-sizing: border-box;
}

@media (max-width: 520px) {
    .imageresizer-dropzone {
        padding: 36px 16px;
        margin: 10px auto 20px;
    }
}

/* Dynamic Studio Section */
.imageresizer-studio-section {
    width: 100%;
    box-sizing: border-box;
    animation: fadeInStudio 0.25s ease-out;
}

@keyframes fadeInStudio {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.imageresizer-studio-layout {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(380px, 1.25fr);
    gap: 20px;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 899px) {
    .imageresizer-studio-layout {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }
}

.imageresizer-left-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.imageresizer-right-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 900px) {
    .imageresizer-right-col {
        position: sticky;
        top: 16px;
    }
}

.imageresizer-dropzone:hover,
.imageresizer-dropzone.drag-active {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.05);
    transform: translateY(-2px);
}

.imageresizer-dropzone-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.25);
    display: grid;
    place-items: center;
    color: #38bdf8;
    flex-shrink: 0;
}

.imageresizer-dropzone-title {
    color: #f8fafc;
    font-size: 15px;
    font-weight: 800;
    word-break: break-word;
}

.imageresizer-dropzone-desc {
    color: #94a3b8;
    font-size: 11.5px;
    margin-top: 3px;
    line-height: 1.4;
    word-break: break-word;
}

.imageresizer-dropzone-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 8px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #10b981;
    font-size: 11px;
    font-weight: 700;
    max-width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
    line-height: 1.3;
}

/* File bar */
.imageresizer-filebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
    gap: 8px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .imageresizer-filebar {
        padding: 6px 10px;
        gap: 6px;
    }
}

.imageresizer-filebar-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.imageresizer-filebar-badge {
    padding: 2.5px 6px;
    border-radius: 5px;
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    white-space: nowrap;
}

.imageresizer-orig-dim {
    font-size: 11.5px;
    color: #f8fafc;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 420px) {
    .imageresizer-orig-dim {
        font-size: 11px;
    }
}

.imageresizer-filebar-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 700;
    color: #f8fafc;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.imageresizer-filebar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Category navigation */
.imageresizer-category-nav {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    padding: 5px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    box-sizing: border-box;
}

.imageresizer-category-nav::-webkit-scrollbar {
    display: none;
}

.imageresizer-cat-btn {
    flex: 0 0 auto;
    padding: 7px 14px;
    border-radius: 10px;
    background: transparent;
    color: #94a3b8;
    border: none;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.imageresizer-cat-btn:hover {
    color: #f8fafc;
}

.imageresizer-cat-btn.active {
    background: #f59e0b;
    color: #040912;
    box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
}

/* Preset Cards Grid */
.imageresizer-template-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 520px) {
    .imageresizer-template-grid {
        grid-template-columns: 1fr;
    }
}

.imageresizer-tpl-card {
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: all 0.15s ease;
    min-width: 0;
    box-sizing: border-box;
}

@media (max-width: 520px) {
    .imageresizer-tpl-card {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "title badge"
            "sub badge";
        align-items: center;
        gap: 2px 8px;
        padding: 9px 12px;
    }

    .imageresizer-tpl-title {
        grid-area: title;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .imageresizer-tpl-sub {
        grid-area: sub;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .imageresizer-tpl-badge {
        grid-area: badge;
        margin-top: 0 !important;
        align-self: center !important;
        white-space: nowrap;
        flex-shrink: 0;
    }
}

.imageresizer-tpl-card:hover {
    border-color: rgba(56, 189, 248, 0.4);
    background: rgba(56, 189, 248, 0.04);
}

.imageresizer-tpl-card.selected {
    background: rgba(56, 189, 248, 0.08);
    border-color: #38bdf8;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.22);
}

.imageresizer-tpl-title {
    font-size: 12px;
    font-weight: 800;
    color: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.imageresizer-tpl-card.selected .imageresizer-tpl-title {
    color: #f59e0b;
}

.imageresizer-tpl-sub {
    font-size: 11px;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.imageresizer-tpl-badge {
    display: inline-flex;
    align-self: flex-start;
    margin-top: 2px;
    font-size: 10.5px;
    font-weight: 800;
    padding: 2.5px 7px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.08);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.imageresizer-tpl-card.selected .imageresizer-tpl-badge {
    background: #38bdf8;
    color: #040912;
    border: none;
    font-weight: 800;
}

/* Custom Dimensions panel */
.imageresizer-custom-panel {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}

.imageresizer-input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
}

.imageresizer-input-field label {
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 3px;
}

.imageresizer-input-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 9px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-size: 13.5px;
    font-weight: 700;
    outline: none;
    transition: border-color 0.15s;
}

.imageresizer-input-field input:focus {
    border-color: #38bdf8;
}

.imageresizer-lock-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: 12px;
    color: #f8fafc;
    font-weight: 600;
}

.imageresizer-lock-toggle input {
    accent-color: #38bdf8;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Stage & Canvas container */
.imageresizer-stage-card {
    background: #080c16;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.imageresizer-stage-hint {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #94a3b8;
    gap: 8px;
    flex-wrap: wrap;
}

.imageresizer-target-badge {
    color: #38bdf8;
    font-weight: 700;
    white-space: nowrap;
}

.imageresizer-canvas-viewport {
    width: 100%;
    min-height: 260px;
    max-height: 440px;
    display: grid;
    place-items: center;
    cursor: grab;
    touch-action: none;
    padding: 8px;
    box-sizing: border-box;
    background: radial-gradient(circle at center, #101524 0%, #070a12 100%);
    overflow: hidden;
}

.imageresizer-canvas-viewport.grabbing {
    cursor: grabbing;
}

.imageresizer-canvas-viewport canvas {
    max-width: 100%;
    height: auto;
    max-height: 380px;
    border-radius: 8px;
    display: block;
}

/* Stage Toolbar */
.imageresizer-stage-toolbar {
    width: 100%;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.imageresizer-zoom-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.imageresizer-zoom-row input[type="range"] {
    flex: 1;
    accent-color: #38bdf8;
    cursor: pointer;
}

.imageresizer-zoom-val {
    font-size: 11px;
    font-weight: 800;
    color: #38bdf8;
    min-width: 36px;
    text-align: right;
}

.imageresizer-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

.imageresizer-btn-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.imageresizer-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.imageresizer-tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.imageresizer-tool-btn.active {
    background: rgba(56, 189, 248, 0.18);
    border-color: #38bdf8;
    color: #38bdf8;
}

.imageresizer-tool-btn.guide-active {
    background: rgba(16, 185, 129, 0.18);
    border-color: #10b981;
    color: #10b981;
}

.imageresizer-bg-swatches {
    display: flex;
    align-items: center;
    gap: 6px;
}

.imageresizer-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    transition: all 0.15s;
    outline: none;
    flex-shrink: 0;
}

.imageresizer-swatch.active {
    border: 2px solid #38bdf8;
    transform: scale(1.15);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
}

/* ============================================================
   Output Format & Limits Panel (Matches XnTools Reference Card)
   ============================================================ */
.imageresizer-limits-panel {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}

.imageresizer-limits-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.imageresizer-limits-title {
    font-size: 11px;
    font-weight: 800;
    color: #64748b;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.imageresizer-fmt-group {
    display: flex;
    gap: 4px;
}

.imageresizer-fmt-btn {
    padding: 5px 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
}

.imageresizer-fmt-btn.active {
    background: #38bdf8;
    color: #040912;
    border: none;
}

.imageresizer-maxkb-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

.imageresizer-kb-chips {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.imageresizer-kb-chip {
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11.5px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
}

.imageresizer-kb-chip.active {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid #38bdf8;
}

/* ============================================================
   Action Buttons (Crop & Download)
   ============================================================ */
.imageresizer-btn-execute {
    width: 100%;
    height: 48px;
    border-radius: 14px;
    border: none;
    background: #38bdf8;
    color: #040912;
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(56, 189, 248, 0.35);
    transition: all 0.2s;
    box-sizing: border-box;
    padding: 0 14px;
    text-align: center;
}

.imageresizer-btn-execute:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(56, 189, 248, 0.5);
}

.imageresizer-btn-execute:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Download Result Box */
.imageresizer-result-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: 16px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

.imageresizer-result-thumb {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: #ffffff;
    flex-shrink: 0;
}

.imageresizer-result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.imageresizer-result-status {
    color: #10b981;
    font-size: 13px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 5px;
}

.imageresizer-result-dim {
    color: #f8fafc;
    font-size: 12px;
    font-weight: 700;
}

.imageresizer-result-weight {
    color: #94a3b8;
    font-size: 11px;
}

.imageresizer-result-weight strong {
    color: #f8fafc;
}

.imageresizer-btn-download {
    width: 100%;
    height: 48px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(16, 185, 129, 0.35);
    transition: all 0.2s;
    box-sizing: border-box;
}

.imageresizer-btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.imageresizer-btn-reedit {
    width: 100%;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: #94a3b8;
    font-size: 11.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s;
    box-sizing: border-box;
}

.imageresizer-btn-reedit:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
}

/* Privacy footer pill */
.imageresizer-privacy-pill {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.4;
    width: 100%;
    box-sizing: border-box;
}
