/* =========================================================
   IMAGE CROPPER
   ========================================================= */

.cropper-page {
    min-height: 100vh;
    padding: 40px 20px 70px;
    background: #f7f8fa;
}


/* =========================================================
   HEADER
   ========================================================= */

.cropper-header {
    max-width: 1180px;
    margin: 0 auto 30px;
    text-align: center;
}

.cropper-header-content {
    max-width: 760px;
    margin: 0 auto;
}

.cropper-badge,
.result-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border: 1px solid #dfe3e8;
    border-radius: 999px;
    background: #ffffff;
    color: #667085;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.cropper-header h1 {
    margin: 14px 0 10px;
    color: #17191c;
    font-size: 38px;
    line-height: 1.15;
    font-weight: 700;
}

.cropper-header p {
    margin: 0;
    color: #667085;
    font-size: 16px;
    line-height: 1.6;
}


/* =========================================================
   MAIN CONTAINER
   ========================================================= */

.cropper-container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 26px;
    border: 1px solid #e4e7ec;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 8px 30px rgba(16, 24, 40, 0.05);
}


/* =========================================================
   UPLOAD
   ========================================================= */

.cropper-upload {
    min-height: 300px;
    padding: 45px 25px;
    border: 1.5px dashed #cfd5dc;
    border-radius: 16px;
    background: #fafbfc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: 0.2s ease;
}

.cropper-upload:hover,
.cropper-upload.drag-over {
    border-color: #8b95a5;
    background: #f6f7f9;
}

.cropper-upload-icon {
    width: 62px;
    height: 62px;
    margin-bottom: 16px;
    border-radius: 16px;
    background: #eef1f4;
    color: #25282d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 27px;
}

.cropper-upload h2 {
    margin: 0 0 8px;
    color: #20242a;
    font-size: 21px;
}

.cropper-upload p {
    margin: 0 0 20px;
    color: #737b87;
    font-size: 14px;
}

.cropper-browse-btn {
    border: 0;
    border-radius: 9px;
    padding: 11px 22px;
    background: var(--gp-gradient);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
}

.cropper-browse-btn:hover {
    background: var(--gp-gradient-hover);
    transform: translateY(-1px);
}

.cropper-upload-note {
    margin-top: 16px;
    color: #98a2b3;
    font-size: 12px;
}


/* =========================================================
   FILE INFORMATION
   ========================================================= */

.cropper-file-info {
    margin-top: 22px;
    padding: 16px;
    border: 1px solid #e4e7ec;
    border-radius: 14px;
    background: #fafbfc;
    display: flex;
    align-items: center;
    gap: 18px;
}

.cropper-file-preview {
    width: 82px;
    height: 82px;
    flex: 0 0 82px;
    overflow: hidden;
    border-radius: 10px;
    background: #eef0f3;
}

.cropper-file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cropper-file-details {
    min-width: 0;
    flex: 1;
}

.cropper-file-details h3 {
    margin: 0 0 9px;
    color: #20242a;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cropper-file-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    color: #737b87;
    font-size: 12px;
}

.cropper-file-meta strong {
    color: #343941;
}

.cropper-status {
    display: inline-flex;
    margin-top: 10px;
    padding: 4px 9px;
    border-radius: 6px;
    background: #eef1f4;
    color: #667085;
    font-size: 11px;
    font-weight: 600;
}


/* =========================================================
   EDITOR
   ========================================================= */

.cropper-editor {
    margin-top: 22px;
    border: 1px solid #e4e7ec;
    border-radius: 16px;
    overflow: hidden;
    background: #ffffff;
}


/* =========================================================
   TOOLBAR
   ========================================================= */

.cropper-toolbar {
    min-height: 66px;
    padding: 12px 16px;
    border-bottom: 1px solid #e4e7ec;
    background: #fafbfc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.cropper-toolbar-group {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.toolbar-label {
    margin-right: 5px;
    color: #667085;
    font-size: 12px;
    font-weight: 600;
}

.ratio-button,
.tool-button {
    min-width: 42px;
    height: 34px;
    padding: 0 11px;
    border: 1px solid #d9dde3;
    border-radius: 7px;
    background: #ffffff;
    color: #4b5563;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.18s ease;
}

.ratio-button:hover,
.tool-button:hover {
    border-color: #9da5b1;
    background: #f5f6f8;
}

.ratio-button.active {
    border-color: #20242a;
    background: #20242a;
    color: #ffffff;
}

.tool-button {
    width: 36px;
    min-width: 36px;
    padding: 0;
    font-size: 18px;
}


/* =========================================================
   WORKSPACE
   ========================================================= */

.cropper-workspace {
    min-height: 520px;
    padding: 24px;
    background: #25282d;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cropper-canvas-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 470px;
    display: inline-block;
    line-height: 0;
}

#cropperCanvas {
    display: block;
    max-width: 100%;
    max-height: 470px;
    background: #16181b;
    border-radius: 4px;
}


/* =========================================================
   CROP OVERLAY
   ========================================================= */

.cropper-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.crop-selection {
    position: absolute;
    left: 10%;
    top: 10%;
    width: 80%;
    height: 80%;
    min-width: 30px;
    min-height: 30px;
    border: 2px solid #ffffff;
    box-shadow:
        0 0 0 9999px rgba(0, 0, 0, 0.48);
    pointer-events: auto;
    cursor: move;
    box-sizing: border-box;
}


/* =========================================================
   CROP GRID
   ========================================================= */

.crop-grid {
    position: absolute;
    pointer-events: none;
    opacity: 0.65;
}

.grid-vertical {
    left: 33.333%;
    top: 0;
    bottom: 0;
    width: 33.333%;
    border-left: 1px solid rgba(255, 255, 255, 0.6);
    border-right: 1px solid rgba(255, 255, 255, 0.6);
}

.grid-horizontal {
    top: 33.333%;
    left: 0;
    right: 0;
    height: 33.333%;
    border-top: 1px solid rgba(255, 255, 255, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
}


/* =========================================================
   CROP HANDLES
   ========================================================= */

.crop-handle {
    position: absolute;
    width: 13px;
    height: 13px;
    border: 2px solid #ffffff;
    background: #20242a;
    border-radius: 3px;
    z-index: 5;
}

.crop-handle.top-left {
    left: -7px;
    top: -7px;
    cursor: nwse-resize;
}

.crop-handle.top-right {
    right: -7px;
    top: -7px;
    cursor: nesw-resize;
}

.crop-handle.bottom-left {
    left: -7px;
    bottom: -7px;
    cursor: nesw-resize;
}

.crop-handle.bottom-right {
    right: -7px;
    bottom: -7px;
    cursor: nwse-resize;
}


/* =========================================================
   CONTROLS
   ========================================================= */

.cropper-controls {
    padding: 18px 20px;
    border-top: 1px solid #e4e7ec;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
}

.zoom-icon {
    color: #667085;
    font-size: 17px;
    font-weight: 600;
}

#cropperZoom {
    width: 210px;
    accent-color: #20242a;
    cursor: pointer;
}

.zoom-value {
    min-width: 45px;
    color: #475467;
    font-size: 12px;
    font-weight: 600;
}

.crop-dimensions {
    color: #667085;
    font-size: 12px;
}

.crop-dimensions strong {
    color: #20242a;
}


/* =========================================================
   CUSTOM CROP
   ========================================================= */

.custom-crop-section {
    padding: 18px 20px;
    border-top: 1px solid #e4e7ec;
    background: #fafbfc;
}

.custom-crop-title {
    margin-bottom: 12px;
    color: #343941;
    font-size: 13px;
    font-weight: 700;
}

.custom-crop-fields {
    display: grid;
    grid-template-columns: repeat(4, minmax(100px, 1fr));
    gap: 12px;
}

.custom-crop-fields label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #667085;
    font-size: 11px;
    font-weight: 600;
}

.custom-crop-fields input {
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border: 1px solid #d9dde3;
    border-radius: 7px;
    outline: none;
    background: #ffffff;
    color: #20242a;
    font-size: 13px;
    box-sizing: border-box;
}

.custom-crop-fields input:focus {
    border-color: #8b95a5;
    box-shadow: 0 0 0 3px rgba(139, 149, 165, 0.12);
}


/* =========================================================
   ACTIONS
   ========================================================= */

.cropper-actions {
    padding: 20px;
    border-top: 1px solid #e4e7ec;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.secondary-action,
.primary-action {
    min-height: 42px;
    padding: 0 19px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
}

.secondary-action {
    border: 1px solid #d9dde3;
    background: #ffffff;
    color: #475467;
}

.secondary-action:hover {
    background: #f5f6f8;
}

.primary-action {
    border: 0;
    background: var(--gp-gradient);
    color: #ffffff;
}

.primary-action:hover {
    background: var(--gp-gradient-hover);
    transform: translateY(-1px);
}

.primary-action:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}


/* =========================================================
   LOADING
   ========================================================= */

.cropper-loading {
    padding: 22px;
    border-top: 1px solid #e4e7ec;
    text-align: center;
}

.loading-spinner {
    width: 25px;
    height: 25px;
    margin: 0 auto 10px;
    border: 3px solid #e1e4e8;
    border-top-color: #20242a;
    border-radius: 50%;
    animation: cropperSpin 0.8s linear infinite;
}

.cropper-loading p {
    margin: 0;
    color: #667085;
    font-size: 13px;
}

@keyframes cropperSpin {
    to {
        transform: rotate(360deg);
    }
}


/* =========================================================
   RESULT
   ========================================================= */

.cropper-result {
    margin-top: 22px;
    border: 1px solid #e4e7ec;
    border-radius: 16px;
    overflow: hidden;
    background: #ffffff;
}

.result-header {
    padding: 22px;
    border-bottom: 1px solid #e4e7ec;
    background: #fafbfc;
}

.result-header h2 {
    margin: 10px 0 0;
    color: #20242a;
    font-size: 20px;
}

.result-content {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
    gap: 28px;
    padding: 24px;
}

.result-preview {
    min-height: 300px;
    padding: 20px;
    border-radius: 12px;
    background: #25282d;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-preview img {
    display: block;
    max-width: 100%;
    max-height: 480px;
    border-radius: 5px;
    object-fit: contain;
}

.result-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
}

.result-detail-item {
    padding: 13px 14px;
    border: 1px solid #e4e7ec;
    border-radius: 9px;
    background: #fafbfc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.result-detail-item span {
    color: #667085;
    font-size: 12px;
}

.result-detail-item strong {
    color: #20242a;
    font-size: 13px;
}

.download-button,
.new-image-button {
    width: 100%;
    min-height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-sizing: border-box;
}

.download-button {
    margin-top: 8px;
    background: var(--gp-gradient);
    color: #ffffff;
    text-decoration: none;
    border: 0;
}

.download-button:hover {
    background: var(--gp-gradient-hover);
}

.new-image-button {
    border: 1px solid #d9dde3;
    background: #ffffff;
    color: #475467;
}

.new-image-button:hover {
    background: #f5f6f8;
}


/* =========================================================
   ERROR
   ========================================================= */

.cropper-error {
    margin-top: 18px;
    padding: 15px 17px;
    border: 1px solid #e3e5e8;
    border-radius: 10px;
    background: #fafafa;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.error-icon {
    width: 25px;
    height: 25px;
    flex: 0 0 25px;
    border-radius: 50%;
    background: #eceef0;
    color: #343941;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.cropper-error strong {
    color: #343941;
    font-size: 13px;
}

.cropper-error p {
    margin: 4px 0 0;
    color: #737b87;
    font-size: 12px;
}


/* =========================================================
   INFORMATION
   ========================================================= */

.cropper-information {
    max-width: 1180px;
    margin: 22px auto 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.information-card {
    padding: 22px;
    border: 1px solid #e4e7ec;
    border-radius: 14px;
    background: #ffffff;
    text-align: center;
}

.information-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 13px;
    border-radius: 11px;
    background: #f0f2f4;
    color: #343941;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.information-card h3 {
    margin: 0 0 7px;
    color: #343941;
    font-size: 14px;
}

.information-card p {
    margin: 0;
    color: #7a828e;
    font-size: 12px;
    line-height: 1.55;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 900px) {

    .cropper-information {
        grid-template-columns: repeat(2, 1fr);
    }

    .result-content {
        grid-template-columns: 1fr;
    }

    .result-preview {
        min-height: 260px;
    }

    .cropper-workspace {
        min-height: 430px;
    }

    #cropperCanvas {
        max-height: 390px;
    }

    .custom-crop-fields {
        grid-template-columns: repeat(2, 1fr);
    }
}


@media (max-width: 650px) {

    .cropper-page {
        padding: 25px 12px 50px;
    }

    .cropper-container {
        padding: 14px;
        border-radius: 13px;
    }

    .cropper-header h1 {
        font-size: 29px;
    }

    .cropper-header p {
        font-size: 14px;
    }

    .cropper-upload {
        min-height: 260px;
        padding: 30px 15px;
    }

    .cropper-file-info {
        align-items: flex-start;
    }

    .cropper-file-preview {
        width: 65px;
        height: 65px;
        flex-basis: 65px;
    }

    .cropper-toolbar {
        padding: 12px;
    }

    .cropper-toolbar-group {
        width: 100%;
    }

    .cropper-workspace {
        min-height: 350px;
        padding: 12px;
    }

    #cropperCanvas {
        max-height: 320px;
    }

    .cropper-controls {
        align-items: flex-start;
        flex-direction: column;
    }

    .zoom-control {
        width: 100%;
        min-width: 0;
    }

    #cropperZoom {
        flex: 1;
        width: auto;
    }

    .custom-crop-fields {
        grid-template-columns: repeat(2, 1fr);
    }

    .cropper-actions {
        flex-direction: column-reverse;
    }

    .secondary-action,
    .primary-action {
        width: 100%;
    }

    .cropper-information {
        grid-template-columns: 1fr;
    }

    .result-content {
        padding: 15px;
    }

    .result-preview {
        min-height: 220px;
        padding: 12px;
    }
}


@media (max-width: 420px) {

    .ratio-button {
        flex: 1;
        min-width: 0;
    }

    .custom-crop-fields {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .cropper-file-meta {
        flex-direction: column;
        gap: 5px;
    }
}


/* The HTML "hidden" attribute must win over the display rules above,
   otherwise sections meant to stay hidden can show up at once. */
[hidden] {
    display: none !important;
}
