/* ==========================================================================
   DPI Changer - UnitConverterTool.com
   Silo: Image Tools   Accent: #4a90ff   Hover: #3a7fee
   Self-contained. Built to tool-build.md sections 1 and 3.
   No slider, no tabs, no aspect lock in this tool, so that CSS is not carried.
   ========================================================================== */

/* ---- 3a. ROOT AND HEADING ---- */
.uct-tool {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    font-family: 'DM Sans', sans-serif;
    color: #e5e7eb;
}
.uct-tool_heading { text-align: center; margin-bottom: 28px; }
.uct-tool_heading h1 { font-size: 32px; font-weight: 700; color: #fff; margin: 0 0 10px; }
.uct-tool_description { font-size: 15px; color: #9ca3af; margin: 0; line-height: 1.6; }

/* ---- 3b. LAYOUT ---- */
.uct-tool-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
    align-items: start;
}
@media (max-width: 1024px) {
    .uct-tool-layout { grid-template-columns: 1fr; }
}

/* ---- 3c. UPLOAD AREA ---- */
.uct-upload-area {
    background: #1a1f2e;
    border: 2px dashed #3a4258;
    border-radius: 12px;
    padding: 40px 24px;
    text-align: center;
    transition: border-color .2s ease, background .2s ease;
}
.uct-upload-area.drag-over { border-color: #4a90ff; background: #1e2538; }
.uct-upload-area h3 { font-size: 18px; font-weight: 600; color: #e5e7eb; margin: 16px 0 6px; }
.uct-upload-area p { font-size: 14px; color: #9ca3af; margin: 0 0 14px; }
.upload-icon svg { stroke: #4a90ff; }
.uct-hidden-input { display: none; }
.uct-tool_drop-text { font-size: 13px; color: #6b7280; margin-top: 14px; }

.uct-trust-strip {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 16px;
    margin-top: 18px; padding-top: 16px; border-top: 1px solid #2a3348;
}
.uct-trust-strip span { font-size: 12px; color: #9ca3af; }

/* #6b7280 is only 3.96:1 on #0A0F1C and fails WCAG AA, so helper text is #9ca3af. */
.uct-helper-text { font-size: 13px; color: #9ca3af; margin: 10px 0 0; line-height: 1.6; }
/* .uct-upload-area p (above) outranks .uct-helper-text and would zero its top
   margin, leaving the import helper text touching the Select Images button.
   This more specific rule restores the intended gap. */
.uct-upload-area .uct-helper-text { margin: 14px 0 0; }

/* ---- 3d. CLOUD SPLIT BUTTON ---- */
.uct-dropdown-container { position: relative; display: inline-block; }
.uct-split-btn-group { display: flex; }

.uct-btn-main {
    background: #4a90ff; color: #fff; border: none;
    padding: 12px 22px; border-radius: 8px 0 0 8px;
    font-family: inherit; font-size: 15px; font-weight: 600;
    cursor: pointer; min-height: 44px; transition: background .15s ease;
}
.uct-btn-main:hover { background: #3a7fee; }

.uct-btn-arrow {
    background: #4a90ff; color: #fff;
    border: none; border-left: 1px solid rgba(255,255,255,.2);
    padding: 12px 14px; border-radius: 0 8px 8px 0;
    cursor: pointer; min-height: 44px; display: flex; align-items: center;
}
.uct-btn-arrow:hover { background: #3a7fee; }

.uct-dropdown-menu {
    display: none; position: absolute; top: calc(100% + 6px); left: 0;
    min-width: 220px; background: #252d3f; border: 1px solid #3a4258;
    border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
    z-index: 30; overflow: hidden;
}
.uct-dropdown-menu.show { display: block; }

.uct-dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; min-height: 44px;
    font-size: 14px; color: #e5e7eb; cursor: pointer;
    transition: background .12s ease;
}
.uct-dropdown-item:hover { background: #1e2538; }
.uct-dropdown-item svg { flex-shrink: 0; }

/* ---- 3e. OPTIONS PANEL, SUB-PANEL, INPUTS, PRESETS ---- */
.uct-options-panel {
    background: #1a1f2e; border: 1px solid #3a4258; border-radius: 12px;
    overflow: hidden;
}
.uct-options-toggle {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; min-height: 44px; cursor: pointer; user-select: none;
}
.uct-options-toggle-left {
    display: flex; align-items: center; gap: 8px;
    font-size: 15px; font-weight: 600; color: #e5e7eb;
}
.uct-options-toggle-arrow { color: #9ca3af; transition: transform .2s ease; }
.uct-options-panel.collapsed .uct-options-toggle-arrow { transform: rotate(-90deg); }

.uct-options-summary { font-size: 12px; font-weight: 400; color: #9ca3af; }

.uct-options-body {
    max-height: 2000px; overflow: hidden;
    transition: max-height .25s ease, padding .25s ease;
    padding: 0 18px 18px;
}
.uct-options-panel.collapsed .uct-options-body {
    max-height: 0; padding-top: 0; padding-bottom: 0;
}

.uct-options-section { padding-top: 16px; }
.uct-options-section + .uct-options-section {
    margin-top: 16px; border-top: 1px solid #2a3348;
}
.uct-options-section-label {
    display: flex; align-items: center; gap: 7px;
    font-size: 13px; font-weight: 600; color: #9ca3af;
    text-transform: uppercase; letter-spacing: .04em; margin-bottom: 12px;
}

/* SUB-PANEL - holds the custom DPI input, revealed by the Custom preset card */
.uct-subpanel { display: none; margin-top: 14px; }
.uct-subpanel.active { display: block; }
.uct-subpanel-title { font-size: 13px; font-weight: 600; color: #e5e7eb; margin-bottom: 10px; }

/* NUMBER INPUT */
.uct-input-row { display: flex; align-items: flex-end; gap: 10px; }
.uct-input-group { flex: 1; }
.uct-input-group label {
    display: block; font-size: 12px; color: #9ca3af; margin-bottom: 5px;
}
.uct-input-group input,
.uct-input-field {
    width: 100%; box-sizing: border-box;
    background: #1e2538; border: 1px solid #3a4258; border-radius: 6px;
    padding: 10px 12px; min-height: 44px;
    font-family: inherit; font-size: 14px; color: #e5e7eb;
}
.uct-input-group input:focus,
.uct-input-field:focus { outline: none; border-color: #4a90ff; }

/* PRESET CARDS */
.uct-preset-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px;
}
.uct-preset-card {
    background: #252d3f; border: 1px solid #3a4258; border-radius: 8px;
    padding: 10px; text-align: center; cursor: pointer; transition: all .15s ease;
    min-height: 44px;
}
.uct-preset-card:hover { border-color: #4a90ff; }
.uct-preset-card.selected { background: #1e2538; border-color: #4a90ff; }
.uct-preset-name { font-size: 13px; font-weight: 600; color: #e5e7eb; }
.uct-preset-dims { font-size: 11px; color: #6b7280; margin-top: 2px; }

/* ---- 3f. ACTIONS ---- */
.uct-action-btn-primary {
    width: 100%; margin-top: 14px; min-height: 52px;
    background: #1a2542; color: #fff;
    border: 1px solid #4a90ff; border-radius: 10px;
    font-family: inherit; font-size: 16px; font-weight: 700;
    cursor: pointer; transition: background .15s ease;
}
.uct-action-btn-primary:hover:not(:disabled) { background: #222f52; }
.uct-action-btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.uct-action-btn-primary.is-busy { pointer-events: none; opacity: .7; }
.uct-action-btn-primary.is-busy::after {
    content: ''; display: inline-block; margin-left: 10px;
    width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
    animation: uct-spin .7s linear infinite; vertical-align: middle;
}
@keyframes uct-spin { to { transform: rotate(360deg); } }

.uct-controls-area {
    display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 22px 0;
}
.uct-action-btn {
    background: #4a90ff; color: #fff; border: none; border-radius: 8px;
    padding: 12px 22px; min-height: 44px;
    font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.uct-action-btn:hover:not(:disabled) { background: #3a7fee; }
.uct-action-btn:disabled { opacity: .5; cursor: not-allowed; }

.uct-secondary-btn, .uct-rerun-btn {
    background: transparent; color: #9ca3af;
    border: 1px solid #3a4258; border-radius: 8px;
    padding: 12px 22px; min-height: 44px;
    font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.uct-secondary-btn:hover, .uct-rerun-btn:hover { border-color: #4a90ff; color: #e5e7eb; }

/* STICKY PRIMARY ACTION ON MOBILE.
   position:sticky does not work here: the button's parent ends long before the
   viewport does, so it stops sticking. position:fixed is the only thing that
   keeps it reachable. Only once there is something to act on. */
@media (max-width: 768px) {
    .uct-tool.uct-has-input .uct-action-btn-primary {
        position: fixed; left: 16px; right: 16px; bottom: 16px;
        width: auto; z-index: 40; box-shadow: 0 6px 20px rgba(0,0,0,.5);
    }
    .uct-tool.uct-has-input .uct-results,
    .uct-tool.uct-has-input .uct-output-note,
    .uct-tool.uct-has-input .uct-privacy-note { padding-bottom: 80px; }
}

/* ---- 3g. RESULTS ---- */
.uct-file-item {
    background: #1a1f2e; border: 1px solid #3a4258; border-radius: 10px;
    padding: 14px; margin-bottom: 10px;
}
.uct-file-item-row { display: flex; align-items: center; gap: 14px; }
.uct-file-thumb {
    width: 56px; height: 56px; flex-shrink: 0;
    background: #252d3f; border-radius: 6px; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.uct-file-thumb canvas, .uct-file-thumb img { max-width: 100%; max-height: 100%; }
.uct-file-info { flex: 1; min-width: 0; }
.uct-file-name {
    font-size: 14px; font-weight: 600; color: #e5e7eb;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.uct-file-meta { font-size: 12px; color: #9ca3af; margin-top: 3px; }
.uct-file-status { font-size: 12px; color: #9ca3af; margin-top: 3px; }

.uct-progress-bar {
    height: 4px; background: #2a3348; border-radius: 2px;
    overflow: hidden; margin-top: 7px;
}
.uct-progress-fill {
    height: 100%; width: 0; background: #4a90ff; transition: width .2s ease;
}

.uct-size-compare { font-size: 12px; margin-top: 4px; line-height: 1.5; }
.uct-size-decreased { color: #4ade80; }
.uct-size-increased { color: #fbbf24; }
.uct-size-same { color: #9ca3af; }

.uct-action-area { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.uct-download-link {
    background: #4a90ff; color: #fff; text-decoration: none;
    padding: 8px 16px; min-height: 44px; border-radius: 6px;
    display: inline-flex; align-items: center;
    font-size: 13px; font-weight: 600;
}
.uct-download-link:hover { background: #3a7fee; color: #fff; }

/* ---- 3h. MESSAGES, NOTES, UTILITY ---- */
.uct-error-msg {
    background: rgba(192,57,43,.12); border: 1px solid #c0392b; border-radius: 8px;
    padding: 12px 16px; margin-bottom: 10px; font-size: 13px; color: #e5e7eb;
    line-height: 1.6;
}
.uct-error-text { color: #c0392b; font-size: 12px; }

.uct-output-note, .uct-privacy-note {
    font-size: 12px; color: #9ca3af; text-align: center;
    line-height: 1.6; margin: 14px 0 0;
}
.uct-hidden { display: none !important; }

.uct-tool a:not(.uct-download-link):not(.uct-action-btn) { color: #4a90ff; }

/* ---- 3h-cloud. URL-IMPORT MODAL (injected by cloud-handlers.js) ---- */
.uct-modal-overlay {
    position: fixed; inset: 0; z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    padding: 20px; background: rgba(0,0,0,.66);
}
.uct-modal-content {
    width: 100%; max-width: 460px;
    background: #111B2E; border: 1px solid #26324a; border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,.5); overflow: hidden;
}
.uct-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; border-bottom: 1px solid #26324a;
}
.uct-modal-header h3 { margin: 0; font-size: 16px; color: #e5e7eb; }
.uct-modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 22px; line-height: 1; color: #9ca3af; padding: 4px 8px;
}
.uct-modal-close:hover { color: #e5e7eb; }
.uct-modal-body { padding: 18px; }
.uct-modal-info { margin: 0 0 12px; font-size: 13px; color: #9ca3af; line-height: 1.6; }
.uct-modal-note { margin: 10px 0 0; font-size: 12px; color: #9ca3af; line-height: 1.6; }
.uct-modal-footer {
    display: flex; gap: 10px; justify-content: flex-end;
    padding: 14px 18px; border-top: 1px solid #26324a;
}
@media (max-width: 480px) {
    .uct-modal-footer { flex-direction: column-reverse; }
    .uct-modal-footer .uct-action-btn,
    .uct-modal-footer .uct-secondary-btn { width: 100%; }
}

/* ---- 3i. MOBILE ---- */
@media (max-width: 768px) {
    .uct-tool { padding: 0 16px; overflow-x: hidden; }
    .uct-tool_heading h1 { font-size: 24px; }
    .uct-upload-area { padding: 28px 16px; }
    .uct-file-item-row { flex-wrap: wrap; }
    .uct-action-area { width: 100%; }
    .uct-download-link { flex: 1; justify-content: center; }
    .uct-preset-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}
@media (max-width: 480px) {
    .uct-tool_heading h1 { font-size: 21px; }
    .uct-trust-strip { flex-direction: column; gap: 7px; }
    .uct-input-row { flex-wrap: wrap; }
}
