/* Custom Font Integration — identical to app-file-compressor.css */
@font-face {
    font-family: 'Nunito Sans';
    src: url('fonts/Geist-Regular.woff2') format('woff2');
    font-weight: normal;
}

@font-face {
    font-family: 'Gabarito';
    src: url('fonts/JetBrainsMono-Regular.woff2') format('woff2');
    font-weight: normal;
}

:root {
    --primary-blue: #0062ff;
    --black: #000000;
    --white: #ffffff;
    --light-blue: #f0f6ff;
    --gray: #e0e0e0;
    --green: #16a34a;
    --amber: #b45309;
}

/* Scoped Reset: Only affects elements inside the app-card */
.app-card * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.app-card {
    font-family: 'Nunito Sans', sans-serif;
    background-color: var(--white);
    color: var(--black);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    width: 100%;
    text-align: center;
    padding: 40px 0;
}

.app-card header {
    margin-bottom: 32px;
    padding: 0 20px;
}

.app-card h1 {
    font-family: 'Gabarito', sans-serif;
    color: var(--primary-blue);
    letter-spacing: -1px;
    margin-bottom: 8px;
    text-align: center;
    white-space: nowrap;
    display: block;
    width: 100%;
    font-size: clamp(1rem, 6vw, 2.5rem);
}

.app-card h1 span { color: #000; }

.app-card p.subtitle {
    font-size: 1rem;
    opacity: 0.7;
}

.app-card .upload-container {
    border: 3px dashed var(--primary-blue);
    border-radius: 16px;
    padding: 50px 30px;
    cursor: pointer;
    transition: 0.3s;
    width: 50%;
    margin: 0 auto;
}

.app-card .upload-container:hover {
    background-color: var(--light-blue);
}

.app-card .upload-container svg {
    color: var(--primary-blue);
    margin-bottom: 15px;
}

#fileInput { display: none; }

#loadingWrapper {
    display: none;
    margin-top: 24px;
    text-align: center;
}

.spinner-ring {
    display: inline-block;
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner-label {
    margin-top: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-blue);
}

.btn {
    display: inline-block;
    width: calc(100% - 40px);
    max-width: 400px;
    background-color: var(--primary-blue);
    color: var(--white);
    padding: 18px;
    font-family: 'Gabarito', sans-serif;
    font-weight: 700;
    margin-top: 24px;
    border-radius: 12px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

#status {
    margin-top: 20px;
    font-weight: 600;
    color: var(--primary-blue);
    padding: 0 20px;
}

/* ── Resize controls: width/height inputs + aspect lock ─────────────────────── */
.dimension-controls {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 24px;
    width: 50%;
    margin-left: auto;
    margin-right: auto;
}

.dimension-field {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.dimension-field label {
    font-size: 0.8rem;
    font-weight: 700;
    opacity: 0.7;
    text-align: left;
}

.dimension-field input[type="number"] {
    width: 110px;
    padding: 12px 14px;
    border: 2px solid var(--gray);
    border-radius: 10px;
    font-family: 'Nunito Sans', sans-serif;
    font-size: 1rem;
    color: var(--black);
}

.dimension-field input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-blue);
}

.dimension-x {
    padding-bottom: 12px;
    font-weight: 700;
    opacity: 0.5;
}

.lock-aspect {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.lock-aspect input { width: 16px; height: 16px; }

.icon-link {
    flex-shrink: 0;
    color: var(--primary-blue);
}

#resizeBtn { max-width: 320px; }

/* ── Stretch vs Crop mode toggle ─────────────────────────────────────────────── */
.fit-mode-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.fit-mode-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.fit-mode-option input { width: 16px; height: 16px; cursor: pointer; }

.fit-mode-hint {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 6px;
    width: 100%;
    text-align: center;
}

/* ── Crop stage: drag-to-reposition crop window ─────────────────────────────── */
.crop-stage {
    display: none;
    margin: 20px auto 0;
    width: 50%;
    max-width: 420px;
    text-align: center;
}

.crop-stage-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
    margin-bottom: 10px;
}

.crop-image-wrap {
    position: relative;
    margin: 0 auto;
    overflow: hidden;
    background: #000;
    border-radius: 12px;
    line-height: 0;
    touch-action: none;
}

.crop-image-wrap img {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

.crop-window {
    position: absolute;
    top: 0;
    left: 0;
    border: 2px solid var(--primary-blue);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    box-sizing: border-box;
    cursor: move;
    touch-action: none;
}

.crop-hint {
    font-size: 0.8rem;
    opacity: 0.65;
    margin-top: 10px;
}

/* ── Before / after preview ──────────────────────────────────────────────────── */
#previewContainer {
    width: 70%;
    margin: 30px auto;
    display: none;
    padding: 20px;
    background: #000;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    text-align: center;
}

.preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

@media (max-width: 640px) {
    .preview-grid { grid-template-columns: 1fr; }
    .dimension-controls, .app-card .upload-container, #previewContainer, .crop-stage { width: 90%; }
}

.preview-pane {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preview-pane-label {
    color: var(--white);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.preview-pane img {
    width: 100%;
    max-height: 260px;
    object-fit: contain;
    border-radius: 8px;
    display: block;
    background: repeating-conic-gradient(#2a2a2a 0% 25%, #1a1a1a 0% 50%) 50% / 16px 16px;
}

.resize-placeholder {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    line-height: 1.5;
    padding: 40px 12px;
}

.preview-dims {
    color: var(--white);
    font-size: 0.75rem;
    opacity: 0.65;
}

.resize-badge {
    display: block;
    width: fit-content;
    margin: 18px auto 0;
    padding: 4px 14px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-align: center;
}

.resize-badge.up   { background: var(--light-blue); color: var(--primary-blue); }
.resize-badge.down { background: #ecfdf3; color: var(--green); }
.resize-badge.same { background: var(--gray); color: #444; }

.error {
    color: red;
}
