/* costi.css — Stili specifici per la pagina /costi (standalone) */

/* ─── Layout pagina ───────────────────────────────────────────── */
.costi-page-main {
    padding-top: calc(var(--header-h, 76px) + 1.5rem);
}

/* ─── Savings card ───────────────────────────────────────────── */
.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.chart-title {
    font-size: 1.125rem;
    color: var(--text);
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-title i { color: var(--primary); font-size: 1rem; }

.chart-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 0.5rem 0;
}

.savings-projection-card {
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.08), rgba(46, 213, 115, 0.05));
    border-color: rgba(39, 174, 96, 0.3);
    margin-bottom: 1rem;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
    padding: 0.9rem 1.25rem 0.75rem;
}

.savings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin: 0.6rem 0 0.5rem;
}

.savings-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    text-align: center;
}

.savings-label {
    font-size: 0.75rem;
    color: var(--text-muted, #5D7A94);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.savings-amount {
    font-size: 1.3rem;
    font-weight: 700;
    color: #27ae60;
}

.savings-amount.savings-highlight {
    font-size: 1.65rem;
    color: #2ed573;
}

.savings-cta {
    font-size: 0.78rem;
    color: var(--text-secondary, #A0B4C5);
    margin: 0;
    padding-top: 0.4rem;
    border-top: 1px solid rgba(39, 174, 96, 0.15);
}

/* ─── Form card ──────────────────────────────────────────────── */
#costi-section .form-card {
    max-width: 520px;
}

#costi-form {
    margin-top: 1.5rem;
}

.costi-field-row {
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.costi-field-label {
    white-space: nowrap;
    margin-bottom: 0 !important;
    text-align: right;
    flex-shrink: 0;
    min-width: 7rem;
}

.costi-field-input {
    width: 230px !important;
    flex: none;
    text-align: center;
}

/* ─── Input importo ──────────────────────────────────────────── */
.costi-input-wrap {
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-sizing: border-box;
}

.costi-input-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb, 0, 116, 217), 0.12);
}

.costi-currency-sym {
    padding: 0.625rem 0.15rem 0.625rem 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--input-bg);
    user-select: none;
    line-height: 1;
}

.costi-input-wrap input.costi-amount-input {
    flex: 1 1 auto;
    width: 100%;
    border: none !important;
    outline: none;
    background: transparent;
    padding: 0.625rem 0.5rem;
    font-size: 0.9375rem !important;
    font-weight: 600;
    color: var(--primary);
    font-family: inherit;
    text-align: center;
    -moz-appearance: textfield;
    box-shadow: none !important;
}

.costi-amount-input::-webkit-outer-spin-button,
.costi-amount-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ─── Input data/ora ─────────────────────────────────────────── */
.costi-datetime-input {
    width: 100%;
    box-sizing: border-box;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--text);
    font-family: inherit;
    text-align: center;
    letter-spacing: 0.04em;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.costi-datetime-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb, 0, 116, 217), 0.12);
}

/* ─── Bottone salva acquisto ─────────────────────────────────── */
.costi-submit-row {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

.costi-submit-btn {
    width: auto;
    padding: 0.875rem 2rem;
    background: var(--card-bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 2rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    min-height: 50px;
    height: auto;
    min-width: unset;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
    outline: none;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.costi-submit-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition);
    border-radius: inherit;
    z-index: -1;
}

.costi-submit-btn:hover::before {
    transform: scaleX(1);
}

.costi-submit-btn:hover {
    color: white;
    border-color: var(--primary);
}

/* ─── Lista acquisti ─────────────────────────────────────────── */
#costi-list-container h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--text);
}

.cost-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.cost-item:last-child {
    border-bottom: none;
}

.cost-item-view {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.cost-date {
    color: var(--text-muted);
    font-size: 0.8125rem;
    white-space: nowrap;
    flex: 1;
}

.cost-amount {
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 0.9375rem;
    text-align: right;
}

.cost-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
    align-items: center;
    margin-left: 1rem;
}

.cost-actions .edit-btn,
.cost-actions .delete-btn {
    width: 2rem !important;
    height: 2rem !important;
    font-size: 0.875rem !important;
}

@media (max-width: 768px) {
    .cost-actions {
        display: none;
    }
}

/* Pannello editing inline */
.cost-item.editing {
    border-bottom: 1px solid var(--primary);
    background: var(--card-bg);
}

.cost-item-edit {
    padding: 0.75rem 0 0.5rem;
}

.cost-edit-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cost-edit-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.cost-edit-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cost-edit-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.cost-edit-btns {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    justify-content: flex-end;
}

/* ─── Statistiche ────────────────────────────────────────────── */
.costi-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.costi-stat-card {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-align: center;
}

.costi-stat-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.3;
}

.costi-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.costi-stat-value-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.3rem;
}

.costi-stat-delta {
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
}

.costi-stat-delta.delta-down,
.costi-stat-delta.delta-negative {
    color: #2ecc71;
}

.costi-stat-delta.delta-up,
.costi-stat-delta.delta-positive {
    color: #e74c3c;
}

.costi-stat-delta.delta-neutral {
    color: var(--text-muted);
    font-weight: 500;
}

/* ─── Bottone "mostra acquisti recenti" toggle ───────────────── */
#costi-acquisti-toggle-row {
    margin-top: 1rem;
    text-align: center;
}

.costi-acquisti-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.4rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.costi-acquisti-toggle-btn:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

#costi-list-container {
    margin-top: 1rem;
}

/* ─── Bottone "mostra altri" ─────────────────────────────────── */
.costi-load-more-btn {
    display: block;
    width: fit-content;
    margin: 0.5rem auto 0;
    padding: 0.55rem 1.25rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.costi-load-more-btn:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

/* ─── Empty state ────────────────────────────────────────────── */
.empty-state {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem 0;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .costi-datetime-input {
        padding: 0.6rem 0.5rem;
        font-size: 16px;
        letter-spacing: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .costi-input-wrap input.costi-amount-input {
        font-size: 16px !important;
    }

    .costi-field-row {
        justify-content: flex-start;
    }

    .costi-field-input {
        width: auto !important;
        flex: 1 !important;
    }
}

@media (max-width: 480px) {
    .cost-edit-row {
        grid-template-columns: 1fr;
    }
}
