/* =========================================================
   RICETTARIO TONY
   Apple-inspired UI
   Versione 15
   ========================================================= */

/* =========================
   DESIGN TOKENS
   ========================= */

:root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-alt: #fbfbfd;

    --text: #1d1d1f;
    --text-strong: #000000;
    --text-soft: #2c2c2e;

    --link: #8a4b1f;
    --link-hover: #633414;

    --accent: #b86a32;
    --accent-hover: #8f4f24;

    --danger: #b00020;
    --danger-bg: #fff2f2;

    --success: #1f7a3f;
    --success-bg: #eef8f1;

    --border: #d2d2d7;
    --border-soft: #e8e8ed;

    --radius-sm: 10px;
    --radius-md: 18px;
    --radius-lg: 28px;

    --max: 1080px;
    --max-readable: 780px;

    --space-page: 32px;
    --space-section: 40px;

    --font: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

/* =========================
   RESET
   ========================= */

* {
    box-sizing: border-box;
}

html {
    font-size: 100%;
}

body {
    margin: 0;
    padding: var(--space-page);

    background: var(--bg);
    color: var(--text);

    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--link);
    outline-offset: 3px;
}

/* =========================
   LAYOUT GENERALE
   ========================= */

main,
body > h1,
body > h2,
body > h3,
body > p,
body > form,
body > table,
body > ul,
body > .success,
body > .error,
body > .messaggio-successo,
body > .messaggio-errore {
    width: min(100%, var(--max));
    margin-left: auto;
    margin-right: auto;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: var(--max-readable);
    margin-bottom: 14px;

    color: var(--text-strong);
    font-size: clamp(2.4rem, 5vw, 4rem);
    line-height: 1.02;
    letter-spacing: -0.06em;
    font-weight: 720;
}

h2 {
    margin-top: 46px;
    margin-bottom: 18px;

    color: var(--text-strong);
    font-size: clamp(1.6rem, 3vw, 2.25rem);
    line-height: 1.08;
    letter-spacing: -0.045em;
    font-weight: 700;
}

h3 {
    margin-top: 28px;
    margin-bottom: 12px;

    color: var(--text-strong);
    font-size: 1.2rem;
    font-weight: 700;
}

p {
    margin-bottom: 18px;

    color: var(--text-soft);
    font-size: 1rem;
}

/* =========================
   MENU
   ========================= */

.topbar {
    width: min(100%, var(--max));
    margin: 0 auto 48px auto;
}

.topbar-contenuto {
    min-height: 48px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;

    padding: 0 4px 16px 4px;

    border-bottom: 1px solid var(--border-soft);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;

    color: var(--text-strong);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.035em;
    white-space: nowrap;
    text-decoration: none;
}

.brand:hover {
    color: var(--text-strong);
    text-decoration: none;
}

.brand-icon {
    width: 28px;
    height: 28px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;
    background: #f4e3e6;
    color: var(--accent-hover);

    font-size: 0.95rem;
    line-height: 1;
}

.brand-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.nav-menu {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 22px;

    list-style: none;
    margin: 0;
    padding: 0;

    background: transparent;
    border: none;
}

.nav-menu li {
    margin: 0;
    padding: 0;
}

.nav-menu a {
    color: var(--text-soft);

    font-size: 0.92rem;
    font-weight: 520;
    text-decoration: none;
}

.nav-menu a:hover {
    color: var(--text-strong);
    text-decoration: none;
}

.nav-logout {
    color: var(--danger) !important;
}

/* =========================
   FORMS
   ========================= */

form {
    margin-bottom: var(--space-section);
    padding: 28px;

    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
}

label {
    display: block;

    margin-bottom: 8px;

    color: var(--text-strong);
    font-size: 0.95rem;
    font-weight: 620;
}

input,
select,
textarea {
    width: 100%;
    min-height: 46px;
    padding: 11px 13px;

    background: #ffffff;
    color: var(--text);

    border: 1px solid var(--border);
    border-radius: var(--radius-sm);

    font: inherit;
}

textarea {
    min-height: 140px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #515154;
    opacity: 1;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--link);
}

button,
input[type="submit"] {
    min-height: 44px;
    padding: 10px 18px;

    border: none;
    border-radius: 999px;

    background: var(--accent);
    color: #ffffff;

    font: inherit;
    font-size: 0.95rem;
    font-weight: 650;

    cursor: pointer;
}

button:hover,
input[type="submit"]:hover {
    background: var(--accent-hover);
}

/* =========================
   TABLE
   ========================= */

table {
    width: 100%;
    border-collapse: collapse;

    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    overflow: hidden;
}

th,
td {
    padding: 14px 16px;

    border-bottom: 1px solid var(--border-soft);

    color: var(--text);
    text-align: left;
    vertical-align: top;
}

th {
    background: var(--surface-alt);

    color: var(--text-strong);
    font-size: 0.78rem;
    font-weight: 720;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

td {
    font-size: 0.96rem;
    font-weight: 400;
}

td strong {
    font-weight: 560;
}

tr:last-child td {
    border-bottom: none;
}

/* =========================
   MESSAGGI
   ========================= */

.success,
.messaggio-successo {
    padding: 16px 18px;
    margin-bottom: 28px;

    background: var(--success-bg);
    border: 1px solid #b9e0c6;
    border-radius: var(--radius-md);

    color: var(--success);
    font-weight: 650;
}

.error,
.messaggio-errore {
    padding: 16px 18px;
    margin-bottom: 28px;

    background: var(--danger-bg);
    border: 1px solid #f0bbbb;
    border-radius: var(--radius-md);

    color: var(--danger);
    font-weight: 650;
}

/* =========================
   RICERCA RICETTE
   ========================= */

.form-ricerca {
    display: grid;
    grid-template-columns: 1.4fr 0.85fr 0.85fr;
    gap: 18px;
    align-items: end;

    margin-top: 24px;
    margin-bottom: 44px;
}

.campo-ricerca {
    min-width: 0;
}

.azioni-ricerca {
    grid-column: 1 / -1;

    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 18px;

    padding-top: 4px;
}

.azioni-ricerca a {
    color: var(--link);
    font-weight: 620;
    text-decoration: none;
}

.azioni-ricerca a:hover {
    text-decoration: underline;
}

/* =========================
   PAGINA RICETTE
   ========================= */

.lista-ricette {
    list-style: none;

    padding: 0;
    margin-top: 12px;

    background: transparent;
    border: none;
}

.card-ricetta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: center;

    padding: 20px 4px;
    margin: 0;

    border-bottom: 1px solid var(--border-soft);
}

.card-ricetta:first-child {
    border-top: 1px solid var(--border-soft);
}

.card-ricetta-header {
    display: block;
}

.card-ricetta strong {
    color: var(--text-strong);
    font-size: 1.08rem;
    font-weight: 650;
    letter-spacing: -0.015em;
}

.card-ricetta a {
    color: var(--text-strong);
    text-decoration: none;
}

.card-ricetta a:hover {
    color: var(--link);
    text-decoration: none;
}

.meta-ricetta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;

    margin-top: 7px;

    color: var(--text-soft);
    font-size: 0.92rem;
    font-weight: 480;
}

.meta-ricetta span {
    color: var(--text-soft);
}

.meta-ricetta span::after {
    content: "·";
    margin-left: 7px;
    color: var(--text-soft);
}

.meta-ricetta span:last-child::after {
    content: "";
    margin-left: 0;
}

.descrizione-ricetta {
    display: none;
}

.azioni-card {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 16px;

    margin: 0;

    white-space: nowrap;
}

.azioni-card a {
    color: var(--link);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}

.azioni-card a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.azioni-card .link-danger {
    color: var(--danger);
}

/* =========================
   ADMIN INDEX
   ========================= */

.admin-page {
    width: min(100%, 980px);
    margin: 0 auto;
}

.admin-hero {
    margin-bottom: 34px;
    padding-bottom: 28px;

    border-bottom: 1px solid var(--border-soft);
}

.eyebrow {
    display: block;

    margin-bottom: 12px;

    color: var(--text-strong);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.admin-hero h1 {
    margin-bottom: 12px;
}

.admin-hero p {
    max-width: 620px;
    margin-bottom: 0;

    color: var(--text-soft);
    font-size: 1.05rem;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;

    margin-bottom: 44px;
}

.quick-action {
    display: block;

    min-height: 150px;
    padding: 26px;

    background: var(--surface);
    border: none;
    border-radius: var(--radius-lg);

    color: var(--text-strong);
    text-decoration: none;
}

.quick-action:hover {
    background: #fdfdfd;
    text-decoration: none;
}

.quick-action.primary {
    background: var(--accent);
    color: #ffffff;
}

.quick-action.primary:hover {
    background: var(--accent-hover);
}

.quick-action span {
    display: block;

    margin-bottom: 8px;

    color: inherit;
    font-size: 1.35rem;
    line-height: 1.1;
    font-weight: 720;
    letter-spacing: -0.035em;
}

.quick-action small {
    display: block;

    color: var(--text-soft);
    font-size: 0.96rem;
    line-height: 1.45;
    font-weight: 480;
}

.quick-action.primary small {
    color: #ffffff;
}

.admin-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.admin-panel {
    padding: 26px;

    background: var(--surface);
    border-radius: var(--radius-lg);
}

.admin-panel h2 {
    margin-top: 0;
    margin-bottom: 16px;

    color: var(--text-strong);
    font-size: 1.35rem;
}

.admin-panel a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    padding: 15px 0;

    border-bottom: 1px solid var(--border-soft);

    color: var(--text-strong);
    font-size: 1rem;
    font-weight: 580;
    text-decoration: none;
}

.admin-panel a:last-child {
    border-bottom: none;
}

.admin-panel a::after {
    content: "→";
    color: var(--link);
    font-weight: 700;
}

.admin-panel a:hover {
    color: var(--link);
    text-decoration: none;
}

/* =========================
   DETTAGLIO RICETTA
   ========================= */

.recipe-view {
    width: min(100%, 980px);
    margin: 0 auto;
}

.recipe-back {
    margin-bottom: 24px;
}

.recipe-back a {
    color: var(--link);
    font-size: 0.95rem;
    font-weight: 620;
    text-decoration: none;
}

.recipe-back a:hover {
    text-decoration: underline;
}

.recipe-header {
    margin-bottom: 26px;
    padding-bottom: 28px;

    border-bottom: 1px solid var(--border-soft);
}

.recipe-category {
    margin-bottom: 12px;

    color: var(--text-strong);
    font-size: 0.82rem;
    font-weight: 720;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.recipe-header h1 {
    margin-bottom: 14px;
}

.recipe-description {
    max-width: 760px;
    margin-bottom: 0;

    color: var(--text-soft);
    font-size: 1.05rem;
}

.recipe-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;

    margin-bottom: 24px;
}

.recipe-meta div {
    min-width: 150px;
    padding: 14px 16px;

    background: var(--surface);
    border-radius: var(--radius-md);
}

.recipe-meta span {
    display: block;

    margin-bottom: 4px;

    color: var(--text-soft);
    font-size: 0.82rem;
    font-weight: 620;
}

.recipe-meta strong {
    display: block;

    color: var(--text-strong);
    font-size: 1rem;
    font-weight: 700;
}

.recipe-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;

    margin-bottom: 34px;
    padding: 0;

    background: transparent;
    border: none;
}

.recipe-actions a {
    min-height: 42px;
    padding: 10px 16px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    background: var(--surface);
    color: var(--link);

    border-radius: 999px;

    font-size: 0.95rem;
    font-weight: 650;
    text-decoration: none;
}

.recipe-actions a:hover {
    background: #e8f2ff;
    color: var(--link-hover);
    text-decoration: none;
}

.recipe-actions .btn-main {
    background: var(--accent);
    color: #ffffff;
}

.recipe-actions .btn-main:hover {
    background: var(--accent-hover);
    color: #ffffff;
}

.recipe-actions .btn-danger {
    color: var(--danger);
}

.actions-separator {
    width: 1px;
    height: 28px;
    background: var(--border);
}

.recipe-section {
    margin-bottom: 24px;
    padding: 28px;

    background: var(--surface);
    border-radius: var(--radius-lg);
}

.recipe-section h2 {
    margin-top: 0;
    margin-bottom: 20px;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;

    margin-bottom: 20px;
}

.section-title-row h2 {
    margin-bottom: 0;
}

.recipe-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.recipe-table {
    min-width: 620px;
}

.recipe-text-box,
.recipe-procedure {
    color: var(--text-soft);
    line-height: 1.8;
    font-size: 1rem;
}

.recipe-procedure {
    max-width: 820px;
}

.empty-text {
    margin: 0;

    color: var(--text-soft);
    font-style: normal;
    font-weight: 500;
}

.recipe-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* =========================
   INGREDIENTI PIÙ LEGGERI
   ========================= */

.recipe-table td:first-child,
.tabella-ingredienti-dettaglio td:first-child,
table td:first-child {
    font-weight: 420;
}

.recipe-table td strong,
.tabella-ingredienti-dettaglio td strong,
table td strong {
    font-weight: 520;
}

/* =========================
   LISTE GENERICHE
   ========================= */

ul:not(.nav-menu):not(.lista-ricette) {
    padding: 26px;

    background: var(--surface);
    border-radius: var(--radius-lg);
}

li {
    margin-bottom: 8px;
}

/* =========================
   RESPONSIVE
   ========================= */

@media screen and (max-width: 900px) {
    body {
        padding: 22px;
    }

    .topbar-contenuto {
        align-items: flex-start;
        flex-direction: column;
        gap: 16px;
    }

    .nav-menu {
        justify-content: flex-start;
        gap: 14px 20px;
    }

    .form-ricerca {
        grid-template-columns: 1fr;
    }

    .card-ricetta {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .azioni-card {
        flex-wrap: wrap;
        gap: 12px 16px;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .admin-columns {
        grid-template-columns: 1fr;
    }

    .recipe-bottom-grid {
        grid-template-columns: 1fr;
    }

    .recipe-actions {
        display: flex;
    }

    .actions-separator {
        display: none;
    }
}

@media screen and (max-width: 560px) {
    body {
        padding: 16px;
    }

    .topbar {
        margin-bottom: 34px;
    }

    .brand {
        font-size: 1.08rem;
    }

    .nav-menu {
        gap: 10px 14px;
    }

    form,
    .recipe-section,
    .admin-panel,
    .quick-action {
        padding: 22px;
    }

    .recipe-meta {
        display: grid;
        grid-template-columns: 1fr;
    }

    th,
    td {
        padding: 12px 10px;
    }
}
/* =========================
   CALCOLA PORZIONI
   ========================= */

.portion-page {
    width: min(100%, 980px);
    margin: 0 auto;
}

.portion-back {
    margin-bottom: 24px;
}

.portion-back a {
    color: var(--link);
    font-weight: 620;
    text-decoration: none;
}

.portion-back a:hover {
    text-decoration: underline;
}

.portion-header {
    margin-bottom: 28px;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--border-soft);
}

.portion-kicker {
    margin-bottom: 12px;

    color: var(--text-strong);
    font-size: 0.82rem;
    font-weight: 720;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.portion-header h1 {
    margin-bottom: 14px;
}

.portion-header p {
    max-width: 760px;
    margin-bottom: 0;

    color: var(--text-soft);
    font-size: 1.05rem;
}

.portion-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;

    margin-bottom: 28px;
}

.portion-summary div {
    padding: 16px;

    background: var(--surface);
    border-radius: var(--radius-md);
}

.portion-summary span {
    display: block;

    margin-bottom: 5px;

    color: var(--text-soft);
    font-size: 0.82rem;
    font-weight: 620;
}

.portion-summary strong {
    display: block;

    color: var(--text-strong);
    font-size: 1.05rem;
    font-weight: 700;
}

.portion-card {
    margin-bottom: 24px;
    padding: 28px;

    background: var(--surface);
    border-radius: var(--radius-lg);
}

.portion-card h2 {
    margin-top: 0;
    margin-bottom: 20px;
}

.portion-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: end;

    margin: 0;
    padding: 0;

    background: transparent;
    border: none;
    border-radius: 0;
}

.portion-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.portion-table {
    min-width: 680px;
}

.portion-result {
    color: var(--text-strong);
    font-weight: 700;
}

.portion-links {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;

    margin-top: 8px;
    margin-bottom: 20px;
}

.portion-links a {
    color: var(--link);
    font-weight: 620;
    text-decoration: none;
}

.portion-links a:hover {
    text-decoration: underline;
}

@media screen and (max-width: 900px) {
    .portion-summary {
        grid-template-columns: 1fr 1fr;
    }

    .portion-form {
        grid-template-columns: 1fr;
    }

    .portion-form button {
        width: 100%;
    }
}

@media screen and (max-width: 560px) {
    .portion-summary {
        grid-template-columns: 1fr;
    }

    .portion-card {
        padding: 22px;
    }
}