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

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --accent-primary: #0f4c75;
    --accent-secondary: #3282b8;
    --accent-glow: #00d4ff;
    --text-primary: #e8e8e8;
    --text-secondary: #a8a8b3;
    --success: #00ff88;
    --success-color: #10b981;
    --warning: #ffaa00;
    --error: #ff3366;
    --border-color: #2a2a3e;
    --shadow-color: rgba(0, 212, 255, 0.1);
}

/* Base */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    background-image: 
        radial-gradient(ellipse at top left, rgba(15, 76, 117, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(50, 130, 184, 0.1) 0%, transparent 50%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
    animation: slideDown 0.8s ease-out;
}
.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.logo {
    height: 50px;
    width: auto;
    filter: drop-shadow(0 4px 10px rgba(0, 212, 255, 0.2));
}

.title {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-glow) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.subtitle {
    color: #2597cb;
    font-size: 1.1rem;
    font-weight: 300;
}

.back-button {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.7rem 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 0.9rem;
}

.back-button:hover {
    color: white;
    border-color: var(--error);
    background: var(--error);
    transform: translateY(-2px);
}

.back-button svg {
    width: 20px;
    height: 20px;
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

.export-button {
    background: #16213e;
    border: 2px solid #16213e;
    border-radius: 10px;
    padding: 0.75rem 1.5rem;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 2px 8px rgba(33, 115, 70, 0.3);
}

.export-button:hover {
    background: linear-gradient(135deg, #2e7d32, #388e3c);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.4);
}

.export-button svg {
    width: 30px;
    height: 30px;
}

.new-search-button {
    background: #05a3cb;
    border: 2px solid #16213e;
    border-radius: 10px;
    padding: 0.75rem 1.5rem;
    color: #1e3a8a;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.3s ease;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.new-search-button:hover {
    background: #fde68a;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(251, 191, 36, 0.6);
    border-color: #f59e0b;
    color: #1e293b;
}

.new-search-button svg {
    width: 18px;
    height: 18px;
    stroke: #1e3a8a;
}

/* Results Section */
.results-section {
    margin-top: 2rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
}

.results-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    position: relative;
}

/* Scrollbar orizzontale in alto */
.scroll-top {
    overflow-x: auto;
    overflow-y: hidden;
    height: 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.scroll-top-inner {
    height: 20px;
    background: transparent;
}

/* Contenitore tabella con scroll */
.table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 60vh;
    -webkit-overflow-scrolling: touch;
}

.results-table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
    margin-right: 20px;
    display: table;
}

.results-table thead {
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.results-table th {
    padding: 1.2rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--accent-glow);
    border-bottom: 2px solid var(--accent-primary);
    white-space: nowrap;
    min-width: 120px;
}

.results-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.results-table tbody tr {
    transition: background-color 0.2s ease;
}

.results-table tbody tr:hover {
    background: rgba(50, 130, 184, 0.1);
}

.even-row {
    background: rgba(26, 26, 46, 0.3);
}

/* Mobile Cards */
.mobile-cards {
    display: none;
    flex-direction: column;
    gap: 1rem;
}

.result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.result-card:last-child {
    margin-bottom: 0;
}

.card-field {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-field:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.field-label {
    font-size: 0.85rem;
    color: var(--accent-glow);
    font-weight: 600;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-value {
    color: var(--text-primary);
    font-size: 1rem;
    word-break: break-word;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
}

.no-results svg {
    width: 80px;
    height: 80px;
    stroke: var(--text-secondary);
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.no-results h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.no-results p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Loading Spinner */
.loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 15, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-glow);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.loading-spinner p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Error Message */
.error-message {
    background: var(--bg-secondary);
    border: 2px solid var(--error);
    border-radius: 16px;
    padding: 2rem;
    margin: 2rem 0;
    box-shadow: 0 10px 40px rgba(255, 51, 102, 0.3);
}

.error-content {
    text-align: center;
}

.error-content svg {
    width: 60px;
    height: 60px;
    stroke: var(--error);
    margin-bottom: 1rem;
}

.error-content p {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.retry-button {
    background: var(--error);
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-button:hover {
    background: #ff1a4d;
    transform: translateY(-2px);
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Mobile */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .title {
        font-size: 2rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .logo {
        height: 40px;
    }
    
    .results-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .results-header h2 {
        font-size: 1.4rem;
        margin-bottom: 1rem;
    }
    
    .action-buttons {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .export-button,
    .new-search-button {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .results-container {
        background: transparent;
        border: none;
        overflow: visible;
        padding: 0;
        box-shadow: none;
    }
    
    .results-table {
        display: none !important;
    }
    
    .mobile-cards {
        display: flex !important;
        flex-direction: column;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}
