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

/* Variabili */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg-light: #f9fafb;
    --border: #e5e7eb;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background-color: #eee;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    opacity: 0.9;
    font-size: 1rem;
}

/* Main content */
main {
    padding: 2rem;
}

/* Form styling */
.input-section h2 {
    color: var(--text);
    margin-bottom: 0.5rem;
}

.help-text {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

#etf-list {
    margin-bottom: 1.5rem;
}

.etf-row {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

/* Input styling */
input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input[type="text"].isin-input {
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.05em;
}

input:invalid {
    border-color: var(--danger);
}

/* Buttons */
button,
.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background: white;
    border-color: var(--primary);
    color: var(--primary);
}

.btn-remove {
    width: 40px;
    height: 40px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0;
}

.btn-remove:hover {
    background: #dc2626;
    transform: rotate(90deg);
}

/* CSV actions */
.csv-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Spinner animation */
.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: white;
    font-size: 1.5rem;
    margin-top: 1.5rem;
    font-weight: 500;
}

.loading-subtext {
    color: rgba(255, 255, 255, 0.7);
    margin-top: 0.5rem;
}

/* Results styling */
.summary-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 2rem;
}

.summary-card h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.total-amount {
    font-size: 2.5rem;
    font-weight: bold;
}

.exposure-section {
    margin-bottom: 2.5rem;
}

.exposure-section h2 {
    color: var(--text);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.exposure-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.exposure-item {
    background: var(--bg-light);
    padding: 1rem;
    border-radius: 8px;
    transition: transform 0.2s;
}

.exposure-item:hover {
    transform: translateX(5px);
}

.exposure-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.exposure-name {
    font-weight: 500;
    color: var(--text);
}

.exposure-percentage {
    font-weight: bold;
    color: var(--primary);
}

/* Chart container */
.chart-container {
    max-width: 400px;
    margin: 0 auto 2rem;
    padding: 1rem;
}

/* Legend table styling */
.exposure-legend {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: var(--bg-light);
    border-radius: 8px;
    overflow: hidden;
}

.exposure-legend tr {
    transition: background-color 0.2s;
}

.exposure-legend tr:hover {
    background-color: rgba(99, 102, 241, 0.05);
}

.exposure-legend tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.02);
}

.exposure-legend td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.exposure-legend tr:last-child td {
    border-bottom: none;
}

.legend-name {
    font-weight: 500;
    color: var(--text);
}

.legend-percentage {
    font-weight: bold;
    color: var(--primary);
    text-align: center;
    white-space: nowrap;
}

.legend-amount {
    color: var(--text-light);
    text-align: right;
    white-space: nowrap;
}

.no-data {
    color: var(--text-light);
    text-align: center;
    padding: 2rem;
}

.actions {
    text-align: center;
    margin-top: 2rem;
}

/* Info box */
.info-box {
    background: var(--bg-light);
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 2rem;
    border-left: 4px solid var(--primary);
}

.info-box h3 {
    color: var(--text);
    margin-bottom: 1rem;
}

.info-box ul {
    list-style: none;
}

.info-box li {
    color: var(--text-light);
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
}

.info-box li:before {
    content: "•";
    position: absolute;
    left: 0.5rem;
    color: var(--primary);
    font-weight: bold;
}

/* Footer */
footer {
    background: var(--bg-light);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem;
    }

    .container {
        border-radius: 0;
    }

    header h1 {
        font-size: 1.5rem;
    }

    main {
        padding: 1.5rem;
    }

    .etf-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .btn-remove {
        width: 100%;
        border-radius: 8px;
    }

    .form-actions {
        flex-direction: column;
    }

    .total-amount {
        font-size: 2rem;
    }
}
