/*
 * =========================================================
 * FILE: /assets/app.css
 * MODULO: Formazione App - Stili base
 * SCOPO:
 * - Layout applicazione con sidebar
 * - Login e installer
 * - Tabelle e form gestionali
 * VERSIONE: 1.3
 * =========================================================
 */

* {
    box-sizing: border-box;
}

:root {
    --sidebar-bg: #34495d;
    --sidebar-bg-dark: #2d3f51;
    --sidebar-active: #4f6376;
    --header-bg: #34495d;
    --page-bg: #eef2f5;
    --panel-bg: #ffffff;
    --panel-head: #d7e1ea;
    --line: #d7dde3;
    --text: #1f2937;
    --muted: #607083;
    --primary: #2f6ea8;
    --primary-dark: #245b8c;
    --danger-bg: #fef2f2;
    --danger-text: #991b1b;
    --success-bg: #ecfdf5;
    --success-text: #065f46;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--page-bg);
    color: var(--text);
    font-size: 14px;
}

a {
    color: inherit;
}

/* =========================================================
   LOGIN / INSTALLER
   ========================================================= */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #eef2f5, #d8e2ec);
}

.login-card,
.install-card {
    width: 100%;
    max-width: 520px;
    padding: 28px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.login-card h1,
.install-card h1 {
    margin: 0 0 6px;
    color: #172434;
}

.login-card p,
.install-card p,
.muted {
    margin: 0 0 18px;
    color: var(--muted);
}

/* =========================================================
   APP LAYOUT
   ========================================================= */
.app-body {
    background: var(--page-bg);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 246px minmax(0, 1fr);
}

.app-sidebar {
    background: var(--sidebar-bg);
    color: #fff;
    min-height: 100vh;
    box-shadow: 3px 0 8px rgba(0, 0, 0, 0.12);
}

.app-logo-box {
    height: 110px;
    margin: 0;
    padding: 12px 26px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--sidebar-bg-dark);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-logo-mark {
    width: 58px;
    height: 58px;
    border-radius: 12px;
    background: #ffffff;
    color: #0e416a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 34px;
}

.app-logo-title {
    color: #ffffff;
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
}

.app-logo-subtitle {
    margin-top: 8px;
    color: #bfd9ef;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 3px;
}

.app-user-box {
    padding: 13px 12px;
    min-height: 40px;
    background: rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #d9e5ef;
    font-size: 12px;
}

.app-menu {
    padding-top: 12px;
}

.app-menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 0 16px;
    color: #ffffff;
    text-decoration: none;
    border-left: 4px solid transparent;
}

.app-menu-link:hover,
.app-menu-link.active {
    background: var(--sidebar-active);
    border-left-color: rgba(255, 255, 255, 0.55);
}

.app-menu-icon {
    width: 18px;
    text-align: center;
    opacity: 0.9;
}

.app-main {
    min-width: 0;
}

.app-header {
    height: 62px;
    margin: 18px 22px 18px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: var(--header-bg);
    color: #ffffff;
    border-radius: 10px 0 0 10px;
}

.app-header h1 {
    margin: 0;
    font-size: 23px;
    font-weight: 800;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header-user {
    color: #dce8f2;
    font-weight: 700;
}

.app-content {
    padding: 0 22px 28px;
}

/* =========================================================
   COMPONENTI
   ========================================================= */
.panel {
    background: var(--panel-bg);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}

.panel-title-bar {
    min-height: 44px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--panel-head);
    border-bottom: 1px solid #c6d0da;
}

.panel-title-bar h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.1;
}

.panel-title-bar p {
    margin: 3px 0 0;
    color: #31475e;
    font-size: 12px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.stat-label {
    display: block;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 8px;
}

.stat-card strong {
    display: block;
    font-size: 34px;
    line-height: 1;
}

.stat-card small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
}

.empty-state {
    padding: 28px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.empty-state span {
    color: var(--muted);
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
    padding: 14px;
}

.table-card,
.form-card {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

.form-card {
    padding: 16px;
}

.form-card h3 {
    margin: 0 0 6px;
    font-size: 18px;
}

.form-note {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background: #f4f7fa;
    color: #24364a;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.data-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #edf0f3;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #f8fbfd;
}

.selected-row {
    background: #eef6ff !important;
}

.text-right {
    text-align: right !important;
}

.muted-row {
    color: var(--muted);
    text-align: center;
    padding: 20px !important;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 22px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}

.badge-ok {
    background: #dff5e7;
    color: #146c2e;
}

.badge-muted {
    background: #edf0f3;
    color: #677789;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: #e8eef4;
    color: #22384f;
    text-decoration: none;
    font-weight: 800;
}

.icon-btn:hover {
    background: #d5e0ea;
}

/* =========================================================
   FORM
   ========================================================= */
label {
    display: block;
    margin: 12px 0 5px;
    font-weight: 700;
    font-size: 13px;
}

.label-help {
    color: var(--muted);
    font-weight: 400;
    font-size: 12px;
}

input,
select {
    width: 100%;
    min-height: 38px;
    padding: 9px 10px;
    border: 1px solid #cbd5df;
    border-radius: 8px;
    font-size: 14px;
    background: #ffffff;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 110, 168, 0.15);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 12px;
}

.form-actions,
.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 14px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    font-size: 13px;
}

.btn:hover {
    background: var(--primary-dark);
}

.btn-light,
.btn-secondary {
    background: #e6edf3;
    color: #1f3145;
}

.btn-light:hover,
.btn-secondary:hover {
    background: #d4dee8;
}

.alert {
    padding: 11px 14px;
    border-radius: 10px;
    margin: 14px;
    font-size: 13px;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid #fecaca;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid #bbf7d0;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-weight: 700;
    margin-right: 10px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.mini-card {
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px;
    background: #f9fafb;
}

.mini-card strong,
.mini-card span {
    display: block;
}

.mini-card span {
    margin-top: 8px;
    color: #6b7280;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1000px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        min-height: auto;
    }

    .app-logo-box {
        height: auto;
    }

    .app-menu {
        display: flex;
        overflow-x: auto;
        padding: 0;
    }

    .app-menu-link {
        white-space: nowrap;
        border-left: 0;
        border-bottom: 4px solid transparent;
    }

    .app-menu-link:hover,
    .app-menu-link.active {
        border-left-color: transparent;
        border-bottom-color: rgba(255, 255, 255, 0.55);
    }

    .split-layout {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   BLOCCO: IMPORT EXCEL
   ========================================================= */
.import-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card.compact {
    padding: 16px;
}

.stat-card.compact strong {
    font-size: 28px;
}

.warning-card strong {
    color: #9a5b00;
}

.import-detail-box {
    background: #f7fafc;
    border: 1px solid #d8e1ea;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.7;
}

.form-upload input[type="file"] {
    background: #ffffff;
    border: 1px solid #cbd6e2;
    border-radius: 8px;
    padding: 10px;
}

.alert-warning {
    background: #fff8e5;
    border-color: #f4d68a;
    color: #6b4a00;
}

.text-right {
    text-align: right;
}

.inline-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

@media (max-width: 980px) {
    .import-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .import-summary-grid {
        grid-template-columns: 1fr;
    }
}


/* =========================================================
   BLOCCO: EVENTI
   ========================================================= */
.event-layout {
    grid-template-columns: minmax(0, 1fr) 390px;
}

.table-scroll {
    overflow-x: auto;
}

.no-wrap {
    white-space: nowrap;
}

.inline-form {
    display: inline-flex;
    margin: 0 0 0 4px;
    padding: 0;
    vertical-align: middle;
}

button.icon-btn {
    border: 0;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.icon-btn-danger {
    background: #fde2e2;
    color: #9b1c1c;
}

.icon-btn-danger:hover {
    background: #f9c7c7;
}

@media (max-width: 1000px) {
    .event-layout {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   BLOCCO: ISCRITTI
   ========================================================= */
.filter-bar {
    display: grid;
    grid-template-columns: minmax(280px, 1.4fr) minmax(220px, 0.8fr) auto;
    gap: 12px;
    align-items: end;
    padding: 14px;
    border-bottom: 1px solid var(--line);
    background: #fbfdff;
}

.filter-bar label {
    margin-top: 0;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-bottom: 1px;
}

.event-info-box {
    margin: 14px 14px 0;
    padding: 12px 14px;
    border: 1px solid #cdd9e4;
    border-radius: 10px;
    background: #f4f8fb;
}

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

.iscritti-summary-grid {
    margin: 14px;
}

.iscritti-layout {
    grid-template-columns: minmax(0, 1fr) 520px;
    align-items: start;
}

.iscritti-form-card {
    max-height: calc(100vh - 115px);
    overflow-y: auto;
}

.iscritti-table {
    font-size: 12px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 12px;
}

.form-section-title {
    margin: 18px 0 6px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #eef3f7;
    color: #24364a;
    font-weight: 800;
    font-size: 13px;
}

textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #cbd5df;
    border-radius: 8px;
    font-size: 14px;
    font-family: Arial, Helvetica, sans-serif;
    resize: vertical;
    background: #ffffff;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 110, 168, 0.15);
}

.badge-warn {
    background: #fff1c2;
    color: #8a5a00;
}

.compact-alert {
    margin: 12px 0 0;
}

.sticky-actions {
    position: sticky;
    bottom: -16px;
    background: #ffffff;
    border-top: 1px solid var(--line);
    padding: 12px 0 0;
}

@media (max-width: 1200px) {
    .iscritti-layout {
        grid-template-columns: 1fr;
    }

    .iscritti-form-card {
        max-height: none;
    }
}

@media (max-width: 800px) {
    .filter-bar,
    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        justify-content: flex-start;
    }
}

/* =========================================================
   BLOCCO: MENU TOOLS E SVUOTA DB
   ========================================================= */
.app-menu-group {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 0 16px;
    margin-top: 8px;
    color: #ffffff;
    font-weight: 700;
    border-left: 4px solid transparent;
    background: rgba(0, 0, 0, 0.08);
}

.app-submenu .app-menu-link {
    min-height: 38px;
    padding-left: 34px;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.06);
}

.danger-zone {
    padding: 16px;
}

.danger-zone h3 {
    margin: 0 0 8px;
    color: var(--danger-text);
}

.danger-zone p {
    margin: 0 0 16px;
    color: var(--muted);
    line-height: 1.5;
}

.compact-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 18px;
}

.safe-card strong {
    color: var(--success-text);
}

.confirm-form {
    border: 1px solid #fecaca;
    background: #fff7f7;
    border-radius: 12px;
    padding: 14px;
}

.btn-danger {
    background: #b91c1c;
    color: #ffffff;
}

.btn-danger:hover {
    background: #991b1b;
}

@media (max-width: 900px) {
    .app-menu-group {
        margin-top: 0;
        white-space: nowrap;
        border-left: 0;
        border-bottom: 4px solid transparent;
    }

    .app-submenu {
        display: flex;
    }

    .app-submenu .app-menu-link {
        padding-left: 16px;
    }

    .compact-grid {
        grid-template-columns: 1fr;
    }
}
