* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: #f5f7fb;
    color: #172033;
}

body {
    min-height: 100vh;
}

body.modal-open {
    overflow: hidden;
}

button,
input {
    font: inherit;
}

.page {
    width: 100%;
    padding: 32px 16px;
}

.card {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    background: white;
    border-radius: 18px;
    padding: 32px;
    box-shadow:
        0 10px 35px rgba(20, 35, 60, 0.08);
}

.brand {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 28px;
}

h1 {
    margin: 0 0 12px;
    font-size: 30px;
    line-height: 1.2;
}

h2 {
    margin: 0;
    font-size: 22px;
}

p {
    margin: 0 0 28px;
    color: #667085;
    line-height: 1.6;
}

.order-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 0;
    border-bottom: 1px solid #eaecf0;
}

.slots {
    display: grid;
    grid-template-columns:
        repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    margin-top: 28px;
}

.slot {
    position: relative;
    width: 100%;
    min-height: 140px;
    padding: 0;
    border: 2px dashed #d0d5dd;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    cursor: pointer;
    appearance: none;
    color: inherit;
}

.slot:hover {
    background: #f8fafc;
}

.slot:focus-visible {
    outline: 3px solid rgba(23, 32, 51, 0.2);
    outline-offset: 2px;
}

.slot-empty {
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.slot-number {
    font-size: 24px;
    font-weight: 700;
}

.slot-status {
    font-size: 13px;
    color: #667085;
}

.slot-preview {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.slot-overlay {
    position: absolute;
    inset: auto 0 0 0;
    padding: 8px;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    font-size: 12px;
    text-align: center;
}

.error {
    margin-top: 20px;
    padding: 14px;
    border-radius: 10px;
    background: #fff4f4;
    color: #b42318;
}

.hidden {
    display: none !important;
}


/* ---------------------------------------------------------
   Crop modal
--------------------------------------------------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
}

.crop-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 660px;
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    background: white;
    border-radius: 18px;
    padding: 22px;
}

.crop-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 18px;
}

.crop-header p {
    margin: 4px 0 0;
    font-size: 14px;
}

.icon-button {
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: 30px;
    line-height: 1;
}

.icon-button:hover {
    background: #f2f4f7;
}

.crop-viewport {
    position: relative;
    width: 100%;
    max-height: 58vh;
    margin: 0 auto;
    overflow: hidden;
    background: #111827;
    touch-action: none;
    cursor: grab;
    user-select: none;
}

.crop-viewport.dragging {
    cursor: grabbing;
}

.crop-viewport img {
    position: absolute;
    max-width: none;
    max-height: none;
    user-select: none;
    pointer-events: none;
}

.zoom-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 20px;
}

.zoom-row span {
    font-size: 14px;
    font-weight: 600;
}

.zoom-row input {
    flex: 1;
}

.crop-status {
    min-height: 24px;
    margin-top: 12px;
    font-size: 14px;
    color: #667085;
}

.crop-status.error-text {
    color: #b42318;
}

.crop-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}

.button {
    border: 0;
    border-radius: 10px;
    padding: 12px 18px;
    cursor: pointer;
    font-weight: 600;
}

.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.button.secondary {
    background: #eef1f5;
    color: #172033;
}

.button.primary {
    background: #172033;
    color: white;
}


@media (max-width: 600px) {
    .page {
        padding: 16px 10px;
    }

    .card {
        padding: 22px 18px;
        border-radius: 14px;
    }

    h1 {
        font-size: 25px;
    }

    .slots {
        grid-template-columns:
            repeat(3, 1fr);
        gap: 8px;
    }

    .slot,
    .slot-empty,
    .slot-preview {
        min-height: 110px;
        height: 110px;
    }

    .crop-dialog {
        padding: 16px;
        border-radius: 14px;
    }

    .modal {
        padding: 8px;
    }
}

.slot {
    display: flex;
    flex-direction: column;
}

.slot-empty-button {
    width: 100%;
    min-height: 140px;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.slot-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
}

.slot-action {
    border: 0;
    padding: 10px 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}

.slot-action.replace {
    background: #eef1f5;
    color: #172033;
}

.slot-action.delete {
    background: #fff1f1;
    color: #b42318;
}

.slot-action:hover {
    filter: brightness(0.97);
}

.slot-action:disabled {
    opacity: 0.5;
    cursor: wait;
}

/* Fix uploaded photo controls */
.slot-overlay {
    position: static;
    inset: auto;
    width: 100%;
    padding: 7px 8px;
    background: #172033;
    color: white;
    font-size: 12px;
    text-align: center;
    flex-shrink: 0;
}

.slot-actions {
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.slot-preview {
    flex-shrink: 0;
}

.personalization {
    margin-top: 28px;
    padding: 22px;
    border: 1px solid #eaecf0;
    border-radius: 14px;
    background: #fafbfc;
}

.personalization h2 {
    margin-bottom: 6px;
}

.personalization > p {
    margin-bottom: 20px;
}

.form-field {
    margin-bottom: 18px;
}

.form-field:last-child {
    margin-bottom: 0;
}

.form-field label {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
    font-weight: 600;
}

.form-field input[type="text"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field textarea {
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 9px;
    padding: 11px 12px;
    background: white;
    color: #172033;
}

.form-field textarea {
    resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus {
    outline: none;
    border-color: #667085;
    box-shadow: 0 0 0 3px rgba(102, 112, 133, 0.12);
}

.save-status {
    min-height: 20px;
    margin-top: 12px;
    font-size: 13px;
    color: #667085;
}

.save-error {
    color: #b42318;
}

.complete-section {
    margin-top: 30px;
    padding-top: 24px;
    border-top: 1px solid #eaecf0;
}

.complete-button {
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 15px 20px;
    background: #172033;
    color: white;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
}

.complete-button:hover {
    opacity: 0.92;
}

.complete-button:disabled {
    opacity: 0.5;
    cursor: wait;
}

.complete-status {
    margin-top: 12px;
    white-space: pre-line;
    font-size: 14px;
    color: #667085;
}

.complete-error {
    color: #b42318;
}

.complete-success {
    padding: 24px;
    border-radius: 14px;
    background: #f0fdf4;
    text-align: center;
}

.complete-success h2 {
    margin-bottom: 8px;
}

.complete-success p {
    margin: 0;
}

.confirm-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 480px;
    background: white;
    border-radius: 18px;
    padding: 26px;
}

.confirm-dialog h2 {
    margin-bottom: 12px;
}

.confirm-dialog p {
    margin-bottom: 14px;
}

.confirm-warning {
    padding: 12px;
    border-radius: 10px;
    background: #fff7ed;
    color: #9a3412;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

@media (max-width: 600px) {
    .confirm-actions {
        flex-direction: column-reverse;
    }

    .confirm-actions .button {
        width: 100%;
    }
}
