/* ============================================
   Compatibilità Chimica - Tubi PP, PE-RT, PPS
   Tema verde/ambra (chimica)
   ============================================ */

:root {
    --color-bg: #0d1210;
    --color-bg-card: #151d18;
    --color-surface: #1e2a24;
    
    --color-primary: #22c55e;
    --color-primary-dim: #16a34a;
    --color-accent: #eab308;
    
    --color-text: #e8f0ec;
    --color-text-muted: #94a39e;
    --color-text-dim: #647870;
    
    --color-border: #2d3d35;
    --color-border-focus: #22c55e;
    
    --res-pp: #166534;
    --res-p: #1e40af;
    --res-o: #a16207;
    --res-n: #991b1b;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
    
    --font-sans: 'Outfit', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --transition: 0.2s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(34, 197, 94, 0.08), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(234, 179, 8, 0.05), transparent);
    pointer-events: none;
    z-index: 0;
}

.app-container {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    margin-bottom: 2rem;
    text-align: center;
}

.back-link {
    display: inline-block;
    font-size: 0.9rem;
    color: var(--color-primary);
    text-decoration: none;
    margin-bottom: 1rem;
    transition: opacity 0.2s;
}

.back-link:hover {
    opacity: 0.8;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    color: var(--color-primary);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.intro-card,
.legend-card,
.filter-card,
.table-card,
.materials-card,
.disclaimer-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.75rem;
    box-shadow: var(--shadow-md);
}

.intro-card p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--color-text-muted);
}

.intro-card a {
    color: var(--color-primary);
    text-decoration: none;
}

.intro-card a:hover {
    text-decoration: underline;
}

.legend-card h3,
.materials-card h3,
.disclaimer-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.legend-item .badge {
    flex-shrink: 0;
    width: 2rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 4px;
}

.legend-item.res-pp .badge { background: rgba(22, 101, 52, 0.5); color: #86efac; }
.legend-item.res-p .badge { background: rgba(30, 64, 175, 0.5); color: #93c5fd; }
.legend-item.res-o .badge { background: rgba(161, 98, 7, 0.5); color: #fde047; }
.legend-item.res-n .badge { background: rgba(153, 27, 27, 0.5); color: #fca5a5; }

.filter-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-card label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.filter-card input {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    padding: 0.7rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
}

.filter-card input::placeholder {
    color: var(--color-text-dim);
}

.filter-card input:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.chem-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.chem-table th,
.chem-table td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.chem-table th {
    font-weight: 600;
    color: var(--color-text-muted);
    background: rgba(0, 0, 0, 0.2);
}

.chem-table th small {
    font-weight: 400;
    font-size: 0.75rem;
    display: block;
    margin-top: 0.2rem;
}

.chem-table tbody tr:hover {
    background: rgba(34, 197, 94, 0.05);
}

.chem-table td:nth-child(1) { font-weight: 500; }
.chem-table td:nth-child(2) { color: var(--color-text-dim); font-size: 0.8rem; }
.chem-table td:nth-child(3) { text-align: center; font-family: var(--font-mono); }

.chem-table .rating {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 1.6rem;
    font-weight: 700;
    border-radius: 4px;
}

.chem-table .rating.pp { background: rgba(22, 101, 52, 0.4); color: #86efac; }
.chem-table .rating.p { background: rgba(30, 64, 175, 0.4); color: #93c5fd; }
.chem-table .rating.o { background: rgba(161, 98, 7, 0.4); color: #fde047; }
.chem-table .rating.n { background: rgba(153, 27, 27, 0.4); color: #fca5a5; }
.chem-table .rating.na { background: rgba(100, 116, 139, 0.3); color: var(--color-text-dim); }

.materials-card ul,
.disclaimer-card ul {
    list-style: none;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.materials-card li {
    padding: 0.4rem 0;
    padding-left: 1.2rem;
    position: relative;
}

.materials-card li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--color-primary);
}

.disclaimer-card p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.disclaimer-card a {
    color: var(--color-primary);
    text-decoration: none;
}

.disclaimer-card a:hover {
    text-decoration: underline;
}

.footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-text-dim);
}

.footer a {
    color: var(--color-primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .app-container { padding: 1.5rem 1rem; }
    .chem-table { font-size: 0.8rem; }
    .chem-table th, .chem-table td { padding: 0.5rem 0.5rem; }
    .legend-grid { grid-template-columns: 1fr; }
}

@media print {
    body::before { display: none; }
    .filter-card { display: none !important; }
    .table-card { box-shadow: none; }
}
