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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.header {
    background: #1a1a2e;
    color: white;
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 600;
}

.nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    color: white;
    border-bottom-color: #4CAF50;
}

.user-info {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

.logout-form {
    display: inline;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
}

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

.btn-secondary:hover {
    background: #555;
}

.btn-logout {
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-small {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    background: #2196F3;
    color: white;
}

.btn-small:hover {
    background: #1976D2;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Main Content */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Login Page */
.login-page {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.login-box {
    background: white;
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.login-title {
    text-align: center;
    color: #1a1a2e;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    text-align: center;
    color: #666;
    font-weight: 400;
    font-size: 1rem;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #4CAF50;
}

.login-form .btn {
    margin-top: 1rem;
    padding: 0.75rem;
    font-size: 1rem;
}

.login-footer {
    margin-top: 2rem;
    text-align: center;
}

.security-note {
    color: #999;
    font-size: 0.8rem;
}

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

.alert-error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

/* Stats Section */
.stats-section {
    margin-bottom: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1a1a2e;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

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

.counties-section h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.75rem;
}

.county-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.county-tag {
    background: #e3f2fd;
    color: #1565c0;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
}

/* Controls Section */
.controls-section {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.search-input:focus {
    outline: none;
    border-color: #4CAF50;
}

/* Results Info */
.results-info {
    margin-bottom: 1rem;
    color: #666;
}

/* Table */
.table-section {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

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

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

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

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.data-table tr:hover {
    background: #f5f5f5;
}

.address-cell {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-message {
    text-align: center;
    color: #999;
    padding: 2rem !important;
}

/* Pagination */
.pagination-section {
    margin-top: 1.5rem;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.page-link {
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s;
}

.page-link:hover {
    background: #f5f5f5;
    border-color: #4CAF50;
}

.page-info {
    padding: 0.5rem 1rem;
    color: #666;
}

/* Record Detail */
.record-section {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.record-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.record-header h2 {
    margin: 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-item label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.detail-item span {
    font-size: 1rem;
    color: #333;
}

.detail-item .highlight {
    color: #4CAF50;
    font-weight: 600;
}

.full-text-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #eee;
}

.full-text-section h3 {
    margin-bottom: 1rem;
    color: #333;
}

.full-text-content {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 4px;
    max-height: 500px;
    overflow-y: auto;
}

.full-text-content pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
}

/* Exports Page */
.exports-section h2 {
    margin-bottom: 0.5rem;
}

.section-description {
    color: #666;
    margin-bottom: 1.5rem;
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.file-icon {
    font-size: 1.5rem;
}

.file-name {
    font-weight: 500;
}

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

/* Error Page */
.error-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.error-box {
    text-align: center;
    background: white;
    padding: 3rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.error-box h1 {
    color: #c62828;
    margin-bottom: 1rem;
}

.error-message {
    color: #666;
    margin-bottom: 2rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: #999;
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .main-content {
        padding: 1rem;
    }

    .controls-section {
        flex-direction: column;
    }

    .search-form {
        flex-direction: column;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
}

/* ==================== JOBS PAGE STYLES ==================== */

/* Start Job Section */
.start-job-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.start-job-section h2 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.job-form .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.job-form .form-row.checkboxes {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.job-form .form-group {
    margin-bottom: 0;
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: #888;
    margin-top: 0.25rem;
}

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

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

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

/* Alert Warning */
.alert-warning {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

/* Jobs List Section */
.jobs-list-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.jobs-list-section h2 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

/* Jobs Table */
.jobs-table .job-row.running {
    background: #e8f5e9;
}

.jobs-table .job-row.failed {
    background: #ffebee;
}

.job-id-link {
    font-family: monospace;
    color: #1565c0;
    text-decoration: none;
}

.job-id-link:hover {
    text-decoration: underline;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.large {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.status-running {
    background: #c8e6c9;
    color: #2e7d32;
}

.status-completed {
    background: #e3f2fd;
    color: #1565c0;
}

.status-stopped {
    background: #fff3e0;
    color: #e65100;
}

.status-failed {
    background: #ffebee;
    color: #c62828;
}

.status-pending {
    background: #f5f5f5;
    color: #666;
}

/* Stat colors */
.stat-value.running {
    color: #2e7d32;
}

.stat-value.failed {
    color: #c62828;
}

/* Actions Cell */
.actions-cell {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.inline-form {
    display: inline;
}

/* Danger Button */
.btn-danger {
    background: #e53935;
    color: white;
}

.btn-danger:hover {
    background: #c62828;
}

/* Auto-refresh note */
.auto-refresh-note {
    text-align: center;
    color: #888;
    font-size: 0.85rem;
    margin-top: 1rem;
}

/* ==================== JOB DETAIL PAGE ==================== */

.job-detail-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.job-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.job-header h2 {
    margin: 0;
    flex: 1;
}

/* Job Info Grid */
.job-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.info-card {
    background: #f8f9fa;
    padding: 1.25rem;
    border-radius: 8px;
}

.info-card h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

.info-list dt {
    color: #666;
    font-size: 0.9rem;
}

.info-list dd {
    margin: 0;
    font-weight: 500;
}

.info-list dd.highlight {
    color: #4CAF50;
    font-size: 1.25rem;
}

.info-list dd.error {
    color: #c62828;
}

/* Progress Bar */
.progress-bar {
    display: inline-block;
    width: 100px;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.progress-fill {
    height: 100%;
    background: #4CAF50;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Job Actions */
.job-actions {
    margin-bottom: 2rem;
}

/* Output Section */
.output-section {
    margin-top: 2rem;
}

.output-section h3 {
    margin-bottom: 0.5rem;
}

.output-log {
    background: #1a1a2e;
    color: #e0e0e0;
    padding: 1rem;
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.output-log pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.empty-output {
    color: #888;
    font-style: italic;
}

/* Error Section */
.error-section {
    margin-top: 2rem;
}

.error-content {
    background: #ffebee;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #ef9a9a;
}

.error-content pre {
    margin: 0;
    color: #c62828;
    white-space: pre-wrap;
}

/* ==================== SETTINGS PAGE STYLES ==================== */

.settings-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.settings-section h3 {
    margin-bottom: 0.5rem;
    color: #1a1a2e;
}

.settings-section .section-description {
    margin-bottom: 1.5rem;
}

/* Recipients List */
.add-recipient-form {
    margin-bottom: 1.5rem;
}

.form-row.inline {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.form-row.inline .form-input {
    flex: 1;
    min-width: 250px;
}

.recipients-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recipient-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.recipient-email {
    font-family: monospace;
}

.empty-state.small {
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 4px;
}

/* SMTP Form */
.smtp-form .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Info Section */
.info-section {
    background: #e3f2fd;
    border: 1px solid #90caf9;
}

.info-section h3 {
    color: #1565c0;
}

.info-section ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.info-section li {
    margin-bottom: 0.5rem;
}

.info-section ul {
    margin-top: 0.5rem;
    padding-left: 1.25rem;
}

.info-section code {
    background: white;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

/* ==================== EXPORTS PAGE ENHANCEMENTS ==================== */

.file-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.file-actions .inline-form {
    display: inline-block;
}

/* ==================== EMAIL STATUS STYLES ==================== */

.email-status-section {
    margin-top: 2rem;
}

.email-status-section h3 {
    margin-bottom: 0.75rem;
}

.email-success,
.email-error,
.email-pending,
.email-skipped {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 500;
}

.email-icon {
    font-size: 1.25rem;
}

.email-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.email-error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.email-pending {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #90caf9;
}

.email-skipped {
    background: #f5f5f5;
    color: #666;
    border: 1px solid #e0e0e0;
}

/* ==================== USER MANAGEMENT STYLES ==================== */

.add-user-form .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.users-table {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.users-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.85rem;
    color: #666;
}

.user-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e0e0e0;
    align-items: center;
}

.user-row:hover {
    background: #f8f9fa;
}

.user-name {
    font-weight: 500;
}

.user-created {
    font-size: 0.85rem;
    color: #666;
}

.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-you {
    background: #e3f2fd;
    color: #1565c0;
}

.role-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.role-admin {
    background: #fff3e0;
    color: #e65100;
}

.role-readonly {
    background: #e8f5e9;
    color: #2e7d32;
}

.text-muted {
    color: #999;
}

/* Responsive user table */
@media (max-width: 768px) {
    .users-header {
        display: none;
    }

    .user-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .user-row > span:before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 0.5rem;
    }
}
