/* ===================================================
   Inline Edit Mode — Seamless form controls 
   =================================================== */

/* --- Shared inline input/select base --- */
.inline-edit-input,
.inline-edit-select {
    background: transparent !important;
    border: none !important;
    border-bottom: 1.5px solid transparent !important;
    border-radius: 0 !important;
    outline: none !important;
    font-family: inherit !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    color: #334155 !important;
    text-align: right !important;
    padding: 2px 4px !important;
    height: auto !important;
    box-sizing: border-box !important;
    transition: border-color 0.2s ease, background 0.2s ease !important;
    cursor: text;
}

.inline-edit-select {
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    /* Subtle dropdown indicator */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M5 6L0 0h10z' fill='%2394a3b8'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 2px center !important;
    background-size: 8px 5px !important;
    padding-right: 14px !important;
}

/* Hover: subtle background tint */
.inline-edit-input:hover,
.inline-edit-select:hover {
    background: rgba(59, 130, 246, 0.04) !important;
    border-bottom-color: #cbd5e1 !important;
}

/* Focus: visible underline */
.inline-edit-input:focus,
.inline-edit-select:focus {
    background: rgba(59, 130, 246, 0.06) !important;
    border-bottom-color: var(--primary-color, #3b82f6) !important;
}

/* Placeholder text */
.inline-edit-input::placeholder {
    color: #cbd5e1 !important;
    font-weight: 400 !important;
}

/* --- Standalone text inputs (luogo, professione) --- */
#profile-details-list.editing>li>.inline-edit-input {
    flex: 0 1 auto;
    max-width: 65%;
    min-width: 80px;
}

/* --- Date edit group (inline version) --- */
.inline-date-group {
    display: flex !important;
    gap: 2px !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    justify-content: flex-end !important;
    flex-grow: 1 !important;
    margin-top: 0 !important;
}

/* Day inputs */
.inline-date-group input[type="number"] {
    width: 34px !important;
    flex-shrink: 0 !important;
    text-align: center !important;
    -moz-appearance: textfield !important;
    appearance: textfield !important;
}

.inline-date-group input[type="number"]::-webkit-inner-spin-button,
.inline-date-group input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Year inputs */
#edit-birth-year,
#edit-death-year,
#edit-marr-year {
    width: 48px !important;
    flex-shrink: 0 !important;
    text-align: center !important;
}

/* Month selects */
#edit-birth-month,
#edit-death-month,
#edit-marr-month {
    min-width: 55px !important;
}

/* Prefix selects — hidden by default, show only when non-default is needed */
.inline-date-prefix {
    min-width: 55px !important;
    font-size: 0.75rem !important;
    color: #94a3b8 !important;
    font-weight: 500 !important;
}

/* --- Sex dropdown --- */
#edit-sex {
    min-width: 80px !important;
}

/* --- Edit mode container styling --- */
#profile-details-list.editing li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f1f5f9;
    gap: 12px;
}

#profile-details-list.editing li:last-child {
    border-bottom: none;
}

#profile-details-list.editing li>.detail-label {
    flex-shrink: 0;
    min-width: 100px;
}

/* --- Inline edit action buttons in header --- */
.info-edit-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: auto;
}

.info-edit-actions button {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.info-edit-actions button .material-symbols-outlined {
    font-size: 18px;
}

.info-edit-actions .info-save-btn {
    background: rgba(22, 163, 74, 0.1);
    color: #16a34a;
}

.info-edit-actions .info-save-btn:hover {
    background: #16a34a;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
}

.info-edit-actions .info-cancel-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.info-edit-actions .info-cancel-btn:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

/* === Stemmi editing buttons === */
#btn-add-stemma {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: var(--primary-color, #3b82f6) !important;
    color: white !important;
    border: none !important;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

#btn-add-stemma:hover {
    background: var(--primary-hover, #2563eb);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.25);
}

#btn-add-stemma:active {
    transform: translateY(0);
}

/* Upload stemma icon-button */
label[for="edit-stemmi-upload"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(99, 102, 241, 0.1) !important;
    color: #6366f1 !important;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

label[for="edit-stemmi-upload"]:hover {
    background: #6366f1;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

label[for="edit-stemmi-upload"] .material-symbols-outlined {
    font-size: 18px;
}

/* Stemma detail edit save/cancel */
#stemma-save-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: var(--primary-color, #3b82f6);
    color: white;
    border: 1.5px solid var(--primary-color, #3b82f6);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

#stemma-save-btn:hover {
    background: var(--primary-hover, #2563eb);
    border-color: var(--primary-hover, #2563eb);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

#stemma-cancel-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: transparent;
    color: #64748b;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

#stemma-cancel-btn:hover {
    background: #f8fafc;
    color: #1e293b;
    border-color: #cbd5e1;
}

/* Marriage edit save/cancel */
#marr-save-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: var(--primary-color, #3b82f6);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

#marr-save-btn:hover {
    background: var(--primary-hover, #2563eb);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.25);
}

#marr-cancel-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: transparent;
    color: #64748b;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

#marr-cancel-btn:hover {
    background: #f8fafc;
    color: #1e293b;
    border-color: #cbd5e1;
}

/* --- Legacy date-edit-group kept for family-edit template --- */
.date-edit-group:not(.inline-date-group) select,
.date-edit-group:not(.inline-date-group) input[type="text"] {
    padding: 4px 6px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 4px !important;
    font-size: 0.8rem !important;
    background: white !important;
    color: #334155 !important;
    outline: none !important;
    height: 28px !important;
    box-sizing: border-box !important;
}

.date-edit-group:not(.inline-date-group) {
    display: flex;
    gap: 2px;
    align-items: center;
    flex-wrap: nowrap;
    margin-top: 0;
    justify-content: flex-end;
    flex-grow: 1;
}

#edit-marr-day {
    width: 38px !important;
    flex-shrink: 0 !important;
}

#edit-marr-month {
    min-width: 70px;
}

.date-edit-group:not(.inline-date-group) select {
    cursor: pointer;
    min-width: 65px;
    flex-shrink: 1;
}