/* DiscoDisco — foglio di stile unico. */

:root {
    --bg: #f6f4f1;
    --surface: #ffffff;
    --border: #e2ddd7;
    --text: #23201d;
    --text-muted: #6f6862;
    --accent: #c0562e;
    --accent-dark: #9c4525;
    --ok-bg: #e8f4ec;
    --ok-text: #1d6b3f;
    --err-bg: #fbeae8;
    --err-text: #a8321f;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 12px rgba(0, 0, 0, .04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* --- Header --- */

.site-header {
    background: #1c1a18;
    color: #f3efeb;
    border-bottom: 3px solid var(--accent);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 28px;
    min-height: 62px;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: .3px;
    color: #fff;
    text-decoration: none;
}

.logo-disc {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0 2px, var(--accent) 2px 7px, #2b2b2b 7px 100%);
    box-shadow: 0 0 0 1px #444;
}

.logo-img { display: block; width: 30px; height: 30px; border-radius: 50%; }

.nav { display: flex; gap: 20px; margin-right: auto; flex-wrap: wrap; }

.nav a {
    color: #cfc8c1;
    text-decoration: none;
    font-size: .94rem;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
}
.nav a:hover { color: #fff; border-bottom-color: var(--accent); }

.user-menu { display: flex; align-items: center; gap: 14px; font-size: .88rem; }
.user-name { color: #9a938c; }
.link-muted { color: #cfc8c1; text-decoration: none; }
.link-muted:hover { color: #fff; }

.link-button {
    background: none; border: 0; padding: 0;
    color: #cfc8c1; font: inherit; cursor: pointer;
}
.link-button:hover { color: #fff; text-decoration: underline; }

.inline { display: inline; }

/* --- Struttura --- */

main.wrap { padding-top: 26px; padding-bottom: 60px; min-height: calc(100vh - 130px); }

.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}

h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -.2px; }
h2 { font-size: 1.1rem; margin: 0 0 14px; }
.subtitle { color: var(--text-muted); font-size: .9rem; margin: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}

/* --- Bottoni --- */

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit; font-size: .9rem;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: #f2efec; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-danger { color: #a8321f; border-color: #e6c4bd; }
.btn-danger:hover { background: var(--err-bg); }

.btn-sm { padding: 5px 10px; font-size: .82rem; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* --- Form --- */

.field { margin-bottom: 15px; }

label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: #4a4540;
    margin-bottom: 5px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"],
select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #d5cfc8;
    border-radius: 7px;
    background: #fff;
    font: inherit;
    font-size: .92rem;
    color: var(--text);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(192, 86, 46, .35);
    outline-offset: 0;
    border-color: var(--accent);
}

textarea { resize: vertical; min-height: 90px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 18px; }

.hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin: 0 0 18px;
    background: var(--surface);
}

legend {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    padding: 0 8px;
}

.required { color: var(--accent); }

/* --- Avvisi --- */

.alert {
    padding: 11px 15px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: .9rem;
    border: 1px solid transparent;
}
.alert-success { background: var(--ok-bg); color: var(--ok-text); border-color: #bfe0cb; }
.alert-error { background: var(--err-bg); color: var(--err-text); border-color: #f0cdc6; }
.alert-info { background: #eaf1f7; color: #2a5674; border-color: #c8dcea; }

/* --- Tabella libreria --- */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; font-size: .89rem; }

th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #efebe6; }

th {
    background: #faf8f6;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    font-weight: 700;
    white-space: nowrap;
    position: sticky; top: 0;
}

th a { color: inherit; text-decoration: none; }
th a:hover { color: var(--accent); }
th .sorted { color: var(--accent); }

tbody tr:hover { background: #fbf9f7; }
tbody tr:last-child td { border-bottom: 0; }

td.cover { width: 46px; padding: 6px 12px; }

.cover-thumb {
    width: 38px; height: 38px;
    border-radius: 4px;
    object-fit: cover;
    background: #eee;
    display: block;
}

.cover-empty {
    width: 38px; height: 38px;
    border-radius: 4px;
    background: repeating-linear-gradient(45deg, #efeae5, #efeae5 4px, #e7e1db 4px, #e7e1db 8px);
}

.row-title { font-weight: 600; }
.row-title a { color: inherit; text-decoration: none; }
.row-title a:hover { color: var(--accent); text-decoration: underline; }

.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }

/* --- Ricerca --- */

.search-card { margin-bottom: 18px; }

.search-main { display: flex; gap: 10px; margin-bottom: 12px; }
.search-main input { flex: 1; }

.search-advanced { border-top: 1px dashed var(--border); padding-top: 14px; margin-top: 4px; }

details.filters summary {
    cursor: pointer;
    font-size: .84rem;
    color: var(--text-muted);
    user-select: none;
}
details.filters summary:hover { color: var(--accent); }

/* --- Paginazione --- */

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }

.pagination a, .pagination span {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    text-decoration: none;
    color: var(--text);
    font-size: .86rem;
}
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pagination .disabled { opacity: .4; }

/* --- Scheda disco --- */

.record-layout { display: grid; grid-template-columns: 300px 1fr; gap: 26px; align-items: start; }

.record-covers { display: grid; gap: 14px; }

.cover-large {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff;
    display: block;
}

.cover-placeholder {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius);
    border: 1px dashed #cfc8c1;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    font-size: .84rem;
    text-align: center;
    background: repeating-linear-gradient(45deg, #faf8f6, #faf8f6 6px, #f3efeb 6px, #f3efeb 12px);
}

.cover-caption { font-size: .76rem; color: var(--text-muted); text-align: center; margin-top: 5px; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px 22px; }

.detail-item .detail-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 2px;
}
.detail-item .detail-value { font-size: .95rem; }

.record-notes {
    white-space: pre-wrap;
    font-size: .88rem;
    background: #faf8f6;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 13px;
    margin-top: 6px;
    max-height: 320px;
    overflow-y: auto;
}

/* --- Vuoto --- */

.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty h2 { color: var(--text); }
.empty-disc {
    width: 64px; height: 64px; margin: 0 auto 18px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0 6px, var(--accent) 6px 20px, #2b2b2b 20px 100%);
    opacity: .5;
}

/* --- Login --- */

.login-page {
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: linear-gradient(150deg, #1c1a18, #33302c);
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border-radius: 14px;
    padding: 34px;
    width: 100%; max-width: 380px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .3);
}

.login-logo { display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.login-logo img { width: 118px; height: 118px; }
.login-logo span.name { font-size: 1.35rem; font-weight: 700; }
.login-sub { text-align: center; color: var(--text-muted); font-size: .9rem; margin: 0 0 22px; }

.remember {
    display: flex; align-items: center; gap: 9px;
    font-size: .9rem; color: var(--text-muted);
    margin: 4px 0 18px; cursor: pointer;
}
.remember input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

.login-back { text-align: center; margin: 20px 0 0; font-size: .85rem; }
.login-back a { color: var(--text-muted); text-decoration: none; }
.login-back a:hover { color: var(--accent); }

/* --- Discogs / suggerimenti --- */

.discogs-bar {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap;
    padding: 13px 16px;
    background: #eef3f7;
    border: 1px solid #cfdfeb;
    border-radius: var(--radius);
    margin-bottom: 18px;
}
.discogs-bar .spacer { margin-left: auto; }
.discogs-bar p { margin: 0; font-size: .84rem; color: #2a5674; }

.suggestion {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 5px;
    padding: 3px 8px;
    background: #fff6e8;
    border: 1px solid #f0d9ae;
    border-radius: 5px;
    font-size: .78rem;
    color: #8a5a12;
    cursor: pointer;
    width: fit-content;
    max-width: 100%;
    text-align: left;
    font-family: inherit;
}
.suggestion:hover { background: #ffedd0; border-color: #e0bd76; }
.suggestion .sugg-value { font-weight: 600; word-break: break-word; }
.suggestion::before { content: "Discogs:"; opacity: .7; flex-shrink: 0; }

.field-filled { animation: flash-fill 1.1s ease-out; }
@keyframes flash-fill {
    0% { background: #fff2d4; }
    100% { background: #fff; }
}

.candidates { display: grid; gap: 10px; margin-top: 14px; max-height: 420px; overflow-y: auto; }

.candidate {
    display: flex; gap: 13px; align-items: center;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    width: 100%;
    font: inherit;
}
.candidate:hover { border-color: var(--accent); background: #fdf7f4; }

.candidate img, .candidate .cand-noimg {
    width: 54px; height: 54px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    background: #eee;
}
.candidate .cand-noimg {
    background: repeating-linear-gradient(45deg, #efeae5, #efeae5 4px, #e7e1db 4px, #e7e1db 8px);
}
.candidate .cand-body { min-width: 0; }
.candidate .cand-title { font-weight: 600; font-size: .9rem; }
.candidate .cand-meta { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

/* Avviso "non e' un vinile" sui risultati della ricerca allargata. */
.cand-nonvinyl {
    display: inline-block;
    margin-top: 3px;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: .74rem;
    font-weight: 600;
    background: var(--err-bg);
    color: var(--err-text);
}

/* --- Modale --- */

.modal {
    position: fixed; inset: 0;
    background: rgba(20, 18, 16, .55);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    z-index: 50;
}
.modal[hidden] { display: none; }

.modal-box {
    background: var(--surface);
    border-radius: 12px;
    padding: 22px;
    width: 100%; max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-head h2 { margin: 0; }

.modal-close {
    background: none; border: 0; cursor: pointer;
    font-size: 1.5rem; line-height: 1; color: var(--text-muted);
    padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

/* --- Immagini nel form --- */

.image-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.image-slot { text-align: center; }
.image-slot .slot-label { font-size: .8rem; font-weight: 600; margin-bottom: 7px; }

.slot-preview {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    border: 1px dashed #cfc8c1;
    object-fit: cover;
    background: repeating-linear-gradient(45deg, #faf8f6, #faf8f6 6px, #f3efeb 6px, #f3efeb 12px);
    display: block;
    margin-bottom: 8px;
}

/* Senza questo il display:block qui sopra vince sull'attributo hidden e lo
   slot vuoto mostrerebbe comunque un box: niente box finche' non c'e' una foto. */
.slot-preview[hidden] { display: none; }

input[type="file"] { font-size: .8rem; width: 100%; }

/* --- Lookup --- */

.lookup-drop {
    border: 2px dashed #cfc8c1;
    border-radius: var(--radius);
    padding: 34px 20px;
    text-align: center;
    background: var(--surface);
}
.lookup-drop.busy { border-color: var(--accent); background: #fdf7f4; }

.lookup-preview {
    max-width: 230px; width: 100%;
    border-radius: 8px;
    margin: 0 auto 16px;
    display: block;
}

.progress {
    height: 5px;
    background: #e8e2dc;
    border-radius: 3px;
    overflow: hidden;
    margin: 14px 0;
}
.progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0;
    transition: width .25s ease;
}

.step-list { list-style: none; padding: 0; margin: 16px 0 0; font-size: .86rem; }
.step-list li { padding: 6px 0; color: var(--text-muted); display: flex; gap: 9px; align-items: center; }
.step-list li .step-icon { width: 17px; text-align: center; flex-shrink: 0; }
.step-list li.done { color: var(--ok-text); }
.step-list li.active { color: var(--text); font-weight: 600; }
.step-list li.fail { color: var(--text-muted); }

.result-hit {
    border: 2px solid var(--ok-text);
    border-radius: var(--radius);
    padding: 20px;
    background: var(--ok-bg);
}
.result-miss {
    border: 2px solid #d9d2cb;
    border-radius: var(--radius);
    padding: 20px;
    background: var(--surface);
}
.result-head { font-size: 1.15rem; font-weight: 700; margin-bottom: 12px; }

.result-record { display: flex; gap: 15px; align-items: center; }
.result-record img {
    width: 74px; height: 74px; border-radius: 6px; object-fit: cover; flex-shrink: 0;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    background: #e8e2dc;
    color: var(--text-muted);
}
.badge-ok { background: #cfe9d9; color: var(--ok-text); }

.stat-row { display: flex; gap: 26px; flex-wrap: wrap; margin-bottom: 4px; }
.stat { font-size: .84rem; color: var(--text-muted); }
.stat strong { display: block; font-size: 1.5rem; color: var(--text); font-weight: 700; line-height: 1.2; }

/* --- Utenti --- */

.role-badge {
    font-size: .7rem; padding: 2px 7px; border-radius: 4px;
    background: #e8e2dc; color: var(--text-muted); font-weight: 600;
    text-transform: uppercase; letter-spacing: .4px;
}
.role-badge.admin { background: #f6ddd3; color: var(--accent-dark); }

/* --- Responsive --- */

@media (max-width: 900px) {
    .record-layout { grid-template-columns: 1fr; }
    .record-covers { grid-template-columns: 1fr 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
    .wrap { padding: 0 14px; }
    .header-inner { min-height: auto; padding: 12px 0; gap: 12px; }
    .nav { order: 3; width: 100%; gap: 16px; }
    .user-menu { margin-left: auto; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .search-main { flex-direction: column; }
    .hide-sm { display: none; }
    .record-covers { grid-template-columns: 1fr; }
    .image-slots { grid-template-columns: 1fr; }
    h1 { font-size: 1.25rem; }
}

@media print {
    .site-header, .site-footer, .btn, .search-card, .pagination { display: none; }
    body { background: #fff; }
    .card, .table-wrap { border: 0; box-shadow: none; }
}

/* --- Landing pubblica --- */

.btn-lg { padding: 13px 26px; font-size: 1.02rem; border-radius: 999px; }

.landing-hero {
    background: linear-gradient(160deg, #1c1a18 0%, #2c2622 55%, #3a2b22 100%);
    color: #f3efeb;
    text-align: center;
    padding: 56px 0 64px;
    border-bottom: 3px solid var(--accent);
}
.landing-hero-inner { display: flex; flex-direction: column; align-items: center; }
.landing-logo {
    width: 150px; height: 150px;
    filter: drop-shadow(0 10px 26px rgba(0, 0, 0, .45));
}
.landing-title {
    font-size: 2.6rem; margin: 20px 0 6px; letter-spacing: -.5px; color: #fff;
}
.landing-tagline { font-size: 1.2rem; margin: 0 0 14px; color: #e7c9b6; }
.landing-lead {
    max-width: 540px; margin: 0 auto 28px;
    color: #cfc8c1; font-size: 1.02rem; line-height: 1.55;
}

.landing-main { padding-top: 48px; padding-bottom: 40px; }

.landing-features {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
    margin-bottom: 52px;
}
.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 20px;
    box-shadow: var(--shadow);
}
.feature-card h3 { font-size: 1.05rem; margin: 0 0 8px; color: var(--accent-dark); }
.feature-card p { margin: 0; color: var(--text-muted); font-size: .94rem; line-height: 1.5; }

.landing-cta {
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 24px;
    box-shadow: var(--shadow);
    max-width: 640px; margin: 0 auto;
}
.landing-cta h2 { font-size: 1.5rem; margin: 0 0 8px; }
.landing-cta p { margin: 0 0 6px; color: var(--text-muted); }
.landing-contact { margin: 10px 0 24px !important; }
.landing-contact a {
    font-size: 1.15rem; font-weight: 700; color: var(--accent); text-decoration: none;
}
.landing-contact a:hover { text-decoration: underline; }

.landing-footer {
    text-align: center; padding: 26px 0; margin-top: 40px;
    border-top: 1px solid var(--border);
    color: var(--text-muted); font-size: .85rem;
}
.landing-footer a { color: var(--text-muted); }

@media (max-width: 860px) {
    .landing-features { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .landing-features { grid-template-columns: 1fr; }
    .landing-title { font-size: 2.1rem; }
    .landing-hero { padding: 44px 0 50px; }
}

/* --- Invito a installare l'app (PWA) --- */

.pwa-install { width: 100%; max-width: 380px; margin: 18px auto 0; }

.pwa-banner {
    display: flex; align-items: center; gap: 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 13px 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
    text-align: left;
}
.pwa-banner-icon { border-radius: 10px; flex-shrink: 0; }
.pwa-banner-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.pwa-banner-body strong { font-size: .96rem; }
.pwa-banner-body span { font-size: .82rem; color: var(--text-muted); line-height: 1.4; }
.pwa-banner-btn { flex-shrink: 0; padding: 8px 16px; border-radius: 999px; }
.pwa-banner-close {
    background: none; border: 0; cursor: pointer;
    font-size: 1.4rem; line-height: 1; color: var(--text-muted);
    padding: 0 2px; align-self: flex-start;
}
.pwa-banner-close:hover { color: var(--text); }

/* Glifo "Condividi" di iOS per le istruzioni Safari. */
.ios-share {
    display: inline-block; width: 13px; height: 15px; vertical-align: -3px;
    background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 28' fill='none' stroke='%23007aff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2v16'/%3E%3Cpath d='M7 7l5-5 5 5'/%3E%3Cpath d='M5 12H3v13h18V12h-2'/%3E%3C/svg%3E");
}
