/* ITI Hub Portal — Stile */
/* Palette derivata da itistudio.com — Fase 4.5 Step A */

:root {
    --primary: #454966;
    --primary-dark: #363a52;
    --secondary: #929ec4;
    --secondary-light: #b8c1db;
    --danger: #dc2626;
    --success: #16a34a;
    --warn: #f59e0b;
    --bg: #f8f9fb;
    --card-bg: #ffffff;
    --text: #454966;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f0f1f3;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(69, 73, 102, 0.06);
    --shadow-md: 0 4px 16px rgba(69, 73, 102, 0.08);
    --shadow-lg: 0 8px 32px rgba(69, 73, 102, 0.12);
}

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

body {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* Navbar */
.navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.navbar-brand a {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}
.navbar-logo {
    color: var(--text);
    flex-shrink: 0;
}
.navbar-menu { display: flex; align-items: center; gap: 16px; }
.navbar-user { font-size: 0.875rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.navbar-user-sigla { font-weight: 800; color: var(--text); font-size: 0.85rem; }
.navbar-link {
    color: var(--text-muted); text-decoration: none; font-size: 0.875rem; font-weight: 500;
    transition: color 0.2s;
}
.navbar-link:hover { color: var(--primary); text-decoration: none; }

/* Buttons */
.btn {
    padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--card-bg); cursor: pointer; font-size: 0.875rem;
    text-decoration: none; display: inline-block;
    font-family: 'Manrope', sans-serif; font-weight: 500;
    transition: all 0.2s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.85rem; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.95rem; font-family: 'Manrope', sans-serif; color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-light); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(69, 73, 102, 0.08);
}
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

.error-msg { color: var(--danger); background: #fef2f2; padding: 8px 12px; border-radius: var(--radius); margin: 8px 0; font-size: 0.875rem; }
.success-msg { color: var(--success); background: #f0fdf4; padding: 8px 12px; border-radius: var(--radius); margin: 8px 0; font-size: 0.875rem; }

/* Login */
.login-container {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--bg);
}
.login-card {
    background: var(--card-bg); padding: 48px 40px 40px; border-radius: var(--radius-lg);
    width: 420px; max-width: 90vw;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}
.login-logo {
    display: flex; justify-content: center; margin-bottom: 28px;
}
.login-logo svg { color: var(--text); }
.login-card h1 {
    text-align: center; color: var(--text); margin-bottom: 4px;
    font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em;
}
.login-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 32px; font-size: 0.9rem; }
.login-footer {
    text-align: center; margin-top: 24px;
    font-size: 0.8rem; color: var(--text-light);
}
.cert-help {
    margin-top: 20px; text-align: center;
}
.cert-help details { font-size: 0.78rem; color: var(--text-light); }
.cert-help summary {
    cursor: pointer; font-weight: 500; color: var(--text-muted);
    transition: color 0.2s;
}
.cert-help summary:hover { color: var(--primary); }
.cert-help p { margin: 8px 0; font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }
.cert-link {
    display: inline-block; padding: 6px 16px;
    background: var(--primary); color: #fff; border-radius: 6px;
    text-decoration: none; font-weight: 600; font-size: 0.82rem;
    transition: background 0.2s;
}
.cert-link:hover { background: #363a52; }
.cert-steps { font-size: 0.72rem; color: var(--text-light); text-align: left; line-height: 1.6; }

/* Cards */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }

/* Tool grid */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 24px; }
.tool-card {
    display: flex; align-items: center; gap: 18px;
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 22px 24px; text-decoration: none; color: var(--text);
    transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}
.tool-card:hover {
    box-shadow: var(--shadow-md); transform: translateY(-3px);
    border-color: var(--secondary-light);
}
.tool-icon {
    font-size: 2.2rem; flex-shrink: 0;
    width: 52px; height: 52px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg); border-radius: var(--radius);
}
.tool-info h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 3px; }
.tool-info p { font-size: 0.82rem; color: var(--text-muted); line-height: 1.4; }

/* Dashboard welcome */
.dashboard-welcome { margin-bottom: 8px; }
.dashboard-welcome h2 { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.dashboard-welcome p { font-size: 0.9rem; color: var(--text-muted); margin-top: 2px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; background: var(--card-bg); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.data-table th { background: var(--bg); font-weight: 600; color: var(--text-muted); }
.data-table tr:hover { background: rgba(146, 158, 196, 0.06); }
.row-disabled { opacity: 0.5; }
.row-warn { background: #fffbeb; }

/* Miniatura SVG inline nelle celle tabella */
.data-table td svg {
    width: 20px;
    height: 20px;
    stroke: var(--secondary);
    stroke-width: 1.5;
    fill: none;
    vertical-align: middle;
}

.info-table { width: 100%; }
.info-table th { text-align: right; padding-right: 16px; color: var(--text-muted); width: 120px; }
.info-table td { padding: 6px 0; }

/* Badges */
.badge { padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fef2f2; color: var(--danger); }

/* Admin tabs */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 2px solid var(--border); }
.tab-btn {
    padding: 10px 20px; border: none; background: none; cursor: pointer;
    font-size: 0.9rem; color: var(--text-muted); border-bottom: 2px solid transparent;
    margin-bottom: -2px; font-family: 'Manrope', sans-serif; font-weight: 500;
    transition: color 0.2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

/* Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(69, 73, 102, 0.4); display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal {
    background: var(--card-bg); border-radius: var(--radius-lg); padding: 28px;
    width: 520px; max-width: 90vw; max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal h3 { margin-bottom: 20px; font-weight: 700; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* Checkboxes — elenco verticale compatto */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 180px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 6px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg);
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 1px 0;
    line-height: 1.4;
}
.checkbox-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    margin: 0 6px 0 0;
    flex-shrink: 0;
}

.loading { color: var(--text-muted); font-style: italic; }

/* Search input (C.1) */
.search-input {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: 'Manrope', sans-serif;
    color: var(--text);
    min-width: 200px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input::placeholder { color: var(--text-light); }
.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(69, 73, 102, 0.08);
}

/* Modal header con pulsante X (C.1-C.7) */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal-header h3 { margin-bottom: 0; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}
.modal-close:hover { color: var(--text); }

/* Sortable columns (C.2) */
.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 20px !important;
}
.sortable:hover { color: var(--primary); }
.sortable::after {
    content: '⇅';
    position: absolute;
    right: 4px;
    font-size: 0.7rem;
    color: var(--text-light);
}
.sortable.sort-asc::after {
    content: '▲';
    color: var(--primary);
}
.sortable.sort-desc::after {
    content: '▼';
    color: var(--primary);
}

/* Popup fields row (C.5) */
.popup-fields {
    display: flex;
    gap: 16px;
}
.popup-fields .form-group { flex: 1; }

/* Checkbox accent color */
.checkbox-group input[type="checkbox"] {
    accent-color: var(--primary);
}

/* Upload icona tool (C.7) */
.icon-upload-area {
    display: flex;
    align-items: center;
    gap: 12px;
}
.icon-preview {
    width: 48px;
    height: 48px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    overflow: hidden;
    flex-shrink: 0;
}
.icon-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.icon-preview svg {
    width: 36px;
    height: 36px;
    stroke: var(--text);
    stroke-width: 1.4;
    fill: none;
}
.icon-upload-btns {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.icon-upload-btns .btn { font-size: 0.78rem; padding: 4px 10px; }
.icon-upload-btns small { font-size: 0.72rem; color: var(--text-light); }

/* ── Impostazioni ── */
.settings-section { max-width: 720px; }
.settings-help {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.5;
}
.settings-help code {
    background: var(--border-light);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.82rem;
    color: var(--primary);
}
