/* CSS Variables */
:root {
    --color-primary: #1e40af;
    --color-secondary: #64748b;
    --color-success: #16a34a;
    --color-danger: #dc2626;
    --color-warning: #ea580c;
    --color-new: #d1fae5;
    --color-new-border: #16a34a;
    --color-removed: #fee2e2;
    --color-removed-border: #dc2626;
    --color-changed: #fef3c7;
    --color-changed-border: #ea580c;
    --color-bg: #f8fafc;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Navbar */
.navbar {
    background-color: var(--color-primary);
    color: white;
    padding: 1rem 0;
    margin-bottom: 2rem;
}

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

.nav-brand h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s;
}

.nav-links a:hover {
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

.nav-links a.active {
    border-bottom-color: #fbbf24;
    font-weight: 600;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--color-danger);
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--color-success);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-size: 1rem;
    vertical-align: middle;
    line-height: 1.5;
    box-sizing: border-box;
}

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

.btn-primary:hover {
    background-color: #1e3a8a;
}

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

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

/* Button element reset - ensure buttons and anchors align perfectly */
button.btn {
    font-family: inherit;
    margin: 0;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group small {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 0 0.25rem 0;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-item input[type="checkbox"] {
    width: auto;
    height: 18px;
    cursor: pointer;
}

.checkbox-item label {
    margin: 0;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

/* Log Viewer */
.log-viewer-container {
    margin: 2rem 0;
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.log-viewer-container h3 {
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-viewer {
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: #1e293b;
    max-height: 400px;
    overflow-y: auto;
}

.log-content {
    margin: 0;
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #e2e8f0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.table thead {
    background-color: #f1f5f9;
}

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

.table tbody tr:hover {
    background-color: #f8fafc;
}

.table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.table th.sortable:hover {
    background-color: #e2e8f0;
}

.table th.sortable .sort-icon {
    margin-left: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

/* Dashboard */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

/* Filters Section */
.filters-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.filter-row {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.filter-item {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
}

.filter-item label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    height: 1.25rem;
}

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

.filter-item select[multiple] {
    min-height: 120px;
    overflow-y: auto;
}

.filter-item select[multiple] option {
    padding: 0.25rem 0.5rem;
}

.filter-item small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    height: 1rem;
}

/* Keep search field aligned with top of street filter */
.filter-item input[type="text"] {
    margin-top: 0;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 1.75rem;
}

.filter-actions .btn {
    white-space: nowrap;
}

/* Preview Result */
.job-status {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 2rem;
    background: white;
}

.status-queued {
    border-left: 4px solid #fbbf24;
}

.status-running {
    border-left: 4px solid #3b82f6;
}

.status-completed {
    border-left: 4px solid var(--color-success);
}

.status-failed {
    border-left: 4px solid var(--color-danger);
}

.error-message {
    color: var(--color-danger);
    margin-top: 0.5rem;
    font-weight: 600;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

.card-number {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.card-label {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.card-new {
    border-left: 4px solid var(--color-new-border);
}

.card-removed {
    border-left: 4px solid var(--color-removed-border);
}

.card-changed {
    border-left: 4px solid var(--color-changed-border);
}

.card-unchanged {
    border-left: 4px solid var(--color-secondary);
}

/* Changes */
.changes-section {
    margin-bottom: 2rem;
}

.section-title {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.change-item {
    background: white;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.change-item label {
    display: block;
    cursor: pointer;
}

.change-new {
    background-color: var(--color-new);
    border-left: 4px solid var(--color-new-border);
}

.change-removed {
    background-color: var(--color-removed);
    border-left: 4px solid var(--color-removed-border);
}

.change-changed {
    background-color: var(--color-changed);
    border-left: 4px solid var(--color-changed-border);
}

.people-list {
    margin-top: 0.5rem;
    color: var(--color-text-muted);
}

.change-details {
    margin-top: 0.5rem;
    padding-left: 1.5rem;
}

.diff-section {
    margin: 0.25rem 0;
}

/* Actions */
.actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Utilities */
.text-muted {
    color: var(--color-text-muted);
}

.text-success {
    color: var(--color-success);
}

.spinner {
    text-align: center;
    padding: 2rem;
}

/* Progress Bar */
.progress-container {
    padding: 2rem 0;
}

.progress-bar-container {
    width: 100%;
    height: 40px;
    background-color: #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    margin: 1.5rem 0;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), #3b82f6);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
}

.progress-text {
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

#progress-message {
    text-align: center;
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.btn-danger {
    background-color: var(--color-danger);
    color: white;
}

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

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

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-content.modal-small {
    max-width: 400px;
}

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

.modal .close {
    color: var(--color-text-muted);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.modal .close:hover,
.modal .close:focus {
    color: var(--color-text);
}

.residents-list {
    margin: 1.5rem 0;
}

.resident-item {
    padding: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.resident-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.resident-item label {
    cursor: pointer;
    font-weight: 500;
    margin: 0;
}

.resident-name-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
}

.resident-name-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Edit Residents Button */
.btn-edit-residents {
    background: transparent;
    border: 1px solid #d1d5db;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--color-text);
    transition: all 0.2s;
}

.btn-edit-residents:hover {
    background-color: #f1f5f9;
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-edit-residents .edit-icon {
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

/* Delete Household Button */
.btn-delete-household {
    background: transparent;
    border: none;
    color: var(--color-danger);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-delete-household:hover {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Residents List Grid */
.residents-list-header,
.resident-item {
    display: grid;
    grid-template-columns: 50px 1fr 1fr 1fr;
    gap: 0.75rem;
    align-items: center;
}

.residents-list-header {
    font-weight: 600;
    padding: 0 0.75rem 0.5rem 0.75rem;
    border-bottom: 2px solid #e2e8f0;
}

.resident-item {
    padding: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

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

.resident-item input[type="text"],
.resident-item input[type="email"] {
    width: 100%;
}

/* Membership Styles */
.residents-compact-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}

.resident-tag {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 100px;
    padding: 2px 10px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #475569;
}

.resident-tag.member {
    background: #d1fae5;
    border-color: #10b981;
    color: #065f46;
    font-weight: 500;
}

.member-badge {
    font-size: 0.8rem;
}

.modal-resident-item {
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 0;
}

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

.membership-controls {
    display: flex;
    gap: 1.5rem;
    margin-top: 10px;
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    margin: 0;
}

.membership-status-badge {
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-member { background: #d1fae5; color: #065f46; }
.badge-none { background: #f1f5f9; color: #64748b; }

/* Modal refactoring styles */
.resident-tag.clickable:hover {
    background-color: #e2e8f0;
    border-color: #cbd5e1;
    transform: translateY(-1px);
    transition: all 0.2s;
}

.resident-tag.clickable.member:hover {
    background-color: #a7f3d0;
    border-color: #059669;
}

.readonly-input {
    background-color: #f1f5f9;
    cursor: not-allowed;
    color: #64748b;
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 1rem;
}