/* --- 1. Variabili Globali e Reset --- */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');

:root {
    --primary-color: #005A9C;
    --secondary-color: #00A3E0;
    
    --background-color: #f8f9fa;
    --text-color: #343a40;
    --card-bg: #ffffff;
    --border-color: #dee2e6;
    --shadow: 0 4px 12px rgba(0,0,0,0.08);

    --status-success: #28a745;
    --status-warning: #ffc107;
    --status-warning-bg: #fffbe6;
    --status-warning-border: #ffeeba;
    --status-warning-text: #856404;
    --status-danger: #dc3545;
    --status-danger-bg: #f8d7da;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 2rem 1rem;
}

/* --- 2. Layout Principale --- */
.calculator {
    max-width: 900px;
    margin: 0 auto;
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.calculator__header {
    background-color: var(--primary-color);
    color: white;
    padding: 2rem 2.5rem;
    text-align: center;
}
.calculator__header h1 { margin: 0; font-size: 2.2rem; }
.calculator__header p { margin: 0.5rem 0 0; opacity: 0.9; }

.calculator__main { padding: 2.5rem; }

h3 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

h4 {
    text-align: center;
    color: var(--primary-color);
    margin-top: 1.5rem;
}

/* --- 3. Form --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.form-group label {
    font-weight: bold;
    margin-bottom: 0.5rem;
    font-size: 0.9em;
    display: block;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1em;
    box-sizing: border-box;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.form-group input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(0, 163, 224, 0.2);
}

.calculator__button {
    display: block;
    width: 100%;
    padding: 1rem;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    margin-top: 2rem;
    transition: background-color 0.3s;
}
.calculator__button:hover { background-color: #007bb5; }

/* --- 4. Risultati --- */
.calculator__results-section { margin-top: 3rem; }

.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.summary__card {
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    border-bottom: 4px solid;
}
#summary-drawdown { border-color: var(--status-danger); }
#summary-critical-value { border-color: var(--primary-color); }
#summary-leverage { border-color: var(--secondary-color); }

.summary__card h4 { margin: 0 0 0.5rem; font-size: 1em; color: #6c757d; }
.summary__card .value { font-size: 2.2em; font-weight: bold; }
#summary-drawdown .value { color: var(--status-danger); }
#summary-critical-value .value { color: var(--primary-color); }
#summary-leverage .value { color: var(--secondary-color); }

.analysis-section__description {
    text-align: center;
    color: #6c757d;
    margin-top: -1rem;
    margin-bottom: 1.5rem;
}

.table-container { overflow-x: auto; }
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.95em;
}
.results-table th, .results-table td {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    text-align: center;
}
.results-table th { background-color: var(--primary-color); color: white; }
.results-table tbody tr:nth-child(even) { background-color: #f8f9fa; }

.status--safe { color: var(--status-success); font-weight: bold; }
.status--warning { color: var(--status-warning); font-weight: bold; }
.status--danger { color: var(--status-danger); font-weight: bold; }

/* --- 5. Elementi UI Aggiuntivi --- */
.error-message {
    padding: 1rem;
    background-color: var(--status-danger-bg);
    color: var(--status-danger);
    border: 1px solid var(--status-danger);
    border-radius: 4px;
    margin-top: 1.5rem;
    text-align: center;
}

/* --- 6. Sezioni Informative (REINTEGRATE) --- */
.info-section, .suggestions-section {
    margin-top: 3rem;
    padding: 2rem;
    border-radius: 8px;
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
}
.info-section h3, .suggestions-section h3 {
    margin-top: 0;
}

.info-section__formula-box {
    background-color: #e9ecef;
    padding: 1rem;
    border-radius: 6px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    text-align: center;
    margin: 1.5rem 0;
    overflow-x: auto;
}

.info-section__explanation {
    background-color: var(--card-bg);
    border-left: 4px solid var(--secondary-color);
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    font-style: italic;
    color: #555;
    border-radius: 0 4px 4px 0;
}
.info-section__explanation strong { font-style: normal; }

.info-section__divider {
    margin: 2.5rem 0;
    border: 0;
    border-top: 1px solid var(--border-color);
}

.suggestions-section {
    background-color: var(--status-warning-bg);
    border-color: var(--status-warning-border);
}
.suggestions-section h3 {
    color: var(--status-warning-text);
}
.suggestions-section ul {
    padding-left: 20px;
    margin: 0;
}