/* Tracing Page */
.tracing-page {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 1.5rem;
    overflow: hidden;
    min-height: 0;
}

.tracing-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
    flex-shrink: 0;
}

.tracing-form-group {
    flex: 1;
    min-width: 200px;
}

.tracing-form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.tracing-input {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid #374151;
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.tracing-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.file-upload-btn {
    position: relative;
    overflow: hidden;
}

.file-upload-btn input[type="file"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.tracing-content {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    flex: 1;
    overflow: hidden;
}

.tracing-sidebar {
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    padding: 1.5rem;
    border: 1px solid var(--bg-tertiary);
    overflow-y: auto;
}

.tracing-sidebar h3 {
    color: #fff;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.trace-result-item {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.trace-result-item:hover {
    background: #374151;
}

.trace-result-item.selected {
    background: var(--accent-color);
    color: #fff;
}

.trace-timestamp {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.tracing-map-container {
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    border: 1px solid var(--bg-tertiary);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tracing-map-header {
    padding: 1.25rem 1.5rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid #374151;
}

.tracing-map-header h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
}

#tracingMap {
    flex: 1;
    min-height: 400px;  /* Required: Leaflet needs explicit height */
    height: 100%;
}

/* Trace Result Item with Image */
.trace-result-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.trace-result-image {
    flex-shrink: 0;
}

.trace-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 2px solid var(--accent-color);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.trace-thumbnail:hover {
    transform: scale(1.1);
    border-color: #ef4444;
}

.trace-thumbnail-placeholder {
    width: 60px;
    height: 60px;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    border: 2px dashed var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

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

.trace-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.trace-result-number {
    background: #ef4444;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.trace-result-info {
    margin-bottom: 0.25rem;
}

/* Map Marker with Image Thumbnail */
.trace-image-marker {
    background: transparent !important;
    border: none !important;
}

.trace-marker-container {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
}

.trace-marker-container:hover {
    transform: scale(1.15);
    z-index: 1000 !important;
}

.trace-marker-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    border: 2px solid white;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.map-pin-thumbnail {
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Full Frame Image Modal */
.fullframe-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fullframe-modal-content {
    background: var(--bg-secondary);
    border-radius: 1rem;
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
}

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

.fullframe-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid #374151;
}

.fullframe-modal-header h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    margin: 0;
}

.fullframe-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.fullframe-close-btn:hover {
    background: #ef4444;
    color: white;
}

.fullframe-modal-body {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: #000;
}

.fullframe-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 0.5rem;
}

.fullframe-modal-body .error-message {
    color: var(--text-secondary);
    padding: 3rem;
    text-align: center;
}

.fullframe-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-top: 1px solid #374151;
    gap: 1rem;
}

.fullframe-info {
    display: flex;
    gap: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    flex-wrap: wrap;
}

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

/* Trace Popup on Map */
.trace-popup {
    padding: 0.5rem;
}

.trace-popup strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 0.25rem;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Spinner for loading states */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
