/* ============================================================
   admin.css – Pannello amministrativo
   ============================================================ */

@import url('main.css?v=1');

:root {
    --sidebar-w:    220px;
    --topbar-h:     56px;
}

/* ---- Layout Admin ---- */
.admin-body {
    display: flex;
    min-height: 100vh;
    background: var(--color-bg);
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--color-primary-dk);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.1rem 1.2rem;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: .02em;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-nav {
    flex: 1;
    padding: .75rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .65rem 1.2rem;
    color: rgba(255,255,255,.8);
    text-decoration: none;
    font-size: .92rem;
    transition: background var(--transition), color var(--transition);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
    border-left-color: rgba(255,255,255,.4);
}

.nav-item.active {
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    border-left-color: #fff;
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    flex-shrink: 0;
}

.nav-icon .icon {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    fill: #fff;
}

.portal-switcher {
    display: flex;
    gap: .5rem;
    padding: .75rem 1.2rem;
}

.portal-switcher__item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.7);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}

.portal-switcher__item:hover {
    background: rgba(255,255,255,.18);
    color: #fff;
}

.portal-switcher__item--active {
    background: var(--color-primary);
    color: #fff;
}

.portal-switcher__item .icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.sidebar-footer {
    padding: 1rem 1.2rem;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: .85rem;
}

.sidebar-user {
    display: block;
    margin-bottom: .4rem;
    opacity: .8;
}

.btn-logout {
    display: block;
    color: rgba(255,255,255,.7);
    text-decoration: none;
    font-size: .85rem;
    transition: color var(--transition);
}
.btn-logout:hover { color: #fff; }
.btn-logout + .btn-logout { margin-top: .35rem; }

/* ---- Main content ---- */
.admin-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--color-grey);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-primary);
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: .4rem;
    line-height: 1.25;
}

.page-title__text {
    display: inline-flex;
    flex-direction: column;
    gap: .08rem;
}

.admin-content {
    padding: 1.5rem;
    flex: 1;
}

/* ---- Login ---- */
.login-body {
    background: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-wrap {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.22);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
}

.login-logo {
    text-align: center;
    margin-bottom: 1.8rem;
}

.login-logo img { height: 64px; margin-bottom: .8rem; }
.login-logo h1  { font-size: 1.2rem; color: var(--color-primary); margin-bottom: .2rem; }
.login-logo p   { font-size: 1rem; color: var(--color-grey-dk); font-weight: 500; letter-spacing: .03em; }

.login-form .form-group { margin-bottom: 1rem; }

.login-links {
    text-align: center;
    margin-top: 1.2rem;
    font-size: .9rem;
}
.login-links a { color: var(--color-primary); text-decoration: none; }
.login-links a:hover { text-decoration: underline; }

/* ---- Panel ---- */
.panel {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.panel--narrow {
    max-width: 700px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .9rem 1.2rem;
    border-bottom: 1px solid var(--color-grey-light);
    background: var(--color-grey-light);
}

.panel-head h2 {
    font-size: 1rem;
    color: var(--color-primary);
    font-weight: 600;
}

.panel .form-group,
.panel form,
.panel .info-list,
.panel .alert {
    padding: 1.2rem 1.2rem 0;
}

.panel .form-actions {
    padding: 1rem 1.2rem 1.2rem;
}

/* ---- Stats ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 150px));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .9rem .5rem;
    text-align: center;
    border-top: 3px solid var(--color-grey);
}

.stat-card--green { border-top-color: var(--color-green); }
.stat-card--blue  { border-top-color: var(--color-accent); }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.stat-label {
    font-size: .85rem;
    color: var(--color-grey-dk);
    margin-top: .2rem;
}

/* ---- Tables ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

.data-table th {
    background: var(--color-grey-light);
    padding: .6rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: .85rem;
    color: var(--color-grey-dk);
    white-space: nowrap;
}

.data-table td {
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--color-grey-light);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafbfc; }

.data-table--sm th,
.data-table--sm td { padding: .45rem .75rem; }

.empty-row { color: var(--color-grey-dk); font-style: italic; }
.table-meta { font-size: .82rem; color: var(--color-grey-dk); padding: .5rem 1rem; }

/* ---- Tabelle con intestazioni ordinabili (vedi admin.js) ---- */
.sortable-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-left: 1.4rem;
}
.sortable-table th.sortable:hover { color: var(--color-primary); }
.sortable-table th.sortable::after {
    content: '\2195';
    position: absolute;
    left: .5rem;
    opacity: .35;
    font-size: .85em;
}
.sortable-table th.sortable.sorted-asc::after  { content: '\2191'; opacity: 1; }
.sortable-table th.sortable.sorted-desc::after { content: '\2193'; opacity: 1; }

.actions { white-space: nowrap; }

/* ---- Badges (admin) ---- */
.badge--green  { background: #d5f5e3; color: #1e8449; }
.badge--red    { background: #fadbd8; color: #922b21; }
.badge--blue   { background: #d6eaf8; color: #1a5276; }
.badge--grey   { background: var(--color-grey-light); color: var(--color-grey-dk); }

/* ---- Filter bar ---- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    padding: .9rem 1.2rem;
    border-bottom: 1px solid var(--color-grey-light);
    background: var(--color-grey-light);
}

.filter-bar input,
.filter-bar select {
    padding: .4rem .65rem;
    border: 1px solid var(--color-grey);
    border-radius: var(--radius);
    font-size: .88rem;
    font-family: var(--font);
    background: #fff;
}

.filter-bar .btn {
    padding-top: .38rem;
    padding-bottom: .38rem;
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    gap: .4rem;
    padding: .75rem 1rem;
    flex-wrap: wrap;
}

.page-link {
    padding: .3rem .65rem;
    border: 1px solid var(--color-grey);
    border-radius: var(--radius);
    text-decoration: none;
    font-size: .85rem;
    color: var(--color-text);
    background: #fff;
}

.page-link.active, .page-link:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 3rem;
}

.empty-state-icon { margin-bottom: 1rem; color: var(--color-grey-dk); }
.empty-state-icon .icon { width: 3.5rem; height: 3.5rem; }
.empty-state h2   { color: var(--color-primary); margin-bottom: .5rem; }
.empty-state p    { color: var(--color-grey-dk); margin-bottom: 1.5rem; }

/* Form trasparenti nelle flex toolbar: il button diventa diretto flex item */
.panel-actions > form,
.panel-head > form {
    display: contents;
}

/* ---- Hamburger button ---- */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: .4rem;
    margin-right: .75rem;
    flex-shrink: 0;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-primary);
    border-radius: 2px;
    transition: all var(--transition);
}

/* ---- Sidebar overlay (mobile) ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 99;
}

.sidebar-overlay--visible {
    display: block;
}

/* ---- Tabelle responsive: scroll orizzontale ---- */
.panel { overflow-x: auto; }
.data-table { min-width: 480px; }

/* ---- Responsive 768px (tablet e mobile) ---- */
@media (max-width: 768px) {

    /* Sidebar: fuori schermo, slide-in con hamburger */
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 100;
    }

    .sidebar--open {
        transform: translateX(0);
    }

    /* Hamburger visibile */
    .hamburger { display: flex; }

    /* Main senza offset sidebar */
    .admin-main { margin-left: 0; }

    /* Topbar */
    .admin-topbar { padding: 0 1rem; }
    .page-title   { font-size: 1rem; }

    /* Content */
    .admin-content { padding: 1rem; }

    /* Filter bar */
    .filter-bar { padding: .6rem .8rem; gap: .4rem; }
    .filter-bar input,
    .filter-bar select { font-size: .85rem; width: 100%; }

    /* Tabelle: celle più compatte */
    .data-table       { font-size: .82rem; }
    .data-table th    { padding: .5rem .65rem; white-space: normal; }
    .data-table td    { padding: .5rem .65rem; }

    /* Paginazione: bottoni più grandi */
    .page-link { padding: .45rem .8rem; font-size: .88rem; }

    /* Login */
    .login-wrap { max-width: 92vw; padding: 2rem 1.5rem; }

    /* Stats: 2 colonne */
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- Responsive 480px (smartphone piccoli) ---- */
@media (max-width: 480px) {
    .admin-content    { padding: .75rem; }
    .panel-head       { padding: .75rem; }
    .panel .form-group,
    .panel form,
    .panel .info-list,
    .panel .alert     { padding: .75rem .75rem 0; }
    .panel .form-actions { padding: .75rem; }
}
