/* Dashboard Styles */
body {
    background-color: #f5f5f5;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Navigation */
.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
}

.navbar-brand {
    font-weight: 600;
}

#connection-status {
    font-size: 0.9rem;
}

#connection-status .fa-circle {
    font-size: 0.7rem;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

/* Stat Cards */
.bg-info {
    background-color: #0dcaf0 !important;
}

.bg-success {
    background-color: #198754 !important;
}

.bg-primary {
    background-color: #0d6efd !important;
}

.bg-warning {
    background-color: #ffc107 !important;
}

/* Tables */
.table {
    margin-bottom: 0;
}

.table th {
    border-top: none;
    font-weight: 600;
    color: #495057;
    background-color: #f8f9fa;
}

/* Status Badges */
.badge-status {
    font-size: 0.85rem;
    padding: 0.35em 0.65em;
}

.status-running {
    background-color: #0dcaf0;
    color: white;
}

/* Elapsed Time Display */
.elapsed-time {
    font-weight: bold;
    margin-left: 0.25rem;
    font-size: 0.9em;
}

/* Make running status badge wider to accommodate elapsed time */
.status-running.badge-status {
    min-width: 120px;
    text-align: center;
}

/* Status cell styling */
td.status-cell {
    white-space: nowrap;
}

.status-details {
    display: inline-block;
    margin-left: 5px;
    font-weight: normal;
}

.status-active {
    background-color: #198754;
    color: white;
}

.status-paused {
    background-color: #ffc107;
    color: #000;
}

.status-failed {
    background-color: #dc3545;
    color: white;
}

/* Action Buttons */
.btn-action {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    margin: 0 0.1rem;
}

/* Loading Spinner */
.spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

/* Tooltips */
.tooltip-inner {
    max-width: 300px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .card-body {
        padding: 1rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .btn-action {
        padding: 0.2rem 0.4rem;
        font-size: 0.8rem;
    }
}

/* DataTables customization */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-top: 1rem;
}

/* Modal customization */
.modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

/* Price formatting */
.price {
    font-weight: 600;
    color: #198754;
}

/* Distance formatting */
.distance {
    color: #6c757d;
    font-size: 0.875rem;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1080;
}

/* Real-time update indicator */
.update-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #198754;
    border-radius: 50%;
    margin-left: 5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(25, 135, 84, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(25, 135, 84, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(25, 135, 84, 0);
    }
}

/* Latest Runs Feature Styles */

/* Purple badge for proxy */
.bg-purple {
    background-color: #6f42c1 !important;
    color: white;
}

/* Animate running status spinner */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fa-spin {
    animation: spin 1s linear infinite;
}

/* Runs table styling */
#runs-table {
    font-size: 0.9rem;
}

#runs-table td {
    vertical-align: middle;
}

/* Mode badges styling */
#runs-table .badge {
    font-size: 0.8rem;
    font-weight: 500;
}

/* Responsive badges */
@media (max-width: 768px) {
    .badge {
        font-size: 0.75rem;
        padding: 0.25em 0.4em;
    }
}

/* Tooltip styling for proxy details */
#runs-table [data-bs-toggle="tooltip"] {
    cursor: help;
    text-decoration: underline dotted;
}

/* Duration styling */
#runs-table .text-muted {
    font-style: italic;
}

/* Column Width Optimization */

/* Text truncation for long content */
.text-truncate-custom {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tasks Table Column Widths */
#tasks-table th:nth-child(1), #tasks-table td:nth-child(1) { width: 25%; } /* Name */
#tasks-table th:nth-child(2), #tasks-table td:nth-child(2) { width: 10%; } /* Source */
#tasks-table th:nth-child(3), #tasks-table td:nth-child(3) { width: 10%; } /* Interval */
#tasks-table th:nth-child(4), #tasks-table td:nth-child(4) { width: 10%; } /* Status */
#tasks-table th:nth-child(5), #tasks-table td:nth-child(5) { width: 15%; } /* Last Run */
#tasks-table th:nth-child(6), #tasks-table td:nth-child(6) { width: 15%; } /* Next Run */
#tasks-table th:nth-child(7), #tasks-table td:nth-child(7) { width: 15%; } /* Actions */

/* Runs Table Column Widths */
#runs-table th:nth-child(1), #runs-table td:nth-child(1) { width: 20%; } /* Task */
#runs-table th:nth-child(2), #runs-table td:nth-child(2) { width: 14%; } /* Started */
#runs-table th:nth-child(3), #runs-table td:nth-child(3) { width: 7%; }  /* Duration */
#runs-table th:nth-child(4), #runs-table td:nth-child(4) { width: 8%; } /* Mode */
#runs-table th:nth-child(5), #runs-table td:nth-child(5) { width: 8%; } /* Connection */
#runs-table th:nth-child(6), #runs-table td:nth-child(6) { width: 7%; } /* Details */
#runs-table th:nth-child(7), #runs-table td:nth-child(7) { width: 5%; }  /* Scraped */
#runs-table th:nth-child(8), #runs-table td:nth-child(8) { width: 5%; }  /* Matches */
#runs-table th:nth-child(9), #runs-table td:nth-child(9) { width: 8%; } /* Status */
#runs-table th:nth-child(10), #runs-table td:nth-child(10) { width: 12%; } /* Actions */

/* Prevent button wrapping in runs table */
#runs-table td:last-child {
    white-space: nowrap;
}

#runs-table .btn-sm {
    margin-right: 2px !important;
}

/* Listings Table Column Widths */
#listings-table th:nth-child(1), #listings-table td:nth-child(1) { width: 5%; }   /* Details */
#listings-table th:nth-child(2), #listings-table td:nth-child(2) { width: 8%; }   /* Price */
#listings-table th:nth-child(3), #listings-table td:nth-child(3) { width: 32%; }  /* Title/Description */

/* Multiline Listing Display Styles */
.listing-view-toggle {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.listing-view-toggle .btn-group {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.listing-view-toggle .btn {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.listing-view-toggle .btn.active {
    background-color: #0d6efd;
    color: white;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Multiline Listing Card */
.listing-multiline {
    background: transparent;
    border: none;
}

.listing-multiline td {
    padding: 0 !important;
    border: none !important;
}

.listing-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin: 8px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.listing-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Listing Header */
.listing-header {
    padding: 12px 16px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.listing-header .price {
    font-size: 1.1rem;
    font-weight: 600;
    color: #198754;
    min-width: 80px;
}

.listing-header .title {
    flex: 1;
    font-weight: 500;
    color: #212529;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.listing-header .status-badge {
    margin-left: auto;
}

.listing-header .expand-icon {
    font-size: 0.875rem;
    color: #6c757d;
    transition: transform 0.2s ease;
    margin-left: 8px;
}

.listing-header.expanded .expand-icon {
    transform: rotate(180deg);
}

/* Listing Sections */
.listing-sections {
    display: none;
    background: white;
}

.listing-sections.show {
    display: block;
}

.listing-section {
    padding: 16px;
    border-bottom: 1px solid #e9ecef;
}

.listing-section:last-child {
    border-bottom: none;
}

.listing-section h6 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6c757d;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

/* Section Content Styles */
.section-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 8px;
}

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

.section-item {
    flex: 1;
    min-width: 200px;
}

.section-item label {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 2px;
    display: block;
}

.section-item .value {
    font-size: 0.925rem;
    color: #212529;
    word-break: break-word;
}

.section-item .value.monospace {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
}

/* Status Colors */
.listing-status-match {
    background-color: #d1e7dd;
    color: #0f5132;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.listing-status-failed {
    background-color: #f8d7da;
    color: #842029;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.listing-status-pending {
    background-color: #fff3cd;
    color: #664d03;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

/* Icons */
.listing-icon {
    font-size: 0.875rem;
    margin-right: 4px;
    opacity: 0.7;
}

/* Actions Section */
.listing-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.listing-actions .btn {
    font-size: 0.8rem;
    padding: 4px 10px;
}

/* JSON Display */
.json-display {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    max-height: 200px;
    overflow: auto;
    margin-top: 8px;
}

/* Image Gallery Preview */
.image-preview-list {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.image-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.image-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Responsive Design */
@media (max-width: 768px) {
    .listing-header {
        flex-wrap: wrap;
    }
    
    .listing-header .price {
        min-width: auto;
    }
    
    .listing-header .title {
        width: 100%;
        order: 2;
        margin-top: 4px;
    }
    
    .section-item {
        min-width: 100%;
    }
    
    .listing-actions {
        justify-content: center;
    }
}

/* Filter Tags */
.filter-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background-color: #e9ecef;
    border-radius: 12px;
    font-size: 0.75rem;
    color: #495057;
}

.filter-tag.passed {
    background-color: #d1e7dd;
    color: #0f5132;
}

.filter-tag.failed {
    background-color: #f8d7da;
    color: #842029;
}

/* Copy Button */
.copy-btn {
    cursor: pointer;
    color: #6c757d;
    font-size: 0.8rem;
    margin-left: 4px;
    transition: color 0.2s ease;
}

.copy-btn:hover {
    color: #0d6efd;
}

.copy-btn.copied {
    color: #198754;
}

/* Map Link */
.map-link {
    color: #0d6efd;
    text-decoration: none;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.map-link:hover {
    text-decoration: underline;
}

/* Listing Detail Modal */
.listing-detail-modal {
    max-height: 70vh;
    overflow-y: auto;
}

.listing-detail-modal .listing-section {
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 16px;
}

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

.listing-detail-modal .listing-actions {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 0;
}

#listingDetailModal .modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Button group in table */
.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.btn-group-sm .btn i {
    font-size: 0.875rem;
}

#listings-table th:nth-child(4), #listings-table td:nth-child(4) { width: 12%; } /* Location */
#listings-table th:nth-child(5), #listings-table td:nth-child(5) { width: 10%; } /* Posted */
#listings-table th:nth-child(6), #listings-table td:nth-child(6) { width: 10%; } /* Added to DB */
#listings-table th:nth-child(7), #listings-table td:nth-child(7) { width: 10%; } /* Scraper */
#listings-table th:nth-child(8), #listings-table td:nth-child(8) { width: 8%; }  /* Result */
#listings-table th:nth-child(9), #listings-table td:nth-child(9) { width: 5%; }  /* View */

/* Center align details button column */
#listings-table th:first-child,
#listings-table td:first-child {
    text-align: center;
}

/* Ensure tables use fixed layout for consistent column widths */
#tasks-table, #runs-table, #listings-table {
    table-layout: fixed;
    width: 100%;
}

/* Responsive adjustments for column widths */
@media (max-width: 1200px) {
    /* Adjust widths for medium screens */
    #listings-table th:nth-child(2), #listings-table td:nth-child(2) { width: 30%; }
    #listings-table th:nth-child(3), #listings-table td:nth-child(3) { width: 15%; }
}

@media (max-width: 768px) {
    /* Reset to auto widths on mobile for better responsiveness */
    #tasks-table, #runs-table, #listings-table, #retry-table {
        table-layout: auto;
    }
    
    #tasks-table th, #tasks-table td,
    #runs-table th, #runs-table td,
    #listings-table th, #listings-table td,
    #retry-table th, #retry-table td {
        width: auto !important;
    }
}

/* Retry Section Styles */
#retry-section .badge {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

#retry-section .alert {
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
}

#retry-table .text-truncate-custom {
    cursor: help;
}

#retry-table .badge {
    font-size: 0.75rem;
}

/* Metrics Report Styles */
.metric-card {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.metric-card h6 {
    color: #495057;
    font-weight: 600;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.5rem;
}

.metric-detail {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

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