:root {
    --primary-color: #3b82f6;
    --secondary-color: #8b5cf6;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-color: #1f2937;
    --border-color: #e5e7eb;
    --sidebar-width: 320px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}
/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-color);
}

.main-container {
    display: flex;
    padding: 2rem;
    gap: 2rem;
    max-width: 1536px;
    width: 100%;
    margin: 0 auto;
}

.content-area {
    flex: 1;
    min-width: 0;
}

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

#resultsSummary {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    text-align: center;
    background-color: #dbeafe; 
    color: #1d4ed8;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 1.5rem;
    height: calc(100vh - 120px); 
    position: sticky;
    top: 80px;
    flex-shrink: 0;
}

.sidebar form {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.sidebar-filters-container {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    padding-right: 15px;
    margin-right: -15px;
}

.reset-btn {
    background: none;
    border: 1px solid #d1d5db;
    color: #4b5563;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.reset-btn:hover {
    background-color: #f9fafb;
    border-color: #9ca3af;
    color: #1f2937;
}

.search-container {
    margin-bottom: 2rem;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.filter-section {
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.filter-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.sidebar-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0 0 1.5rem 0;
}

.filter-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.filter-options-container {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
}

.filter-option {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
}
.filter-option:last-child {
    margin-bottom: 0;
}

.filter-option label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: #374151;
}
.filter-option input {
    margin-right: 0.75rem;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.tools-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}
@media (min-width: 1200px) {
    .tools-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* --- UPDATED: Simplified Tool Card --- */
.tool-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}
.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.tool-card h2 {
    font-size: 1.25rem; /* Smaller title for scannability */
    margin-bottom: 0.5rem;
    color: var(--text-color);
}
.tool-summary {
    color: #4b5563;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    flex-grow: 1; /* Pushes tags to the bottom */
}

.tool-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}
.tag {
    background-color: #e0e0e0;
    color: #333;
    padding: 2px 8px;
    border-radius: 12px;
    margin: 2px;
    font-size: 0.75em;
    display: inline-block;
}

/* --- NEW: Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}
.modal-header h2 {
    font-size: 1.75rem;
    color: var(--text-color);
    margin: 0;
}
.modal-close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: #9ca3af;
    transition: color 0.2s;
}
.modal-close-btn:hover {
    color: var(--text-color);
}

.modal-section {
    margin-bottom: 1.5rem;
}
.modal-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}
.modal-section p {
    font-size: 0.95rem;
    color: #4b5563;
}
.modal-section a {
    color: var(--primary-color);
    text-decoration: none;
}
.modal-section a:hover {
    text-decoration: underline;
}

.modal-links-grid, .modal-details-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
@media (min-width: 640px) {
    .modal-links-grid, .modal-details-grid {
        grid-template-columns: 1fr 1fr;
    }
}
.modal-links-grid div, .modal-details-grid div {
    font-size: 0.9rem;
}
.modal-links-grid strong, .modal-details-grid strong {
    font-weight: 600;
    display: block;
    color: #374151;
    margin-bottom: 0.25rem;
}

.modal-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
    text-align: center;
}
.metric h4 {
    font-size: 0.9rem;
    color: #6b7280;
    font-weight: 500;
    margin-bottom: 0.25rem;
}
.metric p {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
}

.no-results, .loading {
    text-align: center;
    padding: 3rem;
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    grid-column: 1 / -1;
}

@media (max-width: 1024px) {
    .main-container {
        flex-direction: column-reverse;
        padding: 1rem;
    }
    .sidebar {
        width: 100%;
        position: static;
        height: auto;
        max-height: 50vh;
        overflow-y: auto;
    }
}