/* Portale Centrale Operativa — stili condivisi (non scoped) */

/* Fallback dimensioni: SVG/img senza CSS restano a dimensione naturale (enormi) */
.co-portal-shell img.co-portal-logo {
    width: 44px;
    height: 44px;
    max-width: 44px;
    max-height: 44px;
    object-fit: contain;
    flex-shrink: 0;
}

.co-portal-shell svg.co-portal-nav-icon,
.co-portal-shell svg.co-search-icon {
    width: 1rem;
    height: 1rem;
    max-width: 1rem;
    max-height: 1rem;
    flex-shrink: 0;
}

.co-portal-loading {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.co-portal-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #eef2f6 0%, #f8fafc 220px, #f4f6f8 100%);
}

/* —— Header —— */
.co-portal-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #0a2f4f 0%, #0d3b66 45%, #145a8a 100%);
    box-shadow: 0 4px 24px rgba(10, 47, 79, 0.28);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.co-portal-header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: .75rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.25rem;
}

.co-portal-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
}

.co-portal-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.co-portal-brand-text {
    display: flex;
    flex-direction: column;
    gap: .1rem;
}

.co-portal-title {
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: .02em;
    color: #fff;
    line-height: 1.2;
}

.co-portal-tagline {
    font-size: .72rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.65);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.co-portal-nav {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
}

.co-portal-nav-track {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    padding: .35rem;
    background: rgba(0, 0, 0, 0.18);
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
}

.co-portal-nav-link {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    font-weight: 600;
    font-size: .84rem;
    white-space: nowrap;
    transition: background .15s, color .15s, transform .15s;
}

.co-portal-nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.co-portal-nav-link.active {
    background: #fff;
    color: #0d3b66;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.co-portal-nav-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    opacity: .9;
}

.co-portal-userbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-left: auto;
}

.co-portal-user-chip {
    display: none;
    align-items: center;
    gap: .45rem;
    padding: .4rem .75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.95);
    font-size: .8rem;
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.co-portal-user-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35);
}

.co-portal-logout {
    padding: .45rem .9rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
    cursor: pointer;
    font-size: .82rem;
    font-weight: 600;
    transition: background .15s, border-color .15s;
}

.co-portal-logout:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
}

.co-portal-main {
    flex: 1;
    padding: 1.25rem 1.5rem 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* —— Pagine —— */
.co-page-card {
    border-radius: .9rem;
    padding: 1.15rem 1.25rem 1.35rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.co-page-title { margin: 0; font-size: 1.35rem; }
.co-page-subtitle { margin: .35rem 0 0; color: var(--text-muted); }
.co-page-hint { margin: 0; color: var(--text-muted); }

.co-data-table th {
    white-space: nowrap;
    background: #f8fafc;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
}

.co-data-table tbody tr:hover {
    background: rgba(13, 59, 102, 0.03);
}

.co-turnario-header { margin-bottom: .85rem; }
.co-turnario-heading .co-page-subtitle { text-transform: none; }

.co-turnario-toolbar {
    background: var(--background-soft, #f4f6f8);
    border: 1px solid var(--border);
    border-radius: .65rem;
    padding: .85rem 1rem;
    margin-bottom: 1rem;
}

.co-turnario-toolbar-row {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(12rem, 1fr) auto;
    gap: 1rem 1.25rem;
    align-items: end;
}

.co-gpg-toolbar-row {
    grid-template-columns: 1fr auto;
}

.co-toolbar-block { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.co-toolbar-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.co-toolbar-label--hidden { visibility: hidden; user-select: none; }

.co-period-strip { display: flex; flex-wrap: nowrap; align-items: center; gap: .4rem; }
.co-period-strip .co-date-input { width: 10.5rem; min-width: 10.5rem; flex-shrink: 0; }
.co-period-strip .co-nav-btn,
.co-period-strip .co-today-btn,
.co-toolbar-actions .co-icon-btn { flex-shrink: 0; white-space: nowrap; }
.co-period-caption { font-size: .82rem; color: var(--text-muted); text-transform: capitalize; line-height: 1.3; }

.co-search-wrap { position: relative; display: flex; align-items: center; width: 100%; }
.co-search-icon {
    position: absolute;
    left: .65rem;
    width: 1rem !important;
    height: 1rem !important;
    max-width: 1rem;
    max-height: 1rem;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
}
.co-search-input { width: 100%; padding-left: 2.15rem !important; padding-right: 2rem !important; }
.co-search-clear {
    position: absolute;
    right: .35rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: .2rem .45rem;
    border-radius: .25rem;
}
.co-search-clear:hover { color: var(--primary); background: rgba(13, 59, 102, 0.06); }

.co-toolbar-actions { display: flex; flex-wrap: nowrap; align-items: center; gap: .45rem; }
.co-toolbar-actions .co-icon-btn {
    min-width: 2.35rem;
    padding-left: .5rem !important;
    padding-right: .5rem !important;
}
.co-toolbar-actions .co-pdf-btn { white-space: nowrap; }

.co-turnario-summary {
    margin: .75rem 0 0;
    padding-top: .65rem;
    border-top: 1px solid var(--border);
    font-size: .84rem;
    color: var(--text-muted);
}
.co-turnario-summary strong { color: var(--primary); font-weight: 700; }

.co-row--late {
    background: #fff7ed;
}

.co-row--late:hover {
    background: #ffedd5;
}

.co-nav-btn { min-width: 2.25rem; padding-left: .5rem !important; padding-right: .5rem !important; }

/* GPG in essere */
.co-gpg-stats {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
    margin-bottom: 1rem;
}

.co-gpg-stat {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .65rem .9rem;
    min-width: 7rem;
    background: linear-gradient(135deg, #f0f6fc 0%, #fff 100%);
    border: 1px solid var(--border);
    border-radius: .55rem;
}

.co-gpg-stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.co-gpg-stat-label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
}

.co-gpg-radio-badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: .35rem;
    background: var(--primary-light, #e8f0f8);
    color: var(--primary);
    font-size: .82rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.co-gpg-email-link {
    color: var(--primary);
    text-decoration: none;
    font-size: .88rem;
}
.co-gpg-email-link:hover { text-decoration: underline; }

.co-cell-muted {
    color: var(--text-muted);
    font-size: .88rem;
}

.co-gpg-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: .65rem;
}

.co-gpg-table-wrap .co-data-table {
    margin: 0;
}

.co-gpg-table-wrap .co-data-table th:first-child,
.co-gpg-table-wrap .co-data-table td:first-child {
    padding-left: 1rem;
}

@media (min-width: 768px) {
    .co-portal-user-chip { display: inline-flex; }
}

@media (max-width: 960px) {
    .co-turnario-toolbar-row { grid-template-columns: 1fr; align-items: stretch; }
    .co-toolbar-block--actions .co-toolbar-label--hidden { display: none; }
    .co-toolbar-actions { justify-content: flex-end; }

    .co-portal-header-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .co-portal-nav { justify-content: stretch; }
    .co-portal-nav-track { width: 100%; justify-content: center; }
    .co-portal-userbar { margin-left: 0; justify-content: flex-end; }
}

@media (max-width: 640px) {
    .co-portal-main { padding: 1rem; }
    .co-portal-nav-link { padding: .45rem .7rem; font-size: .78rem; }
    .co-portal-nav-link span.co-nav-label-full { display: none; }
}

@media (max-width: 520px) {
    .co-period-strip { flex-wrap: wrap; }
    .co-period-strip .co-date-input { flex: 1; min-width: 8.5rem; width: auto; }
    .co-toolbar-actions { width: 100%; }
    .co-toolbar-actions .co-pdf-btn { flex: 1; }
}
