/* =========================
   BASE / CONTENITORI
   ========================= */
.page-wrapper{
    display:flex;
    flex-direction:column;
    justify-content:center;
    align-items:center;
    padding:2rem;
}
.page-wrapper h1{
    font-size:2.5rem;
    margin-bottom:2rem;
    text-align:center;
    color:var(--black);
}

/* =========================
   FORM / INPUT / BUTTONS
   ========================= */
.login-form,
.selection-form,
.form{
    display:flex;
    flex-direction:column;
    width:100%;
    max-width:400px;
    gap:.5rem;
    background:#fff;
    padding:2rem;
    border-radius:16px;
    box-shadow:0 8px 24px rgba(0,0,0,.08);
}

/* campi coerenti */
.login-form input,
.selection-form :is(input, textarea, select),
.form select{
    padding:1rem;
    font-size:1rem;
    border:2px solid #ddd;
    border-radius:12px;
    transition:border-color .25s ease;
    background:#fff;
}
.login-form input:focus,
.selection-form :is(input, textarea, select):focus,
.form select:focus{
    border-color:var(--pink);
    outline:none;
}

/* etichette */
.selection-form label{
    display:grid;
    gap:.4rem;
    font-weight:600;
    color:var(--black);
}

/* fieldset badge */
.selection-form fieldset{
    border:2px dashed #e8e8e8;
    border-radius:12px;
    padding:.75rem .9rem 1rem;
}
.selection-form legend{
    font-weight:700;
    padding:0 .35rem;
    margin-left:.25rem;
}
.selection-form .checks{
    display:flex;
    gap:1rem;
    flex-wrap:wrap;
    margin-top:.25rem;
}
.selection-form .checks label{
    display:inline-flex;
    align-items:center;
    gap:.45rem;
    font-weight:600;
}

/* messaggi */
.selection-form .help{
    font-size:.95rem;
    color:var(--darkgray);
    line-height:1.35;
    margin:.25rem 0 .5rem;
    border:2px dashed var(--pink);
    padding:.8rem;
    border-radius:12px;
    text-align:justify;
}
.highlight{
    font-size:.95rem;
    color:var(--white);
    line-height:1.35;
    margin:.25rem 0 .5rem;
    background-color:rgba(190,0,0,.95);
    padding:.8rem;
    border-radius:12px;
    text-align:justify;
}

/* pulsanti: form */
.login-form button,
.selection-form button,
.form button{
    padding:1.2rem;
    font-size:1.1rem;
    font-weight:700;
    background:var(--blue);
    color:#fff;
    border:none;
    border-radius:12px;
    cursor:pointer;
    transition:background-color .3s ease;
}
.login-form button:hover,
.selection-form button:hover,
.form button:hover{
    background:var(--pink);
}

/* pulsanti: link */
.primary-button,
.secondary-button{
    color:#fff;
    padding:.8rem 1.5rem;
    border-radius:8px;
    text-decoration:none;
    font-weight:600;
    transition:.2s ease-in-out;
    text-align:center;
    display:inline-block;
}
.primary-button{ background:var(--blue); }
.primary-button:hover{ background:var(--pink); }
.secondary-button{ background:var(--pink); }
.secondary-button:hover{ background:var(--blue); }

.char-counter{ font-size:.85rem; color:#888; text-align:right; margin-top:.2rem; }
.char-counter.exceeded{ color:var(--red); font-weight:600; }

/* link logout */
.logout-link{
    display:block;
    width:100%;
    max-width:320px;
    margin:1rem auto;
    background:var(--red);
    color:#fff;
    font-weight:700;
    padding:1rem;
    border-radius:12px;
    text-align:center;
    text-decoration:none;
    transition:background-color .3s ease-in-out;
}
.logout-link:hover{ background:#b50000; }

/* =========================
   LAYOUT DASHBOARD
   ========================= */
.dash-grid{
    position:relative;
    display:grid;
    grid-template-columns:clamp(240px,22vw,320px) minmax(0,1fr) clamp(320px,26vw,420px);
    gap:28px;
    align-items:start;
}
.panel{
    background:#fff;
    border-radius:14px;
    box-shadow:0 2px 10px rgba(0,0,0,.06);
}
.panel-left,
.panel-right{
    padding:18px;
    position:sticky;
    top:90px;
}
.panel-center{ padding:0; position:relative; z-index:1; }
.panel-left{ z-index:4; isolation:isolate; }
.panel-right{ z-index:3; }

/* ogni colonna non forza la traccia */
.panel, .panel-left, .panel-center, .panel-right{ min-width:0; }

/* =========================
   CARD PROFILO (CENTRO)
   ========================= */
.profile-card{
    position:relative;
    display:grid;
    gap:14px;
    padding:1.25rem;
    background:#fff;
    border-radius:16px;
    box-shadow:0 10px 28px rgba(0,0,0,.08);
}
.profile-card .selection-form{
    background:transparent;
    box-shadow:none;
    padding:0;
    border-radius:0;
    max-width:100%;
}
.profile-head{
    display:flex;
    align-items:center;
    gap:.9rem;
    margin:0;
    background:transparent;
    box-shadow:none;
    padding:0;
}
.profile-head .number{
    width:56px; height:56px;
    object-fit:contain;
    background:var(--dark);
    border-radius:999px;
}
.profile-head .profile{
    width:auto; height:70px;
    object-fit:cover;
}
.profile-username{
    font-weight:800;
    letter-spacing:.4px;
    font-family:"Monument Extended", system-ui, sans-serif;
    font-size:1.2rem;
}

/* =========================
   KPI (COLONNA DESTRA)
   ========================= */
.kpi-grid{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:12px;
    margin-bottom:18px;
}
.kpi-card{
    padding:14px;
    border-radius:12px;
    background:#f6f7fb;
}
.kpi-card.ok{ background: #d3f6dc; }
.kpi-card.err{ background: #f6d3d3; }
.kpi-card.warn{ background: #f6f0d3; }
.kpi-card.pole{ background: #e6d3f6; }
.kpi-num{ font-size:1.4rem; font-weight:800; line-height:1.1; }
.kpi-label{ opacity:.75; font-size:.85rem; }

/* progress bar opzionale per KPI */
.kpi-bar{
    height:8px; background:#e9ecf3; border-radius:999px; overflow:hidden; margin-top:8px;
}
.kpi-bar span{
    display:block; height:100%; width:var(--v,0);
    background:#3b82f6; border-radius:999px; transition:width .4s;
}

.kpi-grid .kpi-card.kpi-wide{
    grid-column: 1 / -1; /* spanna tutte le colonne della kpi-grid */
}

/* Bacheca trofei */
.kpi-card.trophy-board .trophy-wrap{
    display:flex;
    gap:6px;
    flex-wrap:wrap;
    align-items:center;
}

/* opzionale: un filo più ordinato (se vuoi) */
.kpi-card.trophy-board .kpi-num{
    line-height: 1.2;
}

/* =========================
   MINI-CALENDAR (SCOPED)
   ========================= */
.sel-calendar .calendar-box{
    margin:0;
    background:#fff;
    border-radius:14px;
    box-shadow:0 2px 10px rgba(0,0,0,.06);
    padding:10px;
}
.sel-calendar .cal-head{
    display:flex; align-items:center; justify-content:space-between;
    gap:12px; margin-bottom:10px;
}
.sel-calendar .cal-title{
    font-size:1.1rem; font-weight:800; letter-spacing:.2px;
    font-family:"Monument Extended", system-ui, sans-serif;
}
.sel-calendar .event-list{
    list-style:none; padding:0; margin:0;
    display:flex; flex-direction:column; gap:10px;
}
/* pill evento */
.sel-calendar .ev{
    position:relative;
    display:block;
    padding:10px 12px;
    border-radius:12px;
    color:#fff; text-decoration:none; line-height:1.2;
    border:1px solid rgba(0,0,0,.1);
    background:#444; /* sovrascrivibile inline */
}
/* titolo + meta */
.sel-calendar .ev strong{
    display:block; font-weight:800; margin-right:30px;
}
.sel-calendar .ev .subtitle{
    font-size:.85rem; opacity:.95; white-space:nowrap;
    overflow:hidden; text-overflow:ellipsis;
}
/* badge (twitch) in alto a destra */
.sel-calendar .ev-badge{
    position:absolute; top:6px; right:6px;
    width:28px; height:28px; display:inline-flex; align-items:center; justify-content:center;
    border-radius:8px; color:#fff; pointer-events:none;
}
.sel-calendar .fa-twitch{ background:transparent; font-size:1rem; }
/* card hosting (colonna destra) */
.panel-right .calendar-box{ margin-top:8px; }
/* pilloline azioni export nell'evento */
.sel-calendar .ev-actions{
    position:absolute; right:8px; bottom:5px;
    display:flex; gap:6px;
}
.sel-calendar .ev-action{
    font-size:.75rem; padding:2px 6px; border-radius:8px;
    background:rgba(255,255,255,.18); color:#fff; text-decoration:none;
    backdrop-filter:saturate(120%);
}
.sel-calendar .ev-action:hover{ background:rgba(255,255,255,.28); }
/* chip “Esporta tutti” */
.sel-calendar .cal-head{ gap:10px; }
.sel-calendar .export-all{
    display:inline-flex; align-items:center; gap:8px;
    padding:6px 12px; border-radius:999px;
    border:1px solid var(--border,#e5e7eb);
    background:#fff; color:#111827;
    font-size:.85rem; font-weight:700; text-decoration:none;
    box-shadow:0 1px 0 rgba(0,0,0,.03);
    transition:background .2s, border-color .2s, transform .05s, color .2s;
    margin-left:auto;
}
.sel-calendar .export-all:hover{
    background:var(--btn-hover,#f3f4f6);
    border-color:var(--btn-border,#e5e7eb);
}
.sel-calendar .export-all:active{ transform:translateY(1px); }
.sel-calendar .export-all .ico{ font-size:.95rem; line-height:0; }
.sel-calendar .export-all.is-accent{
    background:var(--blue); color:#fff; border-color:transparent;
}
.sel-calendar .export-all.is-accent:hover{ background:var(--pink); }

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width:1100px){
    .dash-grid{
        grid-template-columns:1fr;
        gap:18px;
    }
    .panel-left,
    .panel-right{
        position:static;
        z-index:1;
        top:auto;
    }
    .kpi-grid{ grid-template-columns:repeat(4,minmax(0,1fr)); }
}
@media (max-width:640px){
    .page-wrapper{ padding:1rem; }
    .login-form, .selection-form, .form{ padding:1.5rem; }
    .kpi-grid{ grid-template-columns:repeat(2,minmax(0,1fr)); }
    .sel-calendar .calendar-box{ padding:14px; }
    .sel-calendar .ev{ padding:12px 14px; border-radius:14px; }
}

/* =========================
   DASHBOARD: SCOPED HARDENING
   (niente overflow in colonna sinistra, controlli full-width)
   ========================= */
.page-wrapper .dash-grid :where(.selection-form,.form){
    box-sizing:border-box;
    width:100%;
    max-width:100%;
    margin:0;
}
.page-wrapper .dash-grid :where(.selection-form,.form) *{
    box-sizing:border-box;
    max-width:100%;
    overflow-wrap:anywhere;
}
.page-wrapper .dash-grid > :nth-child(1) :where(.secondary-button, button){
    width:100%;
}
/* versione compatta della form nella colonna sinistra */
.page-wrapper .dash-grid > :nth-child(1) .form{
    background:transparent;
    box-shadow:none;
    padding:0;
    border-radius:0;
    max-width:100%;
    gap:12px;
}
.page-wrapper .dash-grid > :nth-child(1) .form h2{
    margin: 0 0 10px;
    font-size: 1.2rem;
}

/* controlli più snelli */
.page-wrapper .dash-grid > :nth-child(1) .form select{
    height: 44px;
    padding: .6rem .8rem;
    font-size: .95rem;
    border-radius: 12px;
}

.page-wrapper .dash-grid > :nth-child(1) .form button{
    height: 44px;
    padding: 0 1rem;
    font-size: 1rem;
    border-radius: 12px;
    width: 100%;
}

.trophy {
    font-size: 1.2rem;
    margin: 0;
    cursor: pointer;
}
.trophy.gold   { color: var(--gold, #e6b800); }
.trophy.silver { color: var(--silver, #c0c0c0); }
.trophy.bronze { color: var(--bronze, #cd7f32); }

#report-href:hover,
#showMoreData:hover{
    cursor: pointer;
}

/* invio principale del profilo */
.btn-submit{
    display:block;
    width:100%;
    max-width:320px;
    margin:1rem auto;
    background:var(--green);
    color:#fff;
    font-weight:700;
    padding:1rem;
    border-radius:12px;
    text-align:center;
    transition:background-color .3s ease-in-out;
    border: 0;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    box-shadow: none;
}
.btn-submit:hover{ background:#1b4c00; }

.profile-head{
    display:flex;
    align-items:center;
    gap:.9rem;
    margin:0;
    background:transparent;
    box-shadow:none;
    padding:0;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.profile-head > div{
    flex: 1 1 auto;
    min-width: 0;   /* fondamentale per ellipsis in flex */
}

.profile-head .number,
.profile-head .profile{
    flex: 0 0 auto;
}

.profile-username{
    font-weight:800;
    letter-spacing:.4px;
    font-family:"Monument Extended", system-ui, sans-serif;
    font-size:1.2rem;

    display: block;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.field-error{
    border-color:var(--red) !important;
    box-shadow:0 0 0 .2rem rgba(220,53,69,.15) !important;
}
.field-error-msg{
    color:var(--red);
    font-size:.78rem;
    margin-top:.25rem;
}