/* ── Variabili palette Fondazione ───────────────── */
:root {
    --fle-blue: #003C71;
    --fle-blue-mid: #1a5a8a;
    --fle-blue-light: #2d7ab5;
    --bg-gradient: linear-gradient(180deg, #003C71 0%, #1a5a8a 50%, #2d7ab5 100%);
    --panel-bg: #ffffff;
    --panel-radius: 12px;
    --panel-shadow: none;
    --panel-border: 1px solid rgba(255, 255, 255, 0.5);
    --soft-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    --hover-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    --border: #e5e7eb;
    --text: #1f2937;
    --text-dim: #6b7280;
    --text-muted: #9ca3af;
    --red: #dc2626;
    --green: #16a34a;
    --yellow: #d97706;
    --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    color: var(--text);
    padding: 0;
}

body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

/* ── Topbar comune ──────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--fle-blue);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 2rem;
    min-height: 62px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: 1rem;
    flex-wrap: wrap;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
}

.topbar-left h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

.topbar-left .subtitle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.topbar-user {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    transition: all 0.15s;
    cursor: pointer;
    font-family: inherit;
}

.topbar-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.topbar-btn svg {
    width: 14px;
    height: 14px;
}

/* ── Container ──────────────────────────────────── */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
}

main {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
}

/* ── Panel (card bianco su gradient) ────────────── */
.panel {
    background: var(--panel-bg);
    border-radius: var(--panel-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: var(--panel-border);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--fle-blue);
}

.panel-header .panel-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Select usato accanto a btn-sm dentro .panel-actions: deve essere alto come i bottoni */
.panel-actions select {
    width: auto;
    padding: 5px 28px 5px 11px;
    font-size: 0.78rem;
    line-height: 1.3;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
}
.panel-actions select:focus { outline: none; border-color: var(--fle-blue); }
.panel-actions .btn-sm { height: 30px; }

/* Tabella container: righe-header di gruppo */
.containers-table .group-row td {
    background: #f1f7ff;
    color: var(--fle-blue);
    font-weight: 700;
    font-size: 0.82rem;
    padding: 0.55rem 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-top: 1px solid var(--border);
}
.containers-table .group-row:first-child td { border-top: none; }

/* Bottoni icon-only per le azioni container */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fff;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.15s;
    margin-right: 4px;
}
.btn-icon:last-child { margin-right: 0; }
.btn-icon svg { width: 15px; height: 15px; display: block; }
.btn-icon:hover { border-color: var(--fle-blue); color: var(--fle-blue); }
.btn-icon-danger:hover  { border-color: var(--red);   color: var(--red); }
.btn-icon-success { color: var(--green); border-color: rgba(22,163,74,0.3); }
.btn-icon-success:hover { border-color: var(--green); background: rgba(22,163,74,0.08); }
.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Bottoni ────────────────────────────────────── */
.btn {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    border-color: var(--fle-blue);
    color: var(--fle-blue);
}

.btn-sm {
    padding: 6px 11px;
    font-size: 0.78rem;
}

.btn-primary {
    background: var(--fle-blue);
    color: #fff;
    border-color: var(--fle-blue);
}

.btn-primary:hover {
    background: var(--fle-blue-mid);
    color: #fff;
    border-color: var(--fle-blue-mid);
}

.btn-success {
    background: rgba(22, 163, 74, 0.1);
    color: var(--green);
    border-color: rgba(22, 163, 74, 0.25);
}

.btn-success:hover {
    background: rgba(22, 163, 74, 0.18);
    color: var(--green);
    border-color: var(--green);
}

.btn-danger {
    background: rgba(220, 38, 38, 0.08);
    color: var(--red);
    border-color: rgba(220, 38, 38, 0.2);
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.18);
    color: var(--red);
    border-color: var(--red);
}

.btn svg {
    width: 14px;
    height: 14px;
}

/* ── Form input ────────────────────────────────── */
input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--fle-blue);
}

/* ── Tools grid (Strumenti) ─────────────────────── */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.9rem;
}

.tool-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    padding: 1.5rem 1rem 1.25rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    gap: 0.85rem;
    min-height: 138px;
    position: relative;
}

.tool-card:hover {
    border-color: var(--fle-blue);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 60, 113, 0.1);
}

.tool-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(0, 60, 113, 0.08), rgba(45, 122, 181, 0.14));
    color: var(--fle-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.tool-icon svg { width: 24px; height: 24px; }

.tool-card:hover .tool-icon {
    background: linear-gradient(135deg, var(--fle-blue), var(--fle-blue-mid));
    color: #fff;
    transform: scale(1.06);
}

.tool-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--fle-blue);
    line-height: 1.3;
    letter-spacing: 0.01em;
    margin-top: auto;
}

/* Sub-section header all'interno dello stesso panel */
.subsection-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin: 1.5rem 0 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.subsection-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.subsection-title:first-child {
    margin-top: 0;
}

/* ── Status grid (super admin) ──────────────────── */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.6rem;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.85rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    border-left: 3px solid #d1d5db;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.status-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.status-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.status-icon svg { width: 16px; height: 16px; flex-shrink: 0; }

.status-ok    { border-left-color: #16a34a; }
.status-warn  { border-left-color: #d97706; }
.status-error { border-left-color: #dc2626; }
.status-idle  { border-left-color: #9ca3af; }

.status-ok    .status-icon { background: rgba(22,163,74,0.12); color: #16a34a; }
.status-warn  .status-icon { background: rgba(217,119,6,0.15); color: #d97706; }
.status-error .status-icon { background: rgba(220,38,38,0.12); color: #dc2626; }
.status-idle  .status-icon { background: rgba(156,163,175,0.18); color: #6b7280; }

.status-info { min-width: 0; flex: 1; }
.status-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.1rem;
}
.status-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Alert panel (problemi VPS) ─────────────────── */
.alert-panel {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    background: #fff7e6;
    border: 1px solid #f0c879;
    border-left: 4px solid #d97706;
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-bottom: 1.5rem;
    color: #78350f;
}

.alert-panel-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    color: #d97706;
}

.alert-panel-icon svg {
    width: 26px;
    height: 26px;
}

.alert-panel-title {
    font-weight: 700;
    color: #78350f;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.alert-panel-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ── Stats cards (CPU, RAM, ecc.) ───────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem;
}

.stat-card {
    background: #fff;
    border-radius: var(--panel-radius);
    padding: 1.05rem 1.15rem;
    border: 1px solid var(--border);
}

.stat-card .stat-title {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.stat-card .stat-value {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--fle-blue);
    margin-bottom: 0.15rem;
}

.stat-card .stat-sub {
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* ── Tabella ────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead th {
    text-align: left;
    padding: 0.65rem 0.75rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--fle-blue);
    background: #f9fafb;
    white-space: nowrap;
}

tbody td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:hover {
    background: #f9fafb;
}

.center {
    text-align: center;
}

.text-dim {
    color: var(--text-dim);
}

.text-muted {
    color: var(--text-muted);
}

/* ── Status badge ───────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-ok {
    background: rgba(22, 163, 74, 0.12);
    color: var(--green);
}

.badge-warn {
    background: rgba(234, 179, 8, 0.15);
    color: #a16207;
}

.badge-error {
    background: rgba(220, 38, 38, 0.12);
    color: var(--red);
}

.badge-idle {
    background: rgba(100, 100, 100, 0.12);
    color: var(--text-dim);
}

/* ── Modal ──────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background: var(--panel-bg);
    border-radius: var(--panel-radius);
    width: 100%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    color: var(--fle-blue);
    font-size: 1rem;
}

.logs-content {
    flex: 1;
    overflow: auto;
    margin: 0;
    padding: 1rem 1.25rem;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text);
    background: #f9fafb;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Login ──────────────────────────────────────── */
.login-card {
    background: var(--panel-bg);
    border-radius: var(--panel-radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    text-align: center;
}

.login-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    border-radius: 18px;
    background: var(--fle-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
}

.login-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--fle-blue);
    margin-bottom: 0.4rem;
}

.login-sub {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.btn-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0.7rem 1.2rem;
    background: var(--fle-blue);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    width: 100%;
    transition: background 0.15s;
}

.btn-google:hover {
    background: var(--fle-blue-mid);
}

.alert-error {
    background: rgba(220, 38, 38, 0.1);
    color: var(--red);
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 8px;
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.login-footer {
    margin-top: 1.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ── Mobile ─────────────────────────────────────── */
@media (max-width: 700px) {
    .topbar {
        padding: 0.75rem 1rem;
    }
    main, .container {
        padding: 1rem;
    }
    .panel {
        padding: 1rem;
    }
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .topbar-user {
        display: none;
    }
}
