/* 
 * Foglio di Stile Globale - Palette Naturale Rilassante
 * Colori: Verde Bosco, Salvia, Marrone Legno, Sabbia Morbido
 */

:root {
    --bg-main: #f4ede4;
    --bg-card: #ffffff;
    --text-main: #3e3129;
    --text-muted: #6b5c53;
    --primary: #8b5a2b;      /* Marrone Legno Caldo come Primario */
    --primary-hover: #704821;
    --primary-light: #f7efe4;  /* Sabbia chiarissimo per sfondi primari */
    --secondary: #2d5a27;    /* Verde Bosco come Secondario */
    --secondary-hover: #1e3f1a;
    --secondary-light: #eef5ed; /* Verde Salvia chiarissimo per sfondi secondari */
    --border-color: #e2d7cb;
    --border-color-focus: #2d5a27;
    
    /* Toni Verifiche Rilassanti e Naturali (Desaturati) */
    --ok-bg: #e2f0d9;        /* Verde Foglia Chiarissimo */
    --ok-text: #385623;      /* Verde Oliva Scuro */
    --ok-border: #c5e0b4;
    
    --ko-bg: #fbe5d6;        /* Terracotta Chiarissimo */
    --ko-text: #c65911;      /* Ruggine Scuro */
    --ko-border: #f8cbad;
    
    --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    line-height: 1.5;
}

/* Layout */
.container {
    display: flex;
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
    flex-wrap: wrap;
    align-items: flex-start;
}

.panel {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(139, 90, 43, 0.05);
    border: 1px solid var(--border-color);
    flex: 1;
    min-width: 460px;
    position: relative;
    box-sizing: border-box;
}

/* Intestazioni */
h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    padding: 10px 14px;
    border-radius: 6px;
    border-left: 4px solid var(--primary);
    margin-top: 0;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

h3 {
    color: var(--secondary);
    font-size: 1.05rem;
    border-bottom: 2px solid var(--secondary-light);
    padding-bottom: 6px;
    margin-top: 24px;
    margin-bottom: 12px;
}

p {
    margin: 0 0 10px 0;
}

/* Form e Input */
.form-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.form-group-full {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.form-group-full label {
    width: 100%;
    margin-bottom: 6px;
}

label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    width: 45%;
    display: flex;
    align-items: center;
}

input, select {
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
    color: var(--text-main);
    background-color: var(--bg-card);
    transition: all 0.2s ease;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--border-color-focus);
    box-shadow: 0 0 0 3px rgba(139, 90, 43, 0.15);
}

.input-main {
    width: 50%;
    text-align: right;
}

input[readonly] {
    background-color: #f1f3f1;
    color: var(--text-muted);
    cursor: not-allowed;
}

.warn-input {
    background-color: #fff9e6 !important;
    border-color: #e6b800 !important;
    color: #b38f00;
}

/* Pulsanti */
.btn-action {
    background: var(--primary);
    color: #ffffff;
    border: none;
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    width: 100%;
    margin-top: 10px;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-action:hover {
    background: var(--primary-hover);
}

.btn-action:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--secondary);
    color: #ffffff;
    border: none;
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    width: 100%;
    margin-top: 10px;
    transition: background-color 0.2s ease;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

.btn-help {
    background: var(--secondary-light);
    color: var(--secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 11px;
    cursor: pointer;
    margin-left: 8px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-help:hover {
    background: var(--secondary);
    color: #ffffff;
    border-color: var(--secondary);
}

/* Tabelle */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 0.85rem;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

th, td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
}

tr:last-child td {
    border-bottom: none;
}

/* Esiti Verifiche */
.ok {
    background-color: var(--ok-bg) !important;
    color: var(--ok-text) !important;
    font-weight: 700;
}

.ko {
    background-color: var(--ko-bg) !important;
    color: var(--ko-text) !important;
    font-weight: 700;
}

/* Scatole Risultati */
.results-box {
    background: var(--primary-light);
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    border-left: 4px solid var(--primary);
    font-size: 0.9rem;
}

.results-box p {
    margin-bottom: 6px;
}
.results-box p:last-child {
    margin-bottom: 0;
}

/* Abaco Ottimizzazione */
.abaco-cell {
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

.abaco-cell:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
    z-index: 10;
    position: relative;
    border: 1px solid var(--primary) !important;
}

/* Details ed Elementi Espandibili */
details {
    background: var(--secondary-light);
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

details[open] {
    background: var(--bg-card);
    border-color: var(--secondary);
}

summary {
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--secondary);
    outline: none;
}

.g2-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.8rem;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 6px;
}

.g2-row:last-child {
    border-bottom: none;
}

.g2-row input, .g2-row select {
    font-size: 0.75rem;
    padding: 4px 6px;
}

.g2-label {
    font-weight: 600;
    width: 32%;
}

.g2-controls {
    width: 56%;
    display: flex;
    gap: 4px;
    align-items: center;
}

.g2-out {
    width: 12%;
    text-align: right;
    font-weight: 700;
    color: var(--text-main);
}

/* Badge di Salvataggio */
.badge-save {
    position: absolute;
    top: 25px;
    right: 25px;
    font-size: 0.75rem;
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

/* Error Box */
#error_box {
    display: none;
    background: var(--ko-bg);
    color: var(--ko-text);
    border: 1px solid var(--ko-border);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 18px;
    font-weight: 700;
    font-size: 0.85rem;
}

/* Modali per Aiuti */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(46, 59, 46, 0.4);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-card);
    margin: auto;
    padding: 24px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    position: relative;
    animation: modalopen 0.3s ease;
}

@keyframes modalopen {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    font-weight: bold;
    color: var(--text-muted);
    border: none;
    background: none;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--text-main);
}

/* SVG Schema Statico */
#svg_container {
    margin-top: 14px;
}

/* Selettori Geometria */
.geometry-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.geometry-card {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    background: var(--bg-card);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: auto;
}

.geometry-card:hover {
    border-color: var(--secondary);
    background: var(--secondary-light);
}

.geometry-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
    font-weight: 700;
}

.geometry-card svg {
    display: block;
    margin: 8px auto 0 auto;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.card-title {
    font-size: 0.8rem;
    line-height: 1.2;
    color: var(--text-main);
}

/* Sidebar and Dashboard Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    margin: -20px; /* Offset body padding */
}

.sidebar {
    width: 290px;
    background-color: var(--primary);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 24px;
    box-sizing: border-box;
    border-right: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: #ffffff;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    padding-bottom: 15px;
}

.sidebar-logo svg {
    fill: #ffffff;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.menu-item {
    display: block;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.menu-item.active a, .menu-item a:hover {
    background-color: rgba(255,255,255,0.15);
    color: #ffffff;
}

.sidebar-footer {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 15px;
    margin-top: 20px;
    margin-bottom: 30px;
}

.main-stage {
    flex: 1;
    padding: 24px 24px 54px 24px;
    overflow-y: auto;
    background-color: var(--bg-main);
    box-sizing: border-box;
}

.iframe-container {
    width: 100%;
    height: calc(100vh - 48px);
    border: none;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(139, 90, 43, 0.05);
    display: block;
}

/* Dashboard Summary Cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.summary-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(139, 90, 43, 0.03);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease;
}

.summary-card:hover {
    transform: translateY(-2px);
}

.summary-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.summary-card-title {
    font-weight: 700;
    color: var(--primary);
    font-size: 1rem;
}

.summary-status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.summary-details {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.summary-details p {
    margin-bottom: 4px;
}

.summary-card-footer {
    margin-top: 14px;
    border-top: 1px dashed var(--border-color);
    padding-top: 10px;
    text-align: right;
}

.summary-link:hover {
    text-decoration: underline;
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE & TABLET FRIENDLY)
   ========================================================================== */
/* Mobile Header Styles */
.mobile-header {
    display: none;
    height: 50px;
    background-color: var(--primary);
    color: #ffffff;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    font-family: var(--font-family);
    box-sizing: border-box;
}

.menu-toggle-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-logo-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .mobile-header {
        display: flex;
    }
    
    .app-wrapper {
        flex-direction: column;
        min-height: calc(100vh - 50px);
        margin: 0;
    }
    
    .sidebar {
        position: fixed;
        top: 50px;
        left: -290px;
        width: 290px;
        height: calc(100vh - 50px);
        z-index: 998;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .sidebar-logo {
        display: none; /* Nascondi logo grande su mobile per risparmiare spazio */
    }
    
    .sidebar-menu {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 8px;
        justify-content: flex-start;
    }
    
    .sidebar-menu .menu-item a {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    .sidebar-footer {
        display: block;
        margin-top: 20px;
        margin-bottom: 20px;
    }
    
    .main-stage {
        padding: 15px;
    }
    
    .iframe-container {
        height: calc(100vh - 80px);
    }
    
    .container {
        gap: 15px;
    }
    
    .panel {
        min-width: 100% !important;
        padding: 15px;
    }
    
    .form-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        margin-bottom: 15px;
    }
    
    .form-group label {
        width: 100%;
    }
    
    .form-group input, .form-group select {
        width: 100% !important;
        text-align: left;
    }
    
    .input-main {
        width: 100% !important;
        text-align: left !important;
    }
    
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .geometry-selector {
        grid-template-columns: 1fr 1fr;
    }
}

/* ==========================================================================
   GUIDA INTERATTIVA / TOUR UTILITIES
   ========================================================================== */
.tour-highlight {
    position: relative !important;
    z-index: 10001 !important;
    outline: 4px dashed var(--primary) !important;
    outline-offset: 4px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6) !important;
    pointer-events: none; /* Evita interazioni non pianificate */
}

.tour-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent;
    z-index: 10000;
    pointer-events: auto;
}

.tour-card {
    position: fixed;
    z-index: 10002;
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 20px;
    width: 320px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    font-family: var(--font-family);
    animation: tourCardOpen 0.25s ease-out;
    color: var(--text-main);
}

@keyframes tourCardOpen {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.tour-card h4 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.1rem;
    color: var(--primary);
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tour-card p {
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 16px;
    color: var(--text-muted);
}

.tour-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.tour-btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.tour-btn-prev {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--border-color);
}

.tour-btn-next {
    background: var(--primary);
    color: white;
    flex-grow: 1;
}

.tour-btn-next:hover {
    background: var(--primary-hover);
}

.tour-btn-skip {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: normal;
    text-decoration: underline;
}
.tour-btn-skip:hover {
    color: var(--ko-text);
}

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* Sidebar Menu Tooltips */
.sidebar-menu .menu-item {
    position: relative;
}

.menu-tooltip {
    display: none;
    position: absolute;
    left: 102%;
    top: 50%;
    transform: translateY(-50%);
    width: 260px;
    background: #1b4332;
    color: #ffffff;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    z-index: 9999;
    pointer-events: none;
    font-size: 0.8rem;
    line-height: 1.4;
    border: 1px solid #2d6a4f;
    transition: opacity 0.2s ease, transform 0.2s ease;
    opacity: 0;
    transform: translateY(-50%) translateX(10px);
}

.menu-tooltip::before {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%;
    transform: translateY(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: transparent #1b4332 transparent transparent;
}

.menu-tooltip h4 {
    margin: 0 0 6px 0;
    color: #74c69d;
    font-size: 0.88rem;
    font-weight: bold;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    padding-bottom: 4px;
}

.menu-tooltip p {
    margin: 0;
    color: #d8f3dc;
    text-align: justify;
}

.sidebar-menu .menu-item:hover .menu-tooltip {
    display: block;
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}




