/* =========================================================
   MPLC Digital Library — Design System
   Un unico foglio di stile per tutte le pagine.
   Light + Dark mode tramite [data-theme].
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    --mplc-blue:        #0E8BD0;
    --mplc-blue-dark:   #0A6EA6;
    --mplc-blue-soft:   #E6F2FB;

    --bg:        #EEF2F6;
    --surface:   #FFFFFF;
    --surface-2: #F7F9FC;
    --border:    #E2E8F0;
    --border-2:  #CBD5E1;

    --text:      #1A2433;
    --text-muted:#64748B;
    --text-faint:#94A3B8;

    --success-bg:#E4F6EC; --success-text:#0F7A4D;
    --warn-bg:   #FEF3DC; --warn-text:   #B45309;
    --danger:    #DC2626; --danger-bg:   #FCEAEA; --danger-text:#B91C1C;
    --info-bg:   #E6F2FB; --info-text:   #0A6EA6;

    --radius:    12px;
    --radius-sm: 8px;
    --shadow:    0 1px 2px rgba(15,23,42,.04), 0 4px 12px rgba(15,23,42,.05);
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
    --ring:      0 0 0 3px rgba(14,139,208,.22);
}

[data-theme="dark"] {
    --mplc-blue:        #38A8E8;
    --mplc-blue-dark:   #1D8FD4;
    --mplc-blue-soft:   #16334A;

    --bg:        #0E1729;
    --surface:   #16203A;
    --surface-2: #1B2742;
    --border:    #2A3A5C;
    --border-2:  #3A4E78;

    --text:      #E6ECF5;
    --text-muted:#9FB0C9;
    --text-faint:#6E80A0;

    --success-bg:#10331F; --success-text:#5DD79A;
    --warn-bg:   #3A2C0E; --warn-text:   #F2B14C;
    --danger:    #F26464; --danger-bg:   #3A1717; --danger-text:#F58B8B;
    --info-bg:   #16334A; --info-text:   #6CC4F4;

    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.35);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --ring:      0 0 0 3px rgba(56,168,232,.30);
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--mplc-blue-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-inner {
    max-width: 1640px;
    margin: 0 auto;
    padding: 0 24px;
    height: 62px;
    display: flex;
    align-items: center;
    gap: 22px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    font-size: 1.3rem;
    color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .mplc-mark {
    background: var(--mplc-blue);
    color: #fff;
    padding: 5px 9px;
    border-radius: 7px;
    font-size: 1.05rem;
    letter-spacing: .06em;
}
.brand small {
    font-weight: 500;
    font-size: .8rem;
    color: var(--text-muted);
    letter-spacing: .02em;
    border-left: 1px solid var(--border-2);
    padding-left: 12px;
}
.nav { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.nav a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: .92rem;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--mplc-blue); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    transition: .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-2); text-decoration: none; }

/* ---------- Layout ---------- */
.page {
    max-width: 1640px;
    margin: 26px auto;
    padding: 0 24px 60px;
}
.page-narrow { max-width: 820px; }
.page-form   { max-width: 760px; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.page-head h1 {
    font-size: 1.7rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -.01em;
}
.page-head .subtitle { color: var(--text-muted); font-size: .95rem; margin-top: 2px; }

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

/* ---------- Stat cards ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat .label {
    font-size: .82rem;
    color: var(--text-muted);
    font-weight: 600;
    display: flex; align-items: center; gap: 6px;
}
.stat .value { font-size: 1.85rem; font-weight: 800; letter-spacing: -.02em; }
.stat .ico {
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--mplc-blue-soft); color: var(--mplc-blue-dark);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}

/* ---------- Filters ---------- */
.filters { padding: 20px 22px; margin-bottom: 20px; }
.grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(200px, 1fr));
    gap: 16px;
}
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .grid { grid-template-columns: 1fr; } }

label { display: block; font-weight: 600; font-size: .85rem; color: var(--text-muted); margin-bottom: 6px; }

input[type="text"], input[type="password"], input[type="number"], input[type="file"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: .95rem;
    transition: .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--mplc-blue);
    box-shadow: var(--ring);
}
select[multiple] { min-height: 120px; padding: 6px; }
select[multiple] option { padding: 4px 8px; border-radius: 5px; }
textarea { resize: vertical; min-height: 90px; }

.input-icon { position: relative; }
.input-icon i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.input-icon input { padding-left: 36px; }

/* ---------- Active filter chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--info-bg); color: var(--info-text);
    font-size: .82rem; font-weight: 600;
    padding: 5px 12px; border-radius: 999px;
}
.chip a { color: inherit; display: inline-flex; }
.chip a:hover { opacity: .7; text-decoration: none; }

/* ---------- Toolbar / buttons ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--mplc-blue);
    color: #fff;
    font-family: inherit; font-weight: 600; font-size: .92rem;
    cursor: pointer; text-decoration: none;
    transition: .15s;
}
.btn:hover { background: var(--mplc-blue-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-muted { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.btn-muted:hover { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 7px 12px; font-size: .85rem; }
.spacer { flex: 1; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .9rem; }
table.data th, table.data td { padding: 12px 14px; text-align: left; }
table.data thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data tbody tr { border-bottom: 1px solid var(--border); }
table.data tbody tr:last-child { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.actions { white-space: nowrap; }

.dataTables_wrapper { color: var(--text-muted); }
.dataTables_filter { display: none !important; }
.dataTables_paginate .paginate_button {
    padding: 5px 11px !important; border-radius: 7px !important;
    border: 1px solid var(--border) !important; color: var(--text-muted) !important;
}
.dataTables_paginate .paginate_button.current {
    background: var(--mplc-blue) !important; color: #fff !important; border-color: var(--mplc-blue) !important;
}
.dataTables_length select { width: auto; display: inline-block; padding: 4px 8px; }

/* ---------- Badges / pills ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 999px;
    font-size: .78rem; font-weight: 700;
    background: var(--surface-2); color: var(--text-muted);
}
.badge.res { background: var(--info-bg); color: var(--info-text); }
.badge.res-4k { background: var(--success-bg); color: var(--success-text); }
.badge.yes { background: var(--success-bg); color: var(--success-text); }
.badge.no  { background: var(--surface-2); color: var(--text-faint); }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { background: var(--surface-2); color: var(--text-muted); border:1px solid var(--border); padding: 2px 8px; border-radius: 6px; font-size: .78rem; font-weight: 600; }

/* ---------- Edit/add row link icons ---------- */
.row-actions a { color: var(--text-muted); font-size: 1.05rem; padding: 4px; border-radius: 6px; }
.row-actions a:hover { background: var(--surface-2); color: var(--mplc-blue); text-decoration: none; }
.row-actions a.del:hover { color: var(--danger); }

/* ---------- Alerts ---------- */
.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 13px 16px; border-radius: var(--radius-sm);
    font-weight: 600; font-size: .92rem; margin-bottom: 18px;
}
.alert i { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }
.alert.success { background: var(--success-bg); color: var(--success-text); }
.alert.danger  { background: var(--danger-bg);  color: var(--danger-text); }
.alert.info    { background: var(--info-bg);     color: var(--info-text); }
.alert.warn    { background: var(--warn-bg);     color: var(--warn-text); }

/* ---------- Forms (add/edit) ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-field.full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; }
.hint { font-size: .82rem; color: var(--text-faint); margin-top: 5px; font-weight: 500; }

/* ---------- Login ---------- */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
    width: 100%; max-width: 400px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; box-shadow: var(--shadow);
    padding: 36px 32px;
}
.login-card .brand { justify-content: center; margin-bottom: 8px; }
.login-card h1 { text-align: center; font-size: 1.35rem; margin: 6px 0 24px; }

/* ---------- Confirm box (delete) ---------- */
.confirm-box { max-width: 520px; margin: 60px auto; text-align: center; padding: 36px; }
.confirm-box .warn-ico {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--danger-bg); color: var(--danger);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.9rem; margin-bottom: 14px;
}

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty i { font-size: 2.4rem; display: block; margin-bottom: 10px; color: var(--text-faint); }
.muted { color: var(--text-muted); }
.mb0 { margin-bottom: 0; }

/* ---------- Locandine ---------- */
.poster-thumb {
    width: 52px; height: 78px; object-fit: cover;
    border-radius: 6px; border: 1px solid var(--border);
    background: var(--surface-2); display: inline-block; vertical-align: middle;
}
.poster-thumb.placeholder {
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-faint); font-size: 1.1rem;
}
table.data td .poster-thumb { box-shadow: var(--shadow-sm); }

/* Selettore locandina nei form */
.poster-picker { display: flex; gap: 16px; align-items: flex-start; }
.poster-preview {
    width: 125px; height: 187px; flex-shrink: 0;
    border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2);
    object-fit: cover; display: flex; align-items: center; justify-content: center;
    color: var(--text-faint); font-size: 1.6rem; overflow: hidden;
}
.poster-preview img { width: 100%; height: 100%; object-fit: cover; }
.poster-results {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 10px; margin-top: 12px;
}
.poster-option {
    cursor: pointer; border: 2px solid transparent; border-radius: 8px; overflow: hidden;
    background: var(--surface-2); text-align: center; transition: .15s;
}
.poster-option:hover { border-color: var(--mplc-blue); }
.poster-option.selected { border-color: var(--mplc-blue); box-shadow: var(--ring); }
.poster-option img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; }
.poster-option .cap { font-size: .72rem; padding: 4px 5px; color: var(--text-muted); line-height: 1.2; }
.poster-option .noimg { aspect-ratio: 2/3; display: flex; align-items: center; justify-content: center; color: var(--text-faint); }
