/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #1a1a1a;
    background: #fafafa;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
header {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 1000;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: #2563eb;
    text-decoration: none;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 32px;
}

.nav-links a {
    text-decoration: none;
    color: #4b5563;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: #2563eb;
}

/* Search Hero Section */
.search-hero {
    padding: 60px 0 40px;
    text-align: center;
}

.search-hero h1 {
    font-size: 48px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.search-hero p {
    font-size: 20px;
    color: #6b7280;
    margin-bottom: 48px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Search Container */
.search-container {
    max-width: 800px;
    margin: 0 auto;
}

.main-search-bar {
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 20px 24px;
    font-size: 16px;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    outline: none;
    transition: all 0.2s;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.search-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1), 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.search-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    justify-content: center;
}

.search-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.search-btn.primary {
    background: #2563eb;
    color: white;
}

.search-btn.primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.search-btn.secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.search-btn.secondary:hover {
    background: #e5e7eb;
}

/* Advanced Search */
.advanced-toggle {
    text-align: center;
    margin-bottom: 32px;
}

.toggle-btn {
    background: none;
    border: none;
    color: #2563eb;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 auto;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.toggle-btn:hover {
    background: #f0f9ff;
}

.advanced-search {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 32px;
    display: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.advanced-search.open {
    display: block;
}

.advanced-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Field sizing based on expected content length */
.form-group.col-1 { grid-column: span 1; }
.form-group.col-2 { grid-column: span 2; }
.form-group.col-3 { grid-column: span 3; }
.form-group.col-4 { grid-column: span 4; }
.form-group.col-6 { grid-column: span 6; }
.form-group.col-8 { grid-column: span 8; }
.form-group.col-12 { grid-column: span 12; }

.form-label {
    font-weight: 600;
    color: #374151;
    font-size: 13px;
}

.form-input {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input.compact {
    padding: 8px 10px;
    font-size: 13px;
}

textarea.form-input {
    resize: vertical;
    min-height: 70px;
}

/* Taxonomy Keywords Field with Expand/Collapse */
.taxonomy-keywords-group {
    position: relative;
}

.keywords-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.keywords-input-container .form-input {
    flex: 1;
    padding-right: 40px;
}

.expand-toggle {
    position: absolute;
    right: 12px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.expand-toggle:hover {
    background: #e5e7eb;
    color: #2563eb;
    border-color: #2563eb;
    transform: scale(1.05);
}

/* Autocomplete dropdown */
.keywords-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 40px;
    background: white;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}


/* Right-aligned keyword dropdown styling */
.keyword-option-layout {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 12px;
}

.keyword-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0; /* Prevent shrinking */
    min-width: 0; /* Allow text truncation if needed */
}

.keyword-path {
    font-size: 10px;
    color: #9ca3af; /* Light grey, low contrast */
    font-weight: 400;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1; /* Allow path to shrink first */
    max-width: 50%; /* Limit path width to preserve space */
}


.keywords-dropdown.show {
    display: block;
}

.keywords-dropdown-option {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.keywords-dropdown-option:last-child {
    border-bottom: none;
}

.keywords-dropdown-option:hover,
.keywords-dropdown-option.highlighted {
    background-color: #f8fafc;
}


/*
*/
/* Update the keyword dropdown option layout */
.keyword-option-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 12px;
}

.keyword-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-width: 0;
}

.keyword-label {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.keyword-hierarchy {
    font-size: 10px;
    color: #9ca3af; /* Light grey, low contrast */
    font-weight: 400;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1; /* Allow path to shrink first */
    max-width: 50%; /* Limit path width to preserve space */
}


/* Hide path on very small screens or when space is constrained */
@media (max-width: 768px) {
    .keyword-hierarchy {
        display: none;
    }
}
/*
*/
.option-category {
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
}

.option-path {
    font-size: 10px;
    color: #9ca3af;
    margin-left: 12px;
    flex-shrink: 0;
    max-width: 40%;
    text-align: right;
    line-height: 1.2;
}

.keyword-branch-indicator {
    display: none;
}

/* Selected keywords display */
.selected-keywords {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 24px;
}

.selected-keyword {
    background: #eff6ff;
    color: #2563eb;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #dbeafe;
}

.selected-keyword .remove-keyword {
    cursor: pointer;
    color: #6b7280;
    font-weight: bold;
    font-size: 14px;
    line-height: 1;
}

.selected-keyword .remove-keyword:hover {
    color: #dc2626;
}


/* Taxonomy Pills Section */
.taxonomy-pills-section {
    margin-top: 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    display: none;
}

.taxonomy-pills-section.expanded {
    display: block;
}

.pills-header {
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pills-title {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.pills-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #6b7280;
}

.pills-container {
    padding: 20px;
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}

.pill {
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    white-space: nowrap;
    background: #f8fafc;
    color: #374151;
}

.pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.pill.selected {
    border-color: #1d4ed8;
    box-shadow: 0 2px 8px rgba(29, 78, 216, 0.3);
}

.pill-checkmark {
    font-size: 12px;
    display: none;
}

.pill.selected .pill-checkmark {
    display: inline;
}

/* Searchable Select Component */
.searchable-select {
    position: relative;
}

.searchable-select-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    font-family: inherit;
}

.searchable-select-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.searchable-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.searchable-select-dropdown.show {
    display: block;
}

.searchable-select-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f3f4f6;
}

.searchable-select-option:last-child {
    border-bottom: none;
}

.searchable-select-option:hover {
    background: #f9fafb;
}

.searchable-select-option.selected {
    background: #eff6ff;
    color: #2563eb;
}

.searchable-select-option.highlighted {
    background: #f0f9ff;
}

/* Loading State */
.loading {
    display: none;
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

.loading.show {
    display: block;
}

.loading p {
    transition: opacity 0.3s ease-in-out;
}

.spinner {
    border: 2px solid #f3f4f6;
    border-top: 2px solid #2563eb;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Results Section */
.results-section {
    display: none;
    margin-top: 40px;
}

.results-section.show {
    display: block;
}

.results-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 32px;
}

/* Statistics Sidebar */
.stats-sidebar {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    font-size: 13px;
    /* Removed: position: sticky, top, max-height, overflow-y */
}

/* Scrollbar styling for sidebar */
.stats-sidebar::-webkit-scrollbar {
    width: 6px;
}

.stats-sidebar::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.stats-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.stats-sidebar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.stats-title {
    font-weight: 700;
    color: #111827;
    margin-bottom: 12px;
    font-size: 15px;
}

.stat-item {
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

.stat-item:last-child {
    border-bottom: none;
}

/* Compact two-column layout for basic stats */
.stat-item.compact-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 0;
}

.stat-item.compact-row > div {
    flex: 1;
}

.stat-label {
    display: block;
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.stat-value {
    font-weight: 600;
    color: #111827;
    font-size: 15px;
}

/* Statistics Pills */
.stat-pill-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 4px 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 11px;
    gap: 6px;
    min-height: 26px;
}

.stat-pill-label {
    flex: 1;
    color: #475569;
    font-weight: 500;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.3;
}

.stat-pill-count {
    background: #2563eb;
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 10px;
    flex-shrink: 0;
    min-width: 20px;
    text-align: center;
}

/* Outcome-specific pill colors */
.stat-pill-item.outcome-contribuente .stat-pill-count {
    background: #1e40af;
}

.stat-pill-item.outcome-ufficio .stat-pill-count {
    background: #c2410c;
}

.stat-pill-item.reference-pill .stat-pill-count {
    background: #059669;
}

/* Results List */
.result-item {
    border-bottom: 1px solid #f3f4f6;
    transition: all 0.3s ease;
    cursor: pointer;
    overflow: hidden;
}

.result-item:hover {
    background: #f9fafb;
}

.result-item.expanded {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin: 8px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.result-item:last-child {
    border-bottom: none;
}

/* Result Header */
.result-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    cursor: pointer;
}

.result-main {
    flex: 1;
    min-width: 0; /* Allow flex shrinking */
}

.result-title {
    font-weight: 600;
    color: #111827;
    margin-bottom: 8px;
    font-size: 16px;
    line-height: 1.4;
}

.result-summary {
    color: #4b5563;
    margin-bottom: 12px;
    line-height: 1.5;
}

/* Expand Indicator */
.expand-indicator {
    margin-left: 16px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.expand-arrow {
    font-size: 14px;
    color: #6b7280;
    transition: transform 0.2s ease, color 0.2s ease;
    display: inline-block;
}

.result-item:hover .expand-arrow {
    color: #2563eb;
}

/* Expanded Content */
.result-expanded {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: #fafafa;
    border-top: 1px solid #e5e7eb;
}

.result-expanded.show {
    max-height: 2000px; /* Large enough for most content */
    transition: max-height 0.4s ease-in;
}

.expanded-content {
    padding: 24px;
}

/* Detail Sections */
.detail-section {
    margin-bottom: 24px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Detail Lists */
.detail-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.detail-list li {
    padding: 6px 0;
    color: #4b5563;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
}

.detail-list li:last-child {
    border-bottom: none;
}

/* Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

.detail-item {
    background: white;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    color: #4b5563;
    border: 1px solid #e5e7eb;
}

.detail-item strong {
    color: #111827;
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Keywords Line Layout */
.keywords-line {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.keywords-label {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    flex-shrink: 0;
    padding-top: 6px; /* Align with pills */
}

/* Detail Pills */
.detail-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.detail-pill {
    padding: 6px 12px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #d1d5db;
    background-color: #f9fafb;
    color: #374151;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

/* Specific pill types keep their colors */
.date-pill {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

.info-pill {
    background-color: #f3e8ff;
    color: #7c2d12;
    border-color: #e9d5ff;
}

.value-pill {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

/* Detail Text */
.detail-text {
    background: white;
    padding: 16px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    color: #4b5563;
    line-height: 1.6;
    font-size: 14px;
}

/* Result Pills Enhancement */
.result-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.result-pill {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

/* Case reference pill - neutral blue */
.result-pill.case-reference {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

/* Outcome pills with distinct colors */
.result-pill.outcome-contribuente {
    background-color: #dbeafe;
    color: #1e40af;
    border-color: #93c5fd;
}

.result-pill.outcome-ufficio {
    background-color: #fed7aa;
    color: #c2410c;
    border-color: #fdba74;
}

.result-pill.outcome-unknown {
    background-color: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}

/* Responsive Design */
@media (max-width: 768px) {
    .result-header {
        padding: 16px;
    }
    
    .expanded-content {
        padding: 16px;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .expand-indicator {
        margin-left: 8px;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .search-hero h1 {
        font-size: 32px;
    }
    
    .search-hero p {
        font-size: 16px;
    }
    
    .results-layout {
        grid-template-columns: 1fr;
    }
    
    .stats-sidebar {
        position: static;
    }
    
    .advanced-grid {
        grid-template-columns: 1fr;
    }
    
    .container {
        padding: 0 16px;
    }

    .pills-container {
        max-height: 250px;
    }
}

/* Legal References Styling */

/* Reference pills without motivazione - packed together */
.reference-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.reference-pill {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

.reference-with-motivation {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.reference-motivation {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.5;
    padding-left: 8px;
    border-left: 3px solid #e5e7eb;
    font-style: italic;
}

/* References with motivazione - pill + explanation layout */
.motivated-references {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reference-with-motivation {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.reference-motivation {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.5;
    padding-left: 8px;
    border-left: 3px solid #e5e7eb;
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .reference-pills {
        gap: 4px;
    }
    
    .reference-with-motivation {
        padding: 10px;
    }
    
    .reference-motivation {
        font-size: 12px;
        padding-left: 6px;
        border-left-width: 2px;
    }
}

.facts-list {
    padding-left: 16px;
    margin: 0;
}

.facts-list li {
    list-style-type: disc;
    margin-bottom: 2px;
    line-height: 1.2;
    padding-left: 4px;
}

/* Statistics Pills */
.stat-pills-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
    padding-right: 2px;
}

.stat-pill-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    gap: 8px;
}

.stat-pill-label {
    flex: 1;
    color: #475569;
    font-weight: 500;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.stat-pill-count {
    background: #2563eb;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 11px;
    flex-shrink: 0;
}

/* Outcome-specific pill colors */
.stat-pill-item.outcome-contribuente .stat-pill-count {
    background: #1e40af;
}

.stat-pill-item.outcome-ufficio .stat-pill-count {
    background: #FF8D59;
}

.stat-pill-item.reference-pill .stat-pill-count {
    background: #059669;
}

/* Tooltip styles */
.form-group {
    position: relative;
}

.tooltip {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: #1f2937;
    color: white;
    font-size: 12px;
    line-height: 1.4;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    white-space: normal;
    max-width: 300px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 20px;
    border: 6px solid transparent;
    border-top-color: #1f2937;
}

.form-group:hover .tooltip {
    opacity: 1;
    visibility: visible;
    transition-delay: 0.8s; /* Delay before showing */
}

/* Alternative: tooltip on the right side */
.tooltip.tooltip-right {
    left: auto;
    right: 0;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    margin-bottom: 0;
}

.tooltip.tooltip-right::after {
    top: 50%;
    left: -6px;
    transform: translateY(-50%);
    border-top-color: transparent;
    border-right-color: #1f2937;
}

/* Compact Timeline for dates - labels above, dates below */
.timeline-container {
    padding: 0;
    margin-bottom: 12px;
    margin-top: -8px; /* Pull closer to previous section */
}

.timeline {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    min-height: 50px;
}

/* The connecting line */
.timeline::before {
    content: '';
    position: absolute;
    top: 50%; /* Center vertically */
    left: 0;
    right: 0;
    height: 1px;
    background: #e5e7eb;
    z-index: 0;
    transform: translateY(-50%);
}

.timeline-item {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.timeline-item:not(:last-child) {
    margin-right: 16px;
}

/* Labels go ABOVE the dot */
.timeline-label {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: center;
    margin-bottom: 6px;
}

.timeline-item.has-date .timeline-label {
    color: #374151;
}

/* The dot/circle - in the middle on the line */
.timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: white;
    border: 2px solid #d1d5db;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.timeline-item.has-date .timeline-dot {
    background: #2563eb;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

/* Date value goes BELOW the dot */
.timeline-date {
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    text-align: center;
    line-height: 1.2;
    margin-top: 6px;
}

.timeline-item.has-date .timeline-date {
    color: #1f2937;
}

/* Empty state for missing dates */
.timeline-date.empty {
    font-size: 11px;
    color: #d1d5db;
    font-style: italic;
}

/* Other info pills container (for valore_controversia etc) */
.other-info-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .timeline {
        flex-direction: column;
        align-items: flex-start;
        padding: 0;
        min-height: auto;
    }
    
    .timeline::before {
        display: none;
    }
    
    .timeline-item {
        width: 100%;
        flex-direction: row;
        align-items: center;
        margin-bottom: 10px;
        margin-right: 0 !important;
    }
    
    .timeline-dot {
        margin-right: 10px;
        flex-shrink: 0;
    }
    
    .timeline-item > div {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .timeline-label {
        margin-bottom: 2px;
        text-align: left;
    }
    
    .timeline-date {
        margin-top: 0;
        text-align: left;
    }
}


/* Date table styling */
.date-table {
    display: table;
    width: 100%;
    border-collapse: collapse;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.date-table-header,
.date-table-row {
    display: table-row;
}

.date-table-cell {
    display: table-cell;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    vertical-align: middle;
}

/* Header cells */
.date-table-cell.header-col {
    background: #f9fafb;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
    text-align: center;
}

.date-table-cell.header-row {
    background: #f9fafb;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
    text-align: left;
    width: 100px;
}

.date-table-cell.header-corner {
    background: #f9fafb;
    width: 100px;
}

/* Input cells */
.date-table-cell .date-input {
    width: 100%;
    margin: 0;
    border: none;
    padding: 6px 8px;
    background: transparent;
}

.date-table-cell .date-input:focus {
    outline: none;
    box-shadow: none;
    background: #f0f9ff;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .date-table {
        display: block;
    }
    
    .date-table-header,
    .date-table-row {
        display: block;
    }
    
    .date-table-header {
        display: none; /* Hide header on mobile */
    }
    
    .date-table-row {
        margin-bottom: 16px;
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 16px;
    }
    
    .date-table-row:last-child {
        border-bottom: none;
        padding-bottom: 0;
        margin-bottom: 0;
    }
    
    .date-table-cell {
        display: block;
        padding: 8px 0;
        border: none;
    }
    
    .date-table-cell.header-row {
        font-weight: 700;
        font-size: 14px;
        margin-bottom: 8px;
        background: transparent;
    }
    
    .date-table-cell .date-input {
        border: 1px solid #d1d5db;
        border-radius: 6px;
        padding: 8px 10px;
        margin-bottom: 8px;
    }
    
    .date-table-cell .date-input::before {
        content: attr(id);
        display: block;
        font-size: 12px;
        color: #6b7280;
        margin-bottom: 4px;
    }
}

/* Fix: Make footer always sit at bottom */

/* Body becomes a flex container */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Main content grows to fill space, pushing footer down */
.search-hero {
    flex: 1 0 auto;
}

/* Simple Footer stays at bottom */
.simple-footer {
    flex-shrink: 0;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    padding: 24px 0;
    margin-top: auto;
}

.footer-links {
    text-align: center;
    font-size: 14px;
}

.footer-links a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.footer-links .separator {
    color: #d1d5db;
    margin: 0 12px;
}

.footer-links .copyright {
    color: #6b7280;
    font-size: 13px;
}

/* Responsive */
@media (max-width: 480px) {
    .footer-links {
        font-size: 13px;
    }
    
    .footer-links .separator {
        margin: 0 8px;
    }
}