/* Totem Buttons Manager - pagina di gestione */

.tb-app {
    --tb-ink: #16181d;
    --tb-muted: #6b7280;
    --tb-line: #e3e6ec;
    --tb-panel: #ffffff;
    --tb-bg: #f4f6f9;
    --tb-accent: #1f6feb;
    --tb-ok: #0f7b4f;
    --tb-err: #b42318;

    box-sizing: border-box;
    color: var(--tb-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

.tb-app *,
.tb-app *::before,
.tb-app *::after {
    box-sizing: border-box;
}

/* ---------- Login ---------- */

.tb-app-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
    background: var(--tb-bg);
}

.tb-login-box {
    width: 100%;
    max-width: 400px;
    padding: 32px 28px;
    background: var(--tb-panel);
    border: 1px solid var(--tb-line);
    border-radius: 16px;
    box-shadow: 0 18px 44px rgba(16, 24, 40, .08);
    text-align: center;
}

.tb-logo {
    max-width: 190px;
    max-height: 90px;
    height: auto;
    margin: 0 auto 18px;
    display: block;
}

.tb-login-title {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.tb-login-sub {
    margin: 0 0 20px;
    color: var(--tb-muted);
    font-size: 14px;
}

.tb-login-foot {
    margin: 16px 0 0;
    font-size: 13px;
}

.tb-login-foot a {
    color: var(--tb-muted);
}

.tb-app-login .tb-field,
.tb-app-login .tb-check {
    text-align: left;
}

/* ---------- Campi ---------- */

.tb-field {
    display: block;
    margin: 0 0 14px;
}

.tb-field > span {
    display: block;
    margin-bottom: 5px;
    color: var(--tb-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.tb-app input[type="text"],
.tb-app input[type="url"],
.tb-app input[type="password"],
.tb-app input[type="number"],
.tb-app select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--tb-line);
    border-radius: 9px;
    background: #fff;
    color: var(--tb-ink);
    font-size: 15px;
    line-height: 1.3;
}

.tb-app input[type="color"] {
    width: 54px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--tb-line);
    border-radius: 8px;
    background: #fff;
}

.tb-app input:focus,
.tb-app select:focus {
    outline: 2px solid var(--tb-accent);
    outline-offset: 1px;
    border-color: var(--tb-accent);
}

.tb-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 16px;
    font-size: 14px;
}

.tb-check input {
    width: 18px;
    height: 18px;
    margin: 0;
}

/* ---------- Pulsanti ---------- */

.tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid var(--tb-line);
    border-radius: 9px;
    background: #fff;
    color: var(--tb-ink);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.tb-btn:hover {
    background: #f2f4f8;
}

.tb-btn-primary {
    background: var(--tb-accent);
    border-color: var(--tb-accent);
    color: #fff;
    padding: 12px 22px;
}

.tb-btn-primary:hover {
    background: #1a5fd0;
    color: #fff;
}

.tb-btn-ghost {
    background: transparent;
    color: var(--tb-muted);
}

.tb-btn-block {
    width: 100%;
}

/* ---------- Avvisi ---------- */

.tb-alert {
    margin: 0 0 16px;
    padding: 11px 14px;
    border-radius: 9px;
    font-size: 14px;
}

.tb-alert-error {
    background: #fdecea;
    color: var(--tb-err);
}

.tb-alert-ok {
    background: #e7f6ef;
    color: var(--tb-ok);
}

/* 1.4.0 - 01/09/2026 */
.tb-alert-warn {
    background: #fff4e0;
    color: #8a5300;
}

.tb-alert-info {
    background: #eef3fb;
    color: #24467e;
}

/* ---------- Dashboard ---------- */

.tb-app-dash {
    max-width: 1180px;
    margin: 0 auto;
    padding: 20px 18px 60px;
}

.tb-topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--tb-line);
}

.tb-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tb-logo-sm {
    max-height: 40px;
    width: auto;
}

.tb-brand-title {
    font-size: 18px;
    font-weight: 700;
}

.tb-topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tb-user {
    color: var(--tb-muted);
    font-size: 14px;
}

.tb-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    padding: 16px;
    margin-bottom: 22px;
    background: var(--tb-panel);
    border: 1px solid var(--tb-line);
    border-radius: 12px;
}

.tb-count {
    display: block;
}

.tb-count > span {
    display: block;
    margin-bottom: 5px;
    color: var(--tb-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.tb-count select {
    min-width: 90px;
}

.tb-hint {
    flex: 1 1 240px;
    margin: 0;
    color: var(--tb-muted);
    font-size: 13px;
}

.tb-grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.tb-card-slot.is-off {
    display: none;
}

.tb-card {
    padding: 14px;
    background: var(--tb-panel);
    border: 1px solid var(--tb-line);
    border-radius: 12px;
}

.tb-card-head {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 12px;
}

.tb-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: #eef2f8;
    color: var(--tb-muted);
    font-size: 12px;
    font-weight: 700;
}

.tb-card-title {
    font-weight: 700;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tb-thumb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    margin-bottom: 10px;
    border-radius: 10px;
    background-color: #eef1f5;
    background-position: center;
    background-size: cover;
    color: var(--tb-muted);
    font-size: 13px;
}

.tb-thumb.is-empty {
    border: 1px dashed #cfd6e0;
}

.tb-row-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.tb-row-actions .tb-btn {
    flex: 1 1 auto;
    padding: 9px 10px;
    font-size: 13px;
}

.tb-more {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--tb-line);
}

.tb-more summary {
    cursor: pointer;
    color: var(--tb-muted);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.tb-footbar {
    margin-top: 26px;
}

@media (max-width: 640px) {
    .tb-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .tb-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tb-btn {
        transition: none;
    }
}

/* -----------------------------------------------------------------
   Sezioni richiudibili e campi (1.4.2 - 02/09/2026)
   ----------------------------------------------------------------- */

.tb-section {
    margin: 0 0 16px;
    background: #fff;
    border: 1px solid #e6e8ec;
    border-radius: 12px;
    overflow: hidden;
}

.tb-section-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 15px 18px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.tb-section-head::-webkit-details-marker {
    display: none;
}

.tb-section-head::before {
    content: '▸';
    margin-right: 2px;
    color: #8a9099;
    transition: transform .15s;
}

.tb-section[open] .tb-section-head::before {
    transform: rotate(90deg);
}

.tb-section-title {
    font-size: 15px;
    font-weight: 700;
}

.tb-section-sub {
    color: #6b7280;
    font-size: 13px;
}

.tb-section-body {
    padding: 4px 18px 20px;
    border-top: 1px solid #eef0f3;
}

.tb-video-fields,
.tb-grid-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px 24px;
    padding-top: 16px;
}

.tb-field .tb-label {
    display: block;
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #6b7280;
}

.tb-field .tb-input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #d7dbe0;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}

.tb-field .tb-input-small {
    max-width: 130px;
}

.tb-field .tb-input-color {
    max-width: 70px;
    height: 40px;
    padding: 3px;
}

.tb-radio {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-right: 18px;
    font-size: 14px;
}

.tb-field .tb-hint {
    margin: 6px 0 0;
    color: #6b7280;
    font-size: 12.5px;
    line-height: 1.45;
}

.tb-card-inline {
    max-width: 320px;
}
