form {
    width: 100%;
    padding-left: clamp(1rem, 8vw, 6rem);
    margin: 0 auto;
    box-sizing:border-box;
}

.form-group {
    width: min(90%, 700px); /* più pulito e più stabile del vecchio clamp */
    padding-bottom: clamp(0.75rem, 2vw, 1.25rem);
}

.form-title {
    padding-top: clamp(0.75rem, 2vw, 1rem);
}

.form-group label {
    font-weight: 600;
    color: var(--gray-dark);
    margin-bottom: clamp(0.3rem, 1vw, 0.75rem);
    display: block;
    text-transform: uppercase;
    letter-spacing: clamp(0.3px, 0.4vw, 1px);
    font-size: clamp(0.75rem, 2vw, 1rem);
}

.form-control {
    width: 100%;
    /*padding: clamp(0.75rem, 2vw, 1.25rem);*/
    border: 2px solid var(--gray-300);
    border-radius: clamp(10px, 2.5vw, 16px);
    transition: all 0.3s ease;
    background-color: var(--gray-100);
}

.form-control:focus {
    border-color: var(--pink-primary);
    background-color: white;
    outline: none;
    box-shadow: 0 0 0 clamp(2px, 0.7vw, 5px) rgba(231,28,91,0.2);
}

input[type=text], [type=number], [type=url], [type=file], [type=date], [type=tel], select {
    padding: clamp(10px, 2vw, 12px) clamp(12px, 2.5vw, 15px);
    display: inline-block;
    border: clamp(1px, 0.3vw, 2px) solid #ccc;
    box-sizing: border-box;
  }

textarea {
    width: min(90%, 700px);
    height: clamp(100px, 25vh, 180px);
    padding: clamp(0.75rem, 2vw, 1.25rem);
    border-radius: clamp(8px, 1.5vw, 12px);
    box-sizing: border-box;
}

textarea.form-control {
    resize: vertical;
    min-height: clamp(100px, 15vh, 120px);
}

label {
    padding-top: clamp(0.75rem, 2vw, 1rem);
    margin-bottom: clamp(1rem, 3vw, 2rem);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right clamp(0.75rem, 2vw, 1rem) center;
    padding-right: clamp(2rem, 5vw, 3rem);
}

/* === File Upload Modern === */

/* Nascondi l'input file ma mantienilo accessibile */
.custom-file input[type="file"] {
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    z-index: -1;
}

.custom-file-label {
    border: 2px dashed var(--gray-400);
    padding: clamp(1.25rem, 3vw, 2rem);
    border-radius: clamp(10px, 2vw, 16px);
}

.custom-file-label:hover {
    border-color: var(--pink-primary);
    background: linear-gradient(135deg, #fff0f5 0%, white 100%);
}

/* Stile per l'area cliccabile */
.custom-file {
    width: min(95%, 600px);
    padding-top: clamp(0.5rem, 2vw, 1rem);
}

/* Preview container */
.photo-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(8px, 1.5vw, 14px);
    margin-top: clamp(10px, 2vw, 20px);
}


.photo-preview-item {
    width: clamp(90px, 20vw, 160px);
    height: clamp(90px, 20vw, 160px);
}

.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: clamp(6px, 1.5vw, 12px);
}

input[type="file"].blocked + .custom-file-label {
    background-color: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
}

/* ── Crop image cards ───────────────────────────────────────────────────── */
.img-cards-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    box-sizing: border-box;
    width: min(90%, 700px);
}

.img-card { box-sizing: border-box; }

.img-card-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--gray-dark, #333);
}

.img-preview-wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 10px;
    background: #f0f0f0;
    cursor: pointer;
}

.img-preview-wrap--square { aspect-ratio: 1 / 1; }
.img-preview-wrap--banner { aspect-ratio: 16 / 5; }

.img-preview-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 10px;
}

.img-edit-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background 0.2s;
    z-index: 1;
}

.img-edit-btn:hover { background: var(--pink-primary); }

/* ── Crop modal ─────────────────────────────────────────────────────────── */
.crop-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 9000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.crop-modal.active { display: flex; }

.crop-modal-inner {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 700px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.crop-modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.crop-modal-header h4 { margin: 0; font-size: 1rem; font-weight: 700; }

.crop-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #888;
    padding: 0.2rem;
}

.crop-modal-close:hover { color: #333; }

.crop-container { max-height: 420px; background: #222; overflow: hidden; }
.crop-container img { display: block; max-width: 100%; }

.crop-modal-footer {
    padding: 1rem 1.25rem;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    border-top: 1px solid #eee;
}

@media (max-width: 600px) {
    .img-cards-row { grid-template-columns: 1fr; }
}