/* =====================================================================
   PrimeDisplay - stile pannello admin (responsive, senza framework)
   ===================================================================== */

:root {
    --blu: #0d2a59;
    --blu-chiaro: #1d4e9e;
    --accento: #2069e0;
    --sfondo: #f2f4f8;
    --bianco: #fff;
    --testo: #1c2330;
    --muted: #6b7280;
    --bordo: #d9dee8;
    --rosso: #c53030;
    --verde: #1f9d55;
    --raggio: 8px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--sfondo);
    color: var(--testo);
    font-size: 15px;
}
a { color: var(--accento); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .2em 0 .8em; }
h2 { font-size: 1.1rem; margin: .2em 0 .6em; }
.muted { color: var(--muted); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Topbar --- */
.topbar { background: var(--blu); color: #fff; }
.topbar-inner {
    max-width: 1200px; margin: 0 auto; padding: 0 16px;
    display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
    min-height: 56px;
}
.brand { color: #fff; font-size: 1.15rem; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.mainnav a {
    color: #cfd9ec; padding: 8px 12px; border-radius: 6px; font-size: .95rem;
}
.mainnav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.mainnav a.active { background: rgba(255,255,255,.16); color: #fff; }
.userbox { display: flex; align-items: center; gap: 10px; color: #cfd9ec; }

/* --- Layout --- */
.container { max-width: 1200px; margin: 24px auto; padding: 0 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel {
    background: var(--bianco); border: 1px solid var(--bordo);
    border-radius: var(--raggio); padding: 16px 18px; margin: 0 0 20px;
}

/* --- Bottoni --- */
.btn {
    display: inline-block; padding: 8px 14px; border-radius: 6px;
    border: 1px solid var(--bordo); background: var(--bianco); color: var(--testo);
    cursor: pointer; font-size: .92rem; line-height: 1.2;
}
.btn:hover { background: #eef1f6; text-decoration: none; }
.btn-primary { background: var(--accento); border-color: var(--accento); color: #fff; }
.btn-primary:hover { background: var(--blu-chiaro); }
.btn-danger { background: #fff; border-color: #e5b4b4; color: var(--rosso); }
.btn-danger:hover { background: #fdf2f2; }
.btn-sm { padding: 4px 10px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* --- Tabelle --- */
.table {
    width: 100%; border-collapse: collapse; background: var(--bianco);
    border: 1px solid var(--bordo); border-radius: var(--raggio); overflow: hidden;
    margin-bottom: 24px;
}
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--bordo); vertical-align: middle; }
.table th { background: #f7f9fc; font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.actions { white-space: nowrap; }
.actions .btn { margin-right: 4px; }
.inline { display: inline-block; }

/* --- Badge / stato --- */
.badge {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    font-size: .78rem; background: #e8edf5; color: var(--blu);
}
.badge-ok  { background: #e2f5e9; color: var(--verde); }
.badge-off { background: #fdeaea; color: var(--rosso); }

/* --- Form --- */
.form label { display: block; margin-bottom: 14px; font-weight: 500; }
.form input[type=text], .form input[type=email], .form input[type=password],
.form input[type=number], .form input[type=url], .form input[type=time],
.form input[type=date], .form select, .form textarea {
    display: block; width: 100%; max-width: 480px; margin-top: 4px;
    padding: 8px 10px; border: 1px solid var(--bordo); border-radius: 6px;
    font: inherit; background: #fff;
}
.form input[type=file] { margin-top: 6px; }
.form input[type=color] { margin-top: 4px; width: 60px; height: 34px; padding: 2px; border: 1px solid var(--bordo); border-radius: 6px; }
.form small { display: block; font-weight: 400; margin-top: 3px; }
.form .check { font-weight: 400; }
.check-inline { font-weight: 400; margin-right: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 20px; }
.form-actions { margin-top: 10px; display: flex; gap: 8px; }
.form-inline-wrap { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.form-inline-wrap label { margin-bottom: 0; flex: 1 1 160px; }
.form-inline-wrap .btn { margin-bottom: 2px; }
.days-picker { border: 1px solid var(--bordo); border-radius: 6px; padding: 10px 14px; margin: 6px 0 14px; }
.days-picker legend { font-size: .9rem; font-weight: 600; padding: 0 6px; }
.filters a { margin-right: 10px; }
.filters a.active { font-weight: 700; text-decoration: underline; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.alert-error { background: #fdeaea; color: var(--rosso); border: 1px solid #f2c4c4; }

/* --- Cards dashboard --- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.card { background: var(--bianco); border: 1px solid var(--bordo); border-radius: var(--raggio); padding: 14px 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-head h2 { margin: 0; }
.card-preview {
    margin: 12px 0; height: 150px; border-radius: 6px; overflow: hidden;
    background: #0b0f16; display: flex; align-items: center; justify-content: center;
}
.card-preview img { width: 100%; height: 100%; object-fit: cover; }
.preview-generic { color: #93a1b8; text-align: center; font-weight: 600; }
.card-meta { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: .87rem; margin: 0; }
.card-meta dt { color: var(--muted); }
.card-meta dd { margin: 0; }

/* --- Miniature --- */
.thumb { width: 64px; height: 40px; object-fit: cover; border-radius: 4px; display: inline-block; }
.thumb-generic { background: var(--blu); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; }
.thumb-cell { width: 72px; }
.preview-img { max-width: 320px; max-height: 200px; border-radius: 6px; border: 1px solid var(--bordo); }
.swatch { display: inline-block; width: 20px; height: 20px; border-radius: 4px; border: 1px solid var(--bordo); vertical-align: middle; margin-right: 4px; }

/* --- Lista ordinabile (playlist) --- */
.sortable-list { list-style: none; margin: 0 0 30px; padding: 0; }
.sortable-item {
    display: flex; align-items: center; gap: 12px;
    background: var(--bianco); border: 1px solid var(--bordo); border-radius: var(--raggio);
    padding: 8px 12px; margin-bottom: 8px;
}
.sortable-item.inactive { opacity: .5; }
.sortable-item .item-title { flex: 1; }
.sortable-item .item-controls { display: flex; align-items: center; gap: 8px; }
.sortable-item .item-controls input[type=text] { width: 70px; padding: 5px 8px; border: 1px solid var(--bordo); border-radius: 6px; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 1.2rem; user-select: none; }
.sortable-ghost { opacity: .4; background: #e8f0fd; }

/* --- WYSIWYG --- */
.wysiwyg-toolbar { display: flex; gap: 4px; margin-bottom: 6px; }
.wysiwyg-toolbar button {
    padding: 5px 10px; border: 1px solid var(--bordo); background: #fff;
    border-radius: 5px; cursor: pointer;
}
.wysiwyg {
    min-height: 220px; background: #10151f; color: #fff;
    border: 1px solid var(--bordo); border-radius: 6px; padding: 14px;
    margin-bottom: 14px; outline: none;
}

/* --- Anteprima ticker --- */
.ticker-preview {
    height: 46px; border-radius: 6px; overflow: hidden; position: relative;
    display: flex; align-items: center; white-space: nowrap;
    background: #0d2a59; color: #fff; margin-bottom: 14px;
}
.ticker-preview-track { display: inline-flex; will-change: transform; animation: pd-marquee-adm linear infinite; }
.ticker-preview-track span { padding-right: 6em; }
@keyframes pd-marquee-adm { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* --- Vista settimanale --- */
.week-view td { vertical-align: top; min-width: 90px; }
.week-slot {
    background: #e8f0fd; border-radius: 5px; padding: 4px 6px;
    font-size: .78rem; margin-bottom: 4px;
}
.week-slot.inactive { opacity: .45; }

/* --- Modale --- */
.modal {
    position: fixed; inset: 0; background: rgba(10, 15, 25, .55);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal[hidden] { display: none; }
.modal-box {
    background: #fff; border-radius: 10px; padding: 22px 26px;
    text-align: center; max-width: 92vw;
}
#qr-target { display: flex; justify-content: center; margin: 14px 0; }

/* --- Login --- */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, var(--blu) 0%, #10151f 100%);
}
.login-card {
    background: #fff; border-radius: 12px; padding: 34px 36px;
    width: 360px; max-width: 92vw; box-shadow: 0 18px 60px rgba(0,0,0,.4);
}
.login-card h1 { margin: 0; text-align: center; font-weight: 400; }
.login-card p { text-align: center; margin-top: 4px; }
.login-card label { display: block; margin: 14px 0; font-weight: 500; }
.login-card input {
    display: block; width: 100%; margin-top: 5px; padding: 10px 12px;
    border: 1px solid var(--bordo); border-radius: 7px; font: inherit;
}

@media (max-width: 720px) {
    .topbar-inner { padding: 8px 12px; }
    .table { display: block; overflow-x: auto; }
    .sortable-item { flex-wrap: wrap; }
}
