/* =========================================
   ABYSS NEXUS LAB
   IMAGE CROPPER
   ========================================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #08090d;
    --surface: #101218;
    --surface-2: #151821;
    --border: #252a36;
    --text: #f3f5f7;
    --muted: #9299a8;
    --accent: #5ca8ff;
    --accent-hover: #78b7ff;
    --danger: #ff5f6d;
    --success: #4ade80;
}

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}


/* =========================================
   HEADER
   ========================================= */

.tool-header {
    width: 100%;
    border-bottom: 1px solid var(--border);
    background: rgba(8, 9, 13, 0.96);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(14px);
}

.header-inner {
    max-width: 1180px;
    margin: auto;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 18px;
}

.back-button {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    padding: 9px 14px;
    border-radius: 10px;
    font-size: 14px;
    transition: 0.2s ease;
}

.back-button:hover {
    border-color: var(--accent);
    color: var(--accent-hover);
}

.brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-name {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.3px;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 12px;
}


/* =========================================
   MAIN
   ========================================= */

.container {
    width: min(1180px, calc(100% - 32px));
    margin: auto;
    padding: 34px 0 60px;
}


/* =========================================
   HERO
   ========================================= */

.hero {
    text-align: center;
    margin-bottom: 30px;
}

.hero-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
}

.hero h1 {
    font-size: clamp(28px, 5vw, 42px);
    margin-bottom: 10px;
}

.hero p {
    max-width: 680px;
    margin: auto;
    color: var(--muted);
    line-height: 1.7;
}

.privacy-note {
    margin: 18px auto 0;
    width: fit-content;
    max-width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    border-radius: 999px;
    font-size: 13px;
}


/* =========================================
   CARD
   ========================================= */

.tool-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px;
    margin-bottom: 22px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 16px;
}

.section-heading h2 {
    font-size: 18px;
}

.section-heading p {
    color: var(--muted);
    font-size: 13px;
}


/* =========================================
   UPLOAD AREA
   ========================================= */

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 18px;
    padding: 42px 20px;
    text-align: center;
    background: var(--surface-2);
    transition: 0.2s ease;
}

.upload-area.drag-over {
    border-color: var(--accent);
    background: rgba(124, 92, 255, 0.08);
}

.upload-icon {
    font-size: 42px;
    margin-bottom: 12px;
}

.upload-area h3 {
    margin-bottom: 8px;
    font-size: 18px;
}

.upload-area p {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 18px;
}


/* =========================================
   BUTTONS
   ========================================= */

.primary-button,
.secondary-button,
.download-button,
.convert-button {
    border: 0;
    border-radius: 11px;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
}

.primary-button,
.convert-button {
    background: var(--accent);
    color: white;
}

.primary-button:hover,
.convert-button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.secondary-button {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}

.secondary-button:hover {
    border-color: var(--accent);
}

.download-button {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}

.download-button:hover {
    border-color: var(--accent);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
}


/* =========================================
   SELECTED IMAGES
   ========================================= */

.image-list {
    display: grid;
    grid-template-columns:
        repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}

.image-item {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 13px;
    align-items: center;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.image-preview {
    width: 92px;
    height: 92px;
    object-fit: cover;
    border-radius: 10px;
    background: #050609;
}

.image-item-info {
    min-width: 0;
}

.image-item-name {
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-item-size {
    color: var(--muted);
    font-size: 12px;
    margin-top: 5px;
}


/* =========================================
   CROP WORKSPACE
   ========================================= */

.crop-workspace {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        310px;
    gap: 20px;
}

.crop-preview-panel {
    min-width: 0;
    background: #050609;
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}

.crop-canvas-wrapper {
    width: 100%;
    min-height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    overflow: hidden;
}

#cropCanvas {
    display: block;
    max-width: 100%;
    max-height: 620px;
    border-radius: 8px;
    touch-action: none;
    user-select: none;
}


/* =========================================
   CROP CONTROLS
   ========================================= */

.crop-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.control-group {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 15px;
}

.control-group h3 {
    font-size: 14px;
    margin-bottom: 12px;
}

.control-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 7px;
}

.select-input,
.number-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 11px 12px;
    outline: none;
}

.select-input:focus,
.number-input:focus {
    border-color: var(--accent);
}


/* =========================================
   ASPECT RATIO
   ========================================= */

.aspect-grid {
    display: grid;
    grid-template-columns:
        repeat(3, 1fr);
    gap: 7px;
}

.aspect-button {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 9px 6px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 12px;
    transition: 0.2s ease;
}

.aspect-button:hover {
    border-color: var(--accent);
}

.aspect-button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}


/* =========================================
   TRANSFORM BUTTONS
   ========================================= */

.transform-grid {
    display: grid;
    grid-template-columns:
        repeat(2, 1fr);
    gap: 8px;
}

.transform-button {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 10px 8px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 12px;
}

.transform-button:hover {
    border-color: var(--accent);
}


/* =========================================
   ZOOM
   ========================================= */

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

.zoom-row input[type="range"] {
    flex: 1;
}

.zoom-value {
    min-width: 45px;
    text-align: right;
    color: var(--muted);
    font-size: 12px;
}


/* =========================================
   RANGE
   ========================================= */

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.range-value {
    color: var(--muted);
    font-size: 12px;
    margin-top: 7px;
}


/* =========================================
   OUTPUT SETTINGS
   ========================================= */

.output-settings {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-group label {
    font-size: 13px;
    color: var(--muted);
}


/* =========================================
   ACTION SECTION
   ========================================= */

.action-section {
    display: flex;
    justify-content: center;
    margin-top: 22px;
}

.convert-button {
    min-width: 230px;
    padding: 14px 20px;
    font-size: 15px;
}


/* =========================================
   PROGRESS
   ========================================= */

.progress-heading {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 13px;
}

.progress-heading span:last-child {
    color: var(--muted);
}

.progress-track {
    width: 100%;
    height: 9px;
    border-radius: 99px;
    overflow: hidden;
    background: var(--surface-2);
}

.progress-bar {
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width 0.2s ease;
}


/* =========================================
   CROP SHAPE BUTTONS
   ========================================= */

.shape-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.shape-button {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 9px 6px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 12px;
    transition: 0.2s ease;
}

.shape-button:hover {
    border-color: var(--accent);
}

.shape-button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}


/* =========================================
   SELECTION CONTROLS
   ========================================= */

.selection-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-bottom: 16px;
}


/* =========================================
   RESULTS
   ========================================= */

.results-container {
    display: grid;
    grid-template-columns:
        repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.result-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-image {
    width: 100%;
    height: 220px;
    object-fit: contain;
    background: #050609;
    border-radius: 10px;
}

.result-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.result-checkbox {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--accent);
    flex-shrink: 0;
}

.result-name {
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-size {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.result-download {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    font-weight: 700;
}

.result-download:hover {
    border-color: var(--accent);
}


/* =========================================
   DOWNLOAD GRID
   ========================================= */

.download-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}


/* =========================================
   FOOTER
   ========================================= */

.tool-footer {
    text-align: center;
    padding: 20px;
    color: var(--muted);
    font-size: 12px;
}


/* =========================================
   HIDDEN
   ========================================= */

[hidden] {
    display: none !important;
}


/* =========================================
   MOBILE
   ========================================= */

@media (max-width: 850px) {

    .crop-workspace {
        grid-template-columns: 1fr;
    }

    .crop-controls {
        display: grid;
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}


@media (max-width: 650px) {

    .container {
        width: min(
            100% - 20px,
            1180px
        );

        padding-top: 22px;
    }

    .header-inner {
        padding: 13px 12px;
    }

    .brand-name {
        font-size: 15px;
    }

    .tool-card {
        padding: 15px;
        border-radius: 15px;
    }

    .upload-area {
        padding: 30px 14px;
    }

    .image-list {
        grid-template-columns: 1fr;
    }

    .crop-canvas-wrapper {
        min-height: 300px;
        padding: 10px;
    }

    .crop-controls {
        grid-template-columns: 1fr;
    }

    .output-settings {
        grid-template-columns: 1fr;
    }

    .download-grid {
        grid-template-columns: 1fr;
    }

    .results-container {
        grid-template-columns: 1fr;
    }

    .result-image {
        height: 250px;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}


@media (max-width: 380px) {

    .back-button {
        padding: 8px 10px;
        font-size: 12px;
    }

    .brand-subtitle {
        display: none;
    }

    .hero h1 {
        font-size: 26px;
    }

    .aspect-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }
}