/* === CARDS CLIENTI === */
.client-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.client-card {
    background: var(--bg-surface-card);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 20px var(--shadow-md);
    transition: all 0.3s ease;
    border-left: 5px solid var(--gradient-app-start);
}

.client-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px var(--shadow-md);
}


.client-info h3 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 1.3em;
}

.client-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 15px 0;
    font-size: 0.9em;
}

.stat-item {
    background: var(--bg-surface-raised);
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
}

.stat-label {
    font-weight: bold;
    color: var(--text-secondary);
    display: block;
    font-size: 0.8em;
    margin-bottom: 2px;
}

.stat-value {
    color: var(--text-primary);
    font-size: 1.1em;
}

/* Client Tags Badges */
.client-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.client-tag-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 1px var(--shadow-lg);
  color: var(--text-inverse);
}

/* === BMI BADGES === */
.bmi-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: bold;
    margin-top: 5px;
}

.bmi-normale { background: var(--success-bg); color: var(--success-text); }
.bmi-sottopeso { background: var(--primary-bg); color: var(--primary-darker); }
.bmi-sovrappeso { background: var(--warning-bg); color: var(--warning-text); }
.bmi-obesita { background: var(--danger-bg); color: var(--danger-text); }



.client-azienda-fields {
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

/* ============================================
   PATCH per clienti.css
   Migrazione inline styles da client-detail.html
   ============================================ */

.energy-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.energy-card--bmr {
    background: var(--gradient-app);
    border-radius: 15px;
    padding: 25px;
    color: white;
    text-align: center;
}

.energy-card__subtitle {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 10px;
}

.energy-card__value {
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 5px;
}

.energy-card__unit {
    font-size: 14px;
    opacity: 0.9;
}

.energy-card--tdee {
    background: var(--gradient-pink-btn);
    border-radius: 15px;
    padding: 25px;
    color: white;
    text-align: center;
}

.calorie-section-title {
    color: var(--text-heading);
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 600;
}

.calorie-table--styled {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow-sm);
}

.calorie-th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--text-heading);
    border-bottom: 2px solid var(--border-medium);
}

.calorie-th--center {
    text-align: center;
}

.calorie-tr {
    border-bottom: 1px solid var(--border-light);
}

.calorie-td {
    padding: 15px;
}

.calorie-objective-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.calorie-objective-icon {
    font-size: 20px;
}

.calorie-objective-name {
    font-weight: 600;
    color: var(--text-heading);
}

.calorie-objective-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.calorie-td--deficit {
    padding: 15px;
    text-align: center;
    font-weight: 700;
    color: var(--danger);
}

.calorie-td--value {
    padding: 15px;
    text-align: center;
    color: var(--text-heading);
}

.calorie-td--maintenance {
    padding: 15px;
    text-align: center;
    font-weight: 700;
    color: var(--primary);
}

.calorie-td--surplus {
    padding: 15px;
    text-align: center;
    font-weight: 700;
    color: var(--success);
}

.tags-empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

/* =============================================
   PATCH-CLIENTI.CSS — Migrazione inline styles
   da client-list.html e index.html
   (componenti search + tag filter condivisi)
   ============================================= */

/* === SEARCH + TAG FILTER BAR === */
.client-search-container {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.client-search-input {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    padding: 12px 15px;
    border: 2px solid var(--border-medium);
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.2s;
    background-color: var(--bg-surface-card);
    color: var(--text-primary);
}


#client-search-input::placeholder,
#client_codice_fiscale::placeholder,
#home-client-search-input::placeholder,
#telefono::placeholder,
#email::placeholder,
#client_indirizzo::placeholder,
#client_citta::placeholder,
#client_provincia::placeholder {
    color: var(--text-placeholder);
}

.client-search-input:focus {
    border-color: var(--gradient-app-start);
    outline: none;
}

.tag-filter-wrapper {
    position: relative;
}

/* === TAG FILTER BUTTON === */
.tag-filter-btn {
    padding: 12px 15px;
    border: 2px solid var(--border-medium);
    border-radius: 10px;
    background: var(--bg-surface-card);
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-inverted);
}

.tag-filter-btn:hover {
    border-color: var(--gradient-app-start);
}

/* === TAG COUNT BADGE === */
.tag-count-badge {
    background: var(--gradient-app-start);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    align-items: center;
    justify-content: center;
    display: none;
}

/* === TAG DROPDOWN === */
.tag-filter-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 5px;
    background: var(--bg-surface);
    border: 2px solid var(--border-medium);
    border-radius: 10px;
    padding: 10px;
    min-width: 200px;
    box-shadow: 0 4px 12px var(--shadow-md);
    z-index: 100;
}

.tag-filter-list {
    max-height: 200px;
    overflow-y: auto;
}

.tag-filter-loading {
    color: var(--text-muted);
    text-align: center;
}

/* === DROPDOWN FOOTER (actions) === */
.tag-filter-actions {
    border-top: 1px solid var(--border-medium);
    margin-top: 10px;
    padding-top: 10px;
    display: flex;
    gap: 8px;
}

.tag-filter-btn-clear {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    background: var(--bg-surface-card-light);
    cursor: pointer;
    font-size: 13px;
}

.tag-filter-btn-clear:hover {
    background: var(--bg-surface-raised);
}

.tag-filter-btn-close {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 6px;
    background: var(--gradient-app-start);
    color: white;
    cursor: pointer;
    font-size: 13px;
}

.tag-filter-btn-close:hover {
    background: var(--primary-dark);
}

/* === TAG MODAL (shared) === */
.tag-modal-subtitle {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.tag-modal-empty {
    display: none;
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

.tag-modal-empty-hint {
    font-size: 13px;
}

/* =============================================
   PATCH-CLIENTS.CSS — Migrazione inline styles
   da clients.js
   ============================================= */

/* === EMPTY / ERROR / LOADING MESSAGES === */
.clients-empty-msg {
    text-align: center;
    color: var(--text-muted);
}

.clients-error-msg {
    text-align: center;
    color: var(--danger);
}

/* === "VIEW ALL" BUTTON WRAPPER === */
.clients-view-all {
    text-align: center;
    margin-top: 20px;
}

/* === CLIENT CARD ACTIONS === */
.client-card-actions {
    text-align: center;
    margin-top: 15px;
}

.client-btn-delete {
    margin-left: 5px;
}

/* === CLIENT DETAIL CARD === */
.client-detail-card {
    background: var(--bg-surface-card);
    font-size: 1.2em;
    padding: 25px;
    border-radius: 15px;
}



#livello-attivita option {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

#livello-attivita option:checked {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary);
}

.energy-native-select.energy-native-select--ready {
    display: none;
}

.kcal-section .energy-select-picker {
    width: 100%;
    min-width: 0;
    flex: none;
}

.kcal-section .energy-select-picker .progress-exercise-trigger {
    min-height: 42px;
    padding: 9px 36px 9px 12px;
    font-size: 14px;
}

.kcal-section .energy-select-picker .progress-exercise-label {
    min-width: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.2;
}

.kcal-section .energy-select-picker .progress-exercise-dropdown {
    max-height: 240px;
    z-index: 80;
}

.kcal-section .energy-select-picker .progress-exercise-option {
    font-size: 0.9rem;
}

.monitoring-control .energy-select-picker {
    width: 132px;
    min-width: 132px;
    flex: none;
}

.monitoring-control .energy-select-picker .progress-exercise-trigger {
    min-height: 34px;
    padding: 6px 30px 6px 10px;
    border-width: 1px;
    border-radius: 8px;
    font-size: 12px;
}

.monitoring-control .energy-select-picker.open .progress-exercise-trigger {
    border-radius: 8px 8px 0 0;
}

.monitoring-control .energy-select-picker .progress-exercise-dropdown {
    max-height: 180px;
    border-width: 1px;
    border-radius: 0 0 8px 8px;
    z-index: 90;
}

.monitoring-control .energy-select-picker .progress-exercise-option {
    padding: 8px 10px;
    font-size: 12px;
}

.pdf-upload-form .energy-select-picker,
.pdf-modal .energy-select-picker {
    width: 100%;
    min-width: 0;
    flex: none;
}

.pdf-upload-form .energy-select-picker .progress-exercise-trigger,
.pdf-modal .energy-select-picker .progress-exercise-trigger {
    min-height: 46px;
    margin-top: 10px;
}

.pdf-upload-form .energy-select-picker .progress-exercise-dropdown,
.pdf-modal .energy-select-picker .progress-exercise-dropdown {
    z-index: 110;
}

.client-detail-grid .kcal-section .energy-duration-input {
    width: 100%;
    height: 42px;
    min-height: 42px;
    padding: 9px 12px;
    margin-top: 0;
    border: 2px solid var(--border-medium);
    border-radius: 10px;
    background: var(--bg-input, var(--bg-surface-raised));
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.client-detail-grid .kcal-section .energy-duration-input:hover {
    border-color: var(--gradient-app-start);
}

.client-detail-grid .kcal-section .energy-duration-input:focus {
    outline: none;
    border-color: var(--gradient-app-start);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gradient-app-start) 14%, transparent);
}

.client-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.client-detail-title {
    margin: 0;
    color: #667eea;
}

.client-detail-edit-btn {
    font-size: 0.9em;
}

.client-detail-row {
    margin-top: 15px;
}

.client-detail-field {
    margin-top: 15px;
}

/* === CLIENT DETAIL: TAGS SECTION === */
.client-detail-tags-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-medium);
}

.client-detail-tags-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.client-detail-tags-display {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.client-no-tags {
    color: var(--text-primary);
    font-size: 13px;
}

/* === TAG MODAL: CHECKBOX LABELS === */
.tag-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tag-description {
    color: var(--text-muted);
    font-size: 12px;
}

/* === TAG FILTER: DROPDOWN LIST ITEMS === */
.tag-filter-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.tag-filter-label:hover {
    background: var(--bg-surface-raised);
}

.tag-filter-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.tag-list-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 10px;
}

/* === NO RESULTS EMPTY STATE === */
.clients-no-results {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.clients-no-results-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.clients-no-results-title {
    font-size: 16px;
    margin: 0;
}

.clients-no-results-hint {
    font-size: 14px;
    margin-top: 8px;
    color: var(--text-hint);
}

/* === FILTER RESULTS COUNT === */
.clients-results-count {
    color: var(--text-muted);
    margin-bottom: 15px;
    font-size: 14px;
}

/* Specifico per il campo indirizzo nel new-client-form */
#new-client-form .form-group-indirizzo {
    flex: 2;
}

/* NOTE: background-color on .client-tag-badge is dynamic
   (driven by tag.colore from DB). Kept as inline. */

   @media (max-width: 900px) {
    .client-detail-card {
        padding: 16px;
        font-size: 1rem;
    }

}

@media (max-width: 480px) {
    .client-detail-card {
        padding: 12px;
        font-size: 0.95rem;
    }

    /* Tags header: titolo e bottone Gestisci in colonna */
    .client-detail-tags-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    /* Righe info: riduci margini */
    .client-detail-row,
    .client-detail-field {
        margin-top: 10px;
    }
}


#notes-save-status.ok { color: var(--success); }
#notes-save-status.warn { color: var(--warning-medium); }
#notes-save-status.err { color: var(--danger); }
#notes-save-status.info { color: var(--info); }

.form-group > .form-control {
    background-color: var(--bg-surface-card);
    color: var(--text-primary);
}

/* ===== Client Select ===== */

.client-select {
    position: relative;
    width: 100%;
}

.client-select-trigger {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-medium);
    background: var(--bg-surface-card);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px var(--shadow-sm);
    margin-top: 10px;
    text-align: left;
}
.client-select-trigger:hover {
    border-color: var(--gradient-app-start);
}

.client-select-arrow {
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    line-height: 1;
    flex-shrink: 0;
}

.client-select:has(.client-select-dropdown.active) .client-select-trigger {
    border-radius: 10px 10px 0 0;
    border-bottom-color: transparent;
    border-color: var(--gradient-app-start);
}

.client-select:has(.client-select-dropdown.active) .client-select-arrow {
    transform: rotate(180deg);
}

.client-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
     background: var(--bg-surface-card);
    border: 2px solid var(--gradient-app-start);
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 10px 10px;
    margin-top: -2px;
    max-height: 260px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    box-shadow: 0 8px 24px var(--shadow-md);
    scrollbar-width: thin;
}

.client-select-dropdown.active {
    display: block;
}

.client-select-option {
    padding: 10px 14px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.9em;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-lightest);
}

.client-select-option:last-child {
    border-bottom: none;
}

.client-select-option:hover {
    background: var(--bg-surface-raised);
}

.client-select-option.selected {
    background: var(--primary-bg-light);
    color: var(--gradient-app-start);
    font-weight: 600;
}

/* === FEEDBACK TAB — LAYOUT DUE COLONNE === */
.feedback-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 32px;
    align-items: start;
}

.feedback-col-left  { min-width: 0; }
.feedback-col-right { min-width: 0; }

/* Griglia foto progress */
.photos-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.photo-thumb-wrap {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-surface-raised);
    cursor: pointer;
    transition: transform .15s;
}
.photo-thumb-wrap:hover { transform: scale(1.02); }

.photo-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-thumb-date {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,.55));
    color: #fff;
    font-size: .72rem;
    padding: 14px 6px 5px;
    text-align: center;
}

.photo-delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,.5);
    border: none;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .15s;
}
.photo-thumb-wrap:hover .photo-delete-btn { opacity: 1; }

/* Lightbox overlay */
.photo-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.88);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.photo-lightbox img {
    max-width: 92vw;
    max-height: 90vh;
    border-radius: 10px;
    object-fit: contain;
}
.photo-lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
}

/* Responsive: una sola colonna */
@media (max-width: 860px) {
    .feedback-layout {
        grid-template-columns: 1fr;
    }
}
