/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    color: #1e40af;
    font-size: 1.5rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background-color: #3b82f6;
    color: white;
}

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

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

.btn-outline {
    background-color: transparent;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-outline:hover {
    background-color: #f9fafb;
}

.btn-danger {
    background-color: #dc2626;
    color: white;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

/* Layout */
.main {
    padding: 2rem 0;
}

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

/* Sidebar */
.sidebar {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
    height: fit-content;
    position: sticky;
    top: 100px;
}

.filter-section h3 {
    margin-bottom: 1rem;
    color: #1e40af;
    font-size: 1.125rem;
}

.filter-group {
    margin-bottom: 1.5rem;
}

.filter-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #374151;
}

.filter-group input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.checkbox-group {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    padding: 0.5rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    padding: 0.25rem 0;
    font-size: 0.875rem;
}

.checkbox-item input[type="checkbox"] {
    margin-right: 0.5rem;
}

.checkbox-item .count {
    color: #6b7280;
    font-size: 0.75rem;
    margin-left: auto;
}

/* Content */
.content {
    background: white;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
}

.results-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 500;
    color: #374151;
}

.table-container {
    overflow-x: auto;
}

.lenders-table {
    width: 100%;
    border-collapse: collapse;
}

.lenders-table th,
.lenders-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.lenders-table th {
    background-color: #f9fafb;
    font-weight: 600;
    color: #374151;
    position: sticky;
    top: 0;
}

.lenders-table tr:hover {
    background-color: #f9fafb;
}

.lenders-table .actions {
    display: flex;
    gap: 0.5rem;
}

.lenders-table .actions button {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 0.5rem;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h2 {
    color: #1e40af;
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
}

/* Form */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

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

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #374151;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    padding: 0.75rem;
}

.checkbox-grid .checkbox-item {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
}

.property-types-selection {
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    max-height: 300px;
    overflow-y: auto;
}

.property-category {
    border-bottom: 1px solid #e5e7eb;
}

.property-category:last-child {
    border-bottom: none;
}

.category-header {
    background-color: #f9fafb;
    padding: 0.75rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-content {
    padding: 0.75rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

.category-content.collapsed {
    display: none;
}

/* Loading and Empty States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: #6b7280;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #6b7280;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Tags */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.tag {
    background-color: #e0e7ff;
    color: #3730a3;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: static;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .header .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-actions {
        width: 100%;
        justify-content: center;
    }
}

/* Utility Classes */
.text-muted {
    color: #6b7280;
}

.text-small {
    font-size: 0.75rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.hidden {
    display: none;
}

/* Make the filters column stick under the header (no structural change) */
.sidebar-sticky {
  position: sticky;
  top: 88px;              /* adjust if your header height is different */
  align-self: start;      /* ensure the sticky sidebar doesn't stretch */
}

/* Give the filters content its own vertical scrollbar */
#lenderFiltersScroll.sidebar-scroll {
  max-height: calc(100vh - 120px);  /* viewport minus header/margins; tweak as needed */
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;               /* space so content doesn't hide behind scrollbar */
  -webkit-overflow-scrolling: touch;
}

/* Optional: if your layout uses grid, prevent sidebar from shrinking oddly */
.layout {
  /* if you already define columns elsewhere, keep it; otherwise this is safe */
  /* display: grid; grid-template-columns: 300px 1fr; gap: 16px; */
  align-items: start;
}
