/* === Reset e Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f7;
    color: #1d1d1f;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* === Header === */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 0 10px;
}

header h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1d1d1f;
}

.subtitle {
    font-size: 15px;
    color: #6e6e73;
    margin-top: 4px;
}

/* === Card === */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
}

.card h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 6px;
}

.hint {
    font-size: 14px;
    color: #6e6e73;
    margin-bottom: 20px;
}

/* === Form Elements === */
textarea,
input[type="text"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.2s;
}

textarea:focus,
input:focus,
select:focus {
    outline: none;
    border-color: #0071e3;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

textarea {
    resize: vertical;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 4px;
}

.form-group {
    margin-bottom: 16px;
    flex: 1;
}

.form-row {
    display: flex;
    gap: 16px;
}

/* Campo mancante */
.field-missing input,
.field-missing textarea,
.field-missing select {
    border-color: #f59e0b;
    background: #fffbeb;
}

.field-missing label {
    color: #d97706;
}

/* === Fieldset === */
fieldset {
    border: 1px solid #e5e5ea;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

legend {
    font-size: 15px;
    font-weight: 600;
    color: #0071e3;
    padding: 0 8px;
}

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #0071e3;
    color: #fff;
}

.btn-primary:hover {
    background: #0077ed;
}

.btn-success {
    background: #34c759;
    color: #fff;
}

.btn-success:hover {
    background: #30b350;
}

.btn-secondary {
    background: #e5e5ea;
    color: #1d1d1f;
}

.btn-secondary:hover {
    background: #d1d1d6;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: center;
}

/* === File Upload === */
.file-upload {
    margin: 16px 0;
    padding: 12px;
    background: #f5f5f7;
    border-radius: 8px;
}

.file-upload label {
    font-weight: 500;
    margin-bottom: 6px;
}

.file-upload input[type="file"] {
    font-size: 14px;
}

/* === Alerts === */
.alert {
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.alert h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.alert ul {
    padding-left: 20px;
}

.alert li {
    font-size: 14px;
    margin-bottom: 4px;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #f59e0b;
    color: #92400e;
}

/* === Confidence Bar === */
.confidence-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f5f5f7;
    border-radius: 8px;
}

.confidence-bar-wrapper label {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    margin-bottom: 0;
}

.confidence-bar {
    flex: 1;
    height: 10px;
    background: #e5e5ea;
    border-radius: 5px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s ease, background-color 0.5s ease;
}

.confidence-label {
    font-size: 14px;
    font-weight: 700;
    min-width: 40px;
}

/* === Loading === */
.loading-card {
    text-align: center;
    padding: 60px 30px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e5ea;
    border-top: 4px solid #0071e3;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

/* === Success === */
.success-card {
    text-align: center;
}

.success-card h2 {
    color: #34c759;
    margin-bottom: 10px;
}

.next-steps {
    text-align: left;
    background: #f5f5f7;
    padding: 16px 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.next-steps p {
    font-weight: 600;
    margin-bottom: 8px;
}

.next-steps li {
    font-size: 14px;
    color: #6e6e73;
    margin-bottom: 4px;
}

/* === Error Toast === */
.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ff3b30;
    color: #fff;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* === Custom Fields (Campi Aggiuntivi) === */
.btn-add-field {
    background: none;
    color: #0071e3;
    border: 1px dashed #0071e3;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
    width: 100%;
}

.btn-add-field:hover {
    background: #f0f7ff;
    border-color: #0077ed;
}

.custom-fields-container {
    margin-top: 12px;
}

.custom-field-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.custom-field-row input.custom-field-label {
    flex: 0 0 180px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    background: #f5f5f7;
}

.custom-field-row input.custom-field-value,
.custom-field-row textarea.custom-field-value {
    flex: 1;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
}

.btn-remove-field {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: #ff3b30;
    color: #fff;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
    line-height: 1;
}

.btn-remove-field:hover {
    background: #e0352b;
}

/* === Direzione Creativa === */
.direzione-creativa-group {
    margin: 16px 0 8px;
    text-align: left;
}

.direzione-creativa-group .hint {
    margin-top: 4px;
    margin-bottom: 0;
}

textarea.direzione-creativa {
    width: 100%;
    padding: 10px 12px;
    border: 1px dashed #b3d4fc;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #f8fbff;
    transition: border-color 0.2s;
    resize: vertical;
}

textarea.direzione-creativa:focus {
    outline: none;
    border-color: #0071e3;
    border-style: solid;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

/* === Idea Cards (Step 2) === */
.idea-card {
    border: 1px solid #e5e5ea;
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.idea-card:hover {
    border-color: #0071e3;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.12);
}

.idea-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px 12px;
    background: #f9f9fb;
    border-bottom: 1px solid #f0f0f2;
}

.idea-numero {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #0071e3;
    color: #fff;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.idea-titolo {
    font-size: 16px;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0;
}

.idea-body {
    padding: 16px 20px;
}

.idea-section {
    margin-bottom: 10px;
}

.idea-section:last-child {
    margin-bottom: 0;
}

.idea-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6e6e73;
    margin-bottom: 2px;
}

.idea-section p {
    font-size: 14px;
    line-height: 1.5;
    color: #1d1d1f;
    margin: 0;
}

.idea-footer {
    padding: 12px 20px 16px;
    display: flex;
    justify-content: flex-end;
}

.btn-select-idea {
    display: inline-block;
    padding: 8px 20px;
    border: 2px solid #0071e3;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #0071e3;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-select-idea:hover {
    background: #0071e3;
    color: #fff;
}

/* Riepilogo idea selezionata */
.idea-riepilogo {
    background: #f0f7ff;
    border: 1px solid #b3d4fc;
    border-radius: 10px;
    padding: 20px;
    margin: 16px 0;
    text-align: left;
}

.idea-riepilogo h3 {
    font-size: 17px;
    font-weight: 700;
    color: #0071e3;
    margin-bottom: 8px;
}

.idea-riepilogo p {
    font-size: 14px;
    color: #1d1d1f;
    margin-bottom: 6px;
    line-height: 1.5;
}

/* === Progetto Cards === */
.progetto-card {
    border: 1px solid #e5e5ea;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.progetto-card:hover {
    border-color: #0071e3;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.12);
}

.progetto-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progetto-card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 0;
}

.progetto-progresso {
    font-size: 13px;
    font-weight: 600;
    color: #6e6e73;
    background: #f5f5f7;
    padding: 2px 10px;
    border-radius: 12px;
}

.progetto-data {
    font-size: 13px;
    color: #6e6e73;
    margin-top: 4px;
}

.nuovo-progetto-form {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.nuovo-progetto-form input {
    flex: 1;
}

/* === Step Cards (Hub Dashboard) === */
.step-card {
    border: 1px solid #e5e5ea;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 10px;
    border-left: 4px solid #d2d2d7;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.step-card.completato {
    border-left-color: #34c759;
}

.step-card.disponibile {
    border-left-color: #0071e3;
    cursor: pointer;
}

.step-card.disponibile:hover {
    border-color: #0071e3;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.12);
}

.step-card.completato:hover {
    border-color: #34c759;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.12);
}

.step-card.bloccato {
    border-left-color: #d2d2d7;
    opacity: 0.6;
}

.step-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.step-card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1d1d1f;
    margin: 0;
}

.step-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
}

.step-badge-completato {
    background: #dcf5e3;
    color: #1a7a34;
}

.step-badge-disponibile {
    background: #e8f2fd;
    color: #0058b0;
}

.step-badge-bloccato {
    background: #f0f0f2;
    color: #8e8e93;
}

.step-descrizione {
    font-size: 14px;
    color: #6e6e73;
    margin-top: 4px;
    margin-bottom: 0;
}

.step-requisiti {
    font-size: 13px;
    color: #d97706;
    margin-top: 6px;
    margin-bottom: 0;
    font-style: italic;
}

.loading-inline {
    text-align: center;
    padding: 20px;
    color: #6e6e73;
    font-size: 14px;
}

/* === Location Cards (Step 3) === */
.location-card {
    border: 1px solid #e5e5ea;
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.location-card:hover {
    border-color: #0071e3;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.12);
}

.location-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px 12px;
    background: #f9f9fb;
    border-bottom: 1px solid #f0f0f2;
}

.location-numero {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #5856d6;
    color: #fff;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.location-title-block {
    flex: 1;
    min-width: 0;
}

.location-nome {
    font-size: 16px;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0;
}

.location-tipologia {
    font-size: 12px;
    color: #6e6e73;
    font-weight: 500;
}

.location-prezzo {
    font-size: 12px;
    font-weight: 600;
    color: #5856d6;
    background: #f0efff;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.location-body {
    padding: 16px 20px;
}

.location-info-row {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
}

.location-info-row .location-info {
    flex: 1;
    margin-bottom: 0;
}

.location-info {
    margin-bottom: 10px;
}

.location-info:last-child {
    margin-bottom: 0;
}

.location-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6e6e73;
    margin-bottom: 2px;
}

.location-info p {
    font-size: 14px;
    line-height: 1.5;
    color: #1d1d1f;
    margin: 0;
}

.location-perche {
    background: #f8f7ff;
    border-radius: 8px;
    padding: 10px 12px;
}

.location-footer {
    padding: 12px 20px 16px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}

.location-link {
    font-size: 13px;
    font-weight: 600;
    color: #5856d6;
    text-decoration: none;
}

.location-link:hover {
    text-decoration: underline;
}

/* Riepilogo location selezionata */
.location-riepilogo {
    background: #f8f7ff;
    border: 1px solid #d4d3f0;
    border-radius: 10px;
    padding: 20px;
    margin: 16px 0;
    text-align: left;
}

.location-riepilogo h3 {
    font-size: 17px;
    font-weight: 700;
    color: #5856d6;
    margin-bottom: 8px;
}

.location-riepilogo p {
    font-size: 14px;
    color: #1d1d1f;
    margin-bottom: 6px;
    line-height: 1.5;
}

.location-riepilogo a {
    color: #5856d6;
    font-weight: 600;
}

/* === Budget (Step 4) === */
.budget-classificazione {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border: 2px solid;
    border-radius: 12px;
    margin-bottom: 20px;
}

.budget-tipo-badge {
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    padding: 6px 14px;
    border-radius: 8px;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

.budget-tipo-info h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 2px;
}

.budget-tipo-info p {
    font-size: 13px;
    color: #6e6e73;
    margin: 0;
    line-height: 1.4;
}

.budget-centro {
    margin-bottom: 20px;
}

.budget-centro-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e5e5ea;
}

.budget-centro-header h4 {
    font-size: 15px;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0;
}

.budget-centro-subtotale {
    font-size: 14px;
    font-weight: 700;
    color: #0071e3;
    white-space: nowrap;
}

.budget-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.budget-table thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6e6e73;
    padding: 6px 8px;
    border-bottom: 1px solid #e5e5ea;
}

.budget-table tbody td {
    padding: 8px;
    border-bottom: 1px solid #f0f0f2;
    vertical-align: top;
}

.budget-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-weight: 600;
}

.budget-note {
    color: #6e6e73;
    font-size: 12px;
}

.budget-totali {
    background: #f5f5f7;
    border-radius: 10px;
    padding: 16px 20px;
    margin-top: 20px;
}

.budget-totali-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 14px;
}

.budget-totali-finale {
    font-size: 18px;
    font-weight: 800;
    color: #1d1d1f;
    padding-top: 10px;
    margin-top: 6px;
    border-top: 2px solid #d2d2d7;
}

.budget-iva {
    font-size: 12px;
    color: #6e6e73;
    margin-top: 8px;
    margin-bottom: 0;
    text-align: right;
}

.budget-sintesi {
    background: #f0f7ff;
    border: 1px solid #b3d4fc;
    border-radius: 10px;
    padding: 16px 20px;
    margin-top: 16px;
}

.budget-sintesi p {
    font-size: 14px;
    line-height: 1.6;
    color: #1d1d1f;
    margin: 0;
}

/* Riepilogo budget confermato */
.budget-riepilogo {
    text-align: left;
    margin: 16px 0;
}

/* === Moodboard (Step 5) === */
.moodboard-context-card {
    background: #f5f5f7;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 12px;
}

.moodboard-context-card h4 {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6e6e73;
    margin: 0 0 6px;
}

.moodboard-context-card p {
    font-size: 14px;
    color: #1d1d1f;
    margin: 0 0 4px;
    line-height: 1.5;
}

.moodboard-context-card p:last-child {
    margin-bottom: 0;
}

.moodboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.moodboard-grid-small {
    gap: 12px;
}

.moodboard-card {
    border: 1px solid #e5e5ea;
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.moodboard-card:hover {
    border-color: #0071e3;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.12);
}

.moodboard-card img {
    width: 100%;
    display: block;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

.moodboard-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0;
    padding: 12px 14px 4px;
}

.moodboard-card-desc {
    font-size: 13px;
    color: #6e6e73;
    margin: 0;
    padding: 0 14px 12px;
    line-height: 1.4;
}

.moodboard-card-error {
    background: #f5f5f7;
}

.moodboard-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e5ea;
    color: #8e8e93;
    font-size: 14px;
    font-weight: 500;
}

.moodboard-grid-small .moodboard-card img {
    aspect-ratio: 1 / 1;
}

.moodboard-grid-small .moodboard-card-title {
    font-size: 13px;
    padding: 8px 10px 6px;
}

.moodboard-riepilogo {
    text-align: left;
    margin: 16px 0;
}

/* === Utilities === */
.hidden {
    display: none !important;
}

/* === Responsive === */
@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .container {
        padding: 12px;
    }

    .card {
        padding: 20px;
    }

    .actions {
        flex-direction: column;
    }

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