/* ==========================================================================
   GTS – layout dell'app: base, header con menu, pagina, login, bottone AGGIORNA.
   Prende il posto del tema Enfold; lo stile dei moduli resta in gts-app.css
   (il <body> ha id="top" come in Enfold, così i selettori "body#top" funzionano).
   ========================================================================== */

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

html { -webkit-text-size-adjust: 100%; }

body.gts-body {
    margin: 0;
    min-height: 100vh;
    background: #f4f4f2;
    color: #1f1f1f;
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body.gts-body img { max-width: 100%; height: auto; }
body.gts-body a { color: inherit; }
body.gts-body p { margin: 0 0 1em; }
body.gts-body h1, body.gts-body h2, body.gts-body h3 { line-height: 1.2; margin: 0 0 .6em; }
body.gts-body table { border-collapse: collapse; border-spacing: 0; width: 100%; }
body.gts-body button, body.gts-body input, body.gts-body select, body.gts-body textarea { font: inherit; }
body.gts-body [hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   HEADER
   -------------------------------------------------------------------------- */
.gts-header {
    position: sticky;
    top: 0;
    z-index: 900;
    background: #111;
    color: #fff;
    border-bottom: 4px solid #f2d21b;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .18);
}

.gts-header-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 6px 20px;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 22px;
}

.gts-brand { display: flex; align-items: center; flex: 0 0 auto; }
/* logo piccolo nelle pagine dell'app (grande solo nel login): selettore più forte di "body.gts-body img" */
body.gts-body .gts-brand img { display: block; height: 76px; width: auto; max-width: none; }

.gts-menu {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.gts-nav { display: flex; align-items: center; gap: 2px; flex: 1 1 auto; flex-wrap: wrap; }

.gts-nav a {
    color: #fff;
    text-decoration: none;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 9px 12px;
    border-radius: 999px;
    white-space: nowrap;
}
.gts-nav a:hover { background: rgba(255, 255, 255, .1); }
.gts-nav a.is-active { background: #f2d21b; color: #111; }

.gts-account { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }

body.gts-body .gts-account-name {
    color: #fff;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.15;
    padding: 4px 8px;
    border-radius: 8px;
}
.gts-account-name:hover, .gts-account-name.is-active { background: rgba(255, 255, 255, .1); }
.gts-account-name strong { font-size: .86rem; }
.gts-account-name span {
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #f2d21b;
}

.gts-logout-form { margin: 0; }
.gts-logout {
    background: transparent;
    color: #f2d21b;
    border: 1px solid #f2d21b;
    border-radius: 999px;
    padding: 8px 16px;
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .08em;
    cursor: pointer;
}
.gts-logout:hover { background: #f2d21b; color: #111; }

.gts-nav-toggle {
    display: none;
    margin-left: auto;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 10px;
    cursor: pointer;
}
.gts-nav-toggle svg { width: 24px; height: 24px; }

/* --------------------------------------------------------------------------
   PAGINA
   -------------------------------------------------------------------------- */
.gts-main {
    max-width: 1320px;
    margin: 0 auto;
    padding: 22px 20px 110px;
}

.gts-page-title {
    margin: 0 0 18px;
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.gts-panel-narrow { max-width: 560px; }

.gts-profile-info { margin: 0; display: grid; gap: 8px; }
.gts-profile-info div { display: flex; gap: 12px; }
.gts-profile-info dt { width: 120px; flex: 0 0 auto; color: #6b6b6b; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding-top: 2px; }
.gts-profile-info dd { margin: 0; font-weight: 600; }

.gts-flash {
    border-radius: 8px;
    padding: 10px 14px;
    margin: 0 0 14px;
    font-weight: 600;
    font-size: .92rem;
}
.gts-flash.is-ok { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.gts-flash.is-error { background: #ffebee; color: #b71c1c; border: 1px solid #ef9a9a; }

/* --------------------------------------------------------------------------
   BOTTONE AGGIORNA (centrato in basso)
   -------------------------------------------------------------------------- */
.floating-btn {
    position: fixed;
    bottom: calc(22px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background: #f2d21b;
    color: #000;
    font-size: .95em;
    font-weight: 700;
    letter-spacing: .03em;
    border: 1px solid #d9b800;
    border-radius: 999px;
    padding: 12px 20px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
    cursor: pointer;
    z-index: 800;
    transition: transform .15s ease, box-shadow .15s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}
.floating-btn.loading { pointer-events: none; opacity: .8; }
.floating-btn:hover { transform: translateX(-50%) translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, .3); }
.floating-btn .spinner {
    width: 16px;
    height: 16px;
    border: 3px solid rgba(0, 0, 0, .25);
    border-top-color: #000;
    border-radius: 50%;
    animation: floating-spin .8s linear infinite;
    display: none;
}
.floating-btn.loading .spinner { display: inline-block; }
@keyframes floating-spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   LOGIN / ERRORI
   -------------------------------------------------------------------------- */
body.gts-login-body {
    background: #111;
    color: #1f1f1f;
}

.gts-login {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px calc(32px + env(safe-area-inset-bottom));
}

.gts-login-logo { width: 220px; max-width: 70vw; margin-bottom: 26px; }

.gts-login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 14px;
    border-top: 5px solid #f2d21b;
    padding: 26px 24px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}

.gts-login-card h1 { font-size: 1.35rem; font-weight: 800; margin: 0 0 4px; }
.gts-login-sub { color: #6b6b6b; font-size: .92rem; margin: 0 0 18px !important; }

.gts-login-form label {
    display: block;
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #444;
    margin: 12px 0 6px;
}

/* il form è in cima alla scheda: nessuno spazio sopra il primo campo */
.gts-login-form label:first-of-type { margin-top: 0; }

.gts-login-form input[type="text"],
.gts-login-form input[type="password"] {
    width: 100%;
    height: 48px;
    border: 1px solid #d6d6d6;
    border-radius: 10px;
    padding: 0 14px;
    font-size: 16px; /* niente zoom automatico su iPhone */
    background: #fff;
    color: #111;
}
.gts-login-form input:focus { outline: none; border-color: #d9b800; box-shadow: 0 0 0 3px rgba(242, 210, 27, .35); }

.gts-password { position: relative; }
.gts-password input { padding-right: 92px !important; }
.gts-password-toggle {
    position: absolute;
    top: 6px;
    right: 6px;
    height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: #f1f1f1;
    color: #333;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .06em;
    cursor: pointer;
}

.gts-login-submit {
    display: block;
    width: 100%;
    margin-top: 20px;
    height: 50px;
    line-height: 50px;
    border: 0;
    border-radius: 999px;
    background: #f2d21b;
    color: #111;
    text-align: center;
    text-decoration: none;
    font-size: .95rem;
    font-weight: 800;
    letter-spacing: .08em;
    cursor: pointer;
}
.gts-login-submit:hover { background: #ffdf2e; }
.gts-login-submit:disabled { opacity: .7; cursor: wait; }

.gts-login-foot { color: #777; font-size: .8rem; margin-top: 22px !important; }

/* installazione come app (pagina di login) */
.gts-install { text-align: center; }
.gts-install-icon {
    display: block;
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.gts-install h1 { margin-bottom: 14px; }
.gts-install .gts-login-submit { margin-top: 0; }
.gts-install-how {
    margin: 0 !important;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f6f6f6;
    font-size: 1rem;
    line-height: 1.5;
}
.gts-install-glyph { width: 20px; height: 20px; vertical-align: -4px; }
.gts-install .gts-flash { margin: 14px 0 0; }
.gts-install-skip,
.gts-install-link {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 8px;
    background: none;
    border: 0;
    color: #444;
    font-size: .88rem;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.gts-install-link { margin-top: 12px; }

/* --------------------------------------------------------------------------
   TELEFONO / TABLET
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
    .gts-header-inner { flex-wrap: wrap; gap: 0; padding: 6px 14px; min-height: 84px; }
    body.gts-body .gts-brand img { height: 72px; max-width: calc(100vw - 90px); object-fit: contain; object-position: left center; }
    .gts-nav-toggle { width: 44px; height: 44px; }
    .gts-nav-toggle { display: flex; }

    .gts-menu {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 6px 0 10px;
        margin-top: 6px;
        border-top: 1px solid rgba(255, 255, 255, .12);
    }
    .gts-header.is-open .gts-menu { display: flex; }

    .gts-nav { flex-direction: column; align-items: stretch; }
    .gts-nav a { padding: 13px 14px; border-radius: 10px; font-size: .86rem; }

    .gts-account {
        justify-content: space-between;
        padding-top: 10px;
        margin-top: 6px;
        border-top: 1px solid rgba(255, 255, 255, .12);
    }
    body.gts-body .gts-account-name { align-items: flex-start; }
}

@media (max-width: 768px) {
    .gts-main { padding: 14px 12px 100px; }
    .gts-page-title { font-size: 1.05rem; margin-bottom: 12px; }

    .floating-btn { bottom: calc(14px + env(safe-area-inset-bottom)); padding: 11px 16px; font-size: .9em; }
}

/* --------------------------------------------------------------------------
   NOTIFICHE: banner di attivazione e pannello nel Profilo
   -------------------------------------------------------------------------- */
.gts-push-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    max-width: 900px;
    margin: 0 auto 16px;
    padding: 12px 14px;
    border-left: 5px solid #f2d21b;
    border-radius: 12px;
    background: #111;
    color: #fff;
    font-size: .95rem;
    line-height: 1.35;
}
.gts-push-banner.is-ok { border-left-color: #2e7d32; }
.gts-push-banner.is-error { border-left-color: #c62828; }

.gts-push-banner-icon { display: flex; flex: 0 0 auto; color: #f2d21b; }
.gts-push-banner-icon svg { width: 26px; height: 26px; }
.gts-push-banner-text { flex: 1 1 220px; min-width: 0; font-weight: 600; }
.gts-push-banner-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; margin-left: auto; }

.gts-push-banner .gts-push-on {
    min-height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: #f2d21b;
    color: #111;
    font-size: .85rem;
    font-weight: 800;
    letter-spacing: .06em;
    cursor: pointer;
}
.gts-push-banner .gts-push-on:disabled { opacity: .7; cursor: wait; }

.gts-push-banner .gts-push-later {
    min-height: 40px;
    padding: 0 10px;
    border: 0;
    background: none;
    color: #ddd;
    font-size: .85rem;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.gts-push-status { margin: 8px 0 0 !important; font-weight: 700; }
.gts-push-panel[data-state="on"] .gts-push-status { color: #1b5e20; }
.gts-push-panel[data-state="denied"] .gts-push-status { color: #8e1b17; }

.gts-push-msg { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: #f3f3f3; font-size: .9rem; font-weight: 600; }
.gts-push-msg.is-ok { background: #eaf7ee; color: #1b5e20; }
.gts-push-msg.is-error { background: #fdecea; color: #8e1b17; }

/* Profilo: stato delle notifiche e dispositivi registrati */
.gts-push-info { margin: 12px 0 0; display: grid; gap: 6px; }
.gts-push-info div { display: flex; gap: 12px; align-items: baseline; }
.gts-push-info dt {
    width: 170px;
    flex: 0 0 auto;
    color: #6b6b6b;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.gts-push-info dd { margin: 0; font-weight: 700; }
.gts-push-panel[data-permission="granted"] .js-push-permission { color: #1b5e20; }
.gts-push-panel[data-permission="denied"] .js-push-permission { color: #8e1b17; }

.gts-push-devices { margin-top: 16px; }
.gts-push-devices-title { font-size: .85rem; color: #4a4a4a; }
.gts-push-devices ul { list-style: none; margin: 8px 0 0; padding: 0; }
.gts-push-devices li {
    padding: 9px 0;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.gts-push-devices li.is-current { border-left: 3px solid #f2d21b; padding-left: 10px; }
.gts-push-device-name { font-weight: 700; font-size: .92rem; }
.gts-push-device-when { color: #6b6b6b; font-size: .82rem; }
.gts-push-device-badge {
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f2d21b;
    color: #111;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.gts-push-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.gts-push-buttons [hidden] { display: none !important; }
.gts-profile .gts-note { margin: 0 0 4px; color: #6b6b6b; font-size: .88rem; }

/* pagina Profilo: riquadri a scheda (come nelle statistiche) */
.gts-profile .gts-panel {
    margin: 0 0 16px;
    padding: 16px 18px;
    border: 1px solid #e6e6e6;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
}
.gts-profile .gts-panel-title {
    margin: 0 0 12px;
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #444;
}
